web47core 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66de41059addc2feb9a356910262228c3023e61b3860080f55e1b7a66b0f3b8c
4
- data.tar.gz: 40768029411501eb25cf379bc9d42fb3a1ab0124103e09a29df09cf3816afbb8
3
+ metadata.gz: fd6df6a00053ff9fd998b767d581c1468ce7fff3f230526333b73839e59670cf
4
+ data.tar.gz: 1b3d1bd842c3ba6bb6878073cd4ddc71c4e966f144df67a13587f97fcbe4c191
5
5
  SHA512:
6
- metadata.gz: 211c0e7e8ea7bd957ce8d4212d6ea72d10362f3d298d718c6d68d897a3dc2da76a0dddf4265f23dcf6881ab8b079a457666d6786f0044fb32565e5082212b78a
7
- data.tar.gz: 7699c4fde4221b0beca0819239477cbd6e086c2f0f5a92e40fe98079cc96ba419bd0d94bede45d10b14483de2b8e51dbc89209567f5974070ddd786e9e05acfd
6
+ metadata.gz: 5e8fe75827bda687fbfd29fb2109f22e2f0b7195c8655aceee8739c99abed900adf2c1c2b1b723ab2566bd7e89a26a35ca1fc8695afa2a84e8112cb0d2790389
7
+ data.tar.gz: be892f7392931062cb1be21187f84163f7f0534b4af9905b01c60e714ec85849dd6df3947e1da2faa4bd5cca0f3e8b51688b2b9789c9f2c4bc9954c1faffd6af
@@ -21,7 +21,13 @@ module CoreSystemConfiguration
21
21
  # Fields
22
22
  #
23
23
  field :environment, type: String, default: 'test'
24
- field :fips_mode, type: String, default: false
24
+ field :fips_mode, type: Boolean, default: false
25
+ field :fav_icon_path, { type: String, default: '/favicon.ico' }
26
+ field :default_logo_path, { type: String, default: 'ui-company-logo.png' }
27
+ field :primary_stylesheet, { type: String, default: 'app47' }
28
+ field :short_cache, { type: Integer, default: 1 }
29
+ field :medium_cache, { type: Integer, default: 5 }
30
+ field :long_cache, { type: Integer, default: 15 }
25
31
  # SMTP configuration
26
32
  field :default_email, type: String, default: 'support@app47.com'
27
33
  field :support_email, type: String, default: 'support@app47.com'
@@ -75,11 +81,7 @@ module CoreSystemConfiguration
75
81
 
76
82
  module ClassMethods
77
83
  def configuration
78
- @configuration ||= SystemConfiguration.find_or_create_by!(environment: Rails.env)
79
- end
80
-
81
- def reset
82
- @configuration = nil
84
+ SystemConfiguration.find_or_create_by!(environment: Rails.env)
83
85
  end
84
86
 
85
87
  def smtp_configuration
@@ -125,6 +127,21 @@ module CoreSystemConfiguration
125
127
  zendesk_token]
126
128
  end
127
129
 
130
+ #
131
+ # Cache times in minutes
132
+ #
133
+ def short_cache_time
134
+ short_cache.minutes
135
+ end
136
+
137
+ def medium_cache_time
138
+ medium_cache.minutes
139
+ end
140
+
141
+ def long_cache_time
142
+ long_cache.minutes
143
+ end
144
+
128
145
  #
129
146
  # Determine if SMTP is configured
130
147
  #
@@ -249,13 +266,4 @@ module CoreSystemConfiguration
249
266
  def slack_configured?
250
267
  slack_api_url.present?
251
268
  end
252
-
253
- # private
254
-
255
- #
256
- # Clear the cache when the object is saved
257
- #
258
- # def clear_cache
259
- # Rails.cache.delete "SystemConfiguration::#{Rails.env}"
260
- # end
261
269
  end
@@ -22,9 +22,9 @@ module StandardModel
22
22
  #
23
23
  # Relationships
24
24
  #
25
- belongs_to :last_modified_by, class_name: Web47core::Config.audit_model_class_name, optional: true
26
- belongs_to :created_by, class_name: Web47core::Config.audit_model_class_name, optional: true
27
- has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify
25
+ belongs_to :last_modified_by, polymorphic: true, dependent: :nullify, optional: true
26
+ belongs_to :created_by, polymorphic: true, dependent: :nullify, optional: true
27
+ has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify, inverse_of: :model
28
28
  #
29
29
  # Callbacks
30
30
  #
@@ -98,9 +98,10 @@ module StandardModel
98
98
  # Record the creation with this user
99
99
  #
100
100
  def create_and_log(user, attributes)
101
- attributes[:last_modified_by_id] = user.id
102
- attributes[:created_by_id] = user.id
103
101
  model = create(attributes)
102
+ model.last_modified_by = user
103
+ model.created_by = user
104
+ model.save
104
105
  log_change(user, model, attributes) if model.valid?
105
106
  model
106
107
  end
@@ -109,9 +110,10 @@ module StandardModel
109
110
  # Record the creation with this user
110
111
  #
111
112
  def create_and_log!(user, attributes)
112
- attributes[:last_modified_by_id] = user.id
113
- attributes[:created_by_id] = user.id
114
113
  model = create!(attributes)
114
+ model.last_modified_by = user
115
+ model.created_by = user
116
+ model.save!
115
117
  log_change(user, model, attributes)
116
118
  model
117
119
  end
@@ -209,7 +211,7 @@ module StandardModel
209
211
  return self if attributes.blank?
210
212
 
211
213
  action = audit_action
212
- attributes[:last_modified_by_id] = user.id
214
+ self.last_modified_by = user
213
215
  result = update(attributes)
214
216
  log_change(user, attributes, action) if valid?
215
217
  result
@@ -224,7 +226,7 @@ module StandardModel
224
226
  return self if attributes.blank?
225
227
 
226
228
  action = audit_action
227
- attributes[:last_modified_by_id] = user.id
229
+ self.last_modified_by = user
228
230
  result = update!(attributes)
229
231
  log_change(user, attributes, action)
230
232
  result
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '0.7.2'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-11 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport