pg_rails 7.0.5 → 7.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/pg_associable/lib/pg_associable/engine.rb +0 -4
  4. data/pg_associable/lib/pg_associable/simple_form_initializer.rb +2 -2
  5. data/pg_associable/spec/pg_associable/helpers_spec.rb +4 -3
  6. data/pg_engine/app/admin/accounts.rb +25 -0
  7. data/pg_engine/{lib/templates/activeadmin → app/admin}/audits.rb +3 -3
  8. data/pg_engine/app/admin/dashboard.rb +34 -0
  9. data/pg_engine/app/admin/user_accounts.rb +26 -0
  10. data/pg_engine/{lib/templates/activeadmin → app/admin}/users.rb +1 -2
  11. data/pg_engine/app/assets/javascripts/active_admin.js +1 -0
  12. data/pg_engine/app/assets/stylesheets/active_admin.scss +17 -0
  13. data/pg_engine/app/controllers/admin/accounts_controller.rb +33 -0
  14. data/pg_engine/app/controllers/admin/user_accounts_controller.rb +33 -0
  15. data/pg_engine/app/controllers/admin/users_controller.rb +47 -0
  16. data/pg_engine/app/controllers/pg_engine/resource_helper.rb +10 -5
  17. data/pg_engine/app/decorators/account_decorator.rb +16 -0
  18. data/pg_engine/app/decorators/pg_engine/base_decorator.rb +14 -12
  19. data/pg_engine/app/decorators/user_account_decorator.rb +19 -0
  20. data/pg_engine/app/decorators/user_decorator.rb +20 -0
  21. data/pg_engine/app/helpers/pg_engine/flash_helper.rb +1 -1
  22. data/pg_engine/app/models/account.rb +39 -0
  23. data/pg_engine/app/models/user.rb +61 -0
  24. data/pg_engine/app/models/user_account.rb +46 -0
  25. data/pg_engine/app/policies/account_policy.rb +31 -0
  26. data/pg_engine/app/policies/pg_engine/application_policy.rb +1 -1
  27. data/pg_engine/app/policies/user_account_policy.rb +31 -0
  28. data/pg_engine/app/policies/user_policy.rb +31 -0
  29. data/pg_engine/app/views/admin/accounts/_account.html.slim +1 -0
  30. data/pg_engine/app/views/admin/accounts/_form.html.slim +12 -0
  31. data/pg_engine/app/views/admin/accounts/edit.html.slim +5 -0
  32. data/pg_engine/app/views/admin/accounts/new.html.slim +5 -0
  33. data/pg_engine/app/views/admin/accounts/show.html.slim +27 -0
  34. data/pg_engine/app/views/admin/user_accounts/_form.html.slim +12 -0
  35. data/pg_engine/app/views/admin/user_accounts/_user_account.html.slim +1 -0
  36. data/pg_engine/app/views/admin/user_accounts/edit.html.slim +5 -0
  37. data/pg_engine/app/views/admin/user_accounts/new.html.slim +5 -0
  38. data/pg_engine/app/views/admin/user_accounts/show.html.slim +24 -0
  39. data/pg_engine/app/views/admin/users/_form.html.slim +12 -0
  40. data/pg_engine/app/views/admin/users/_user.html.slim +1 -0
  41. data/pg_engine/app/views/admin/users/edit.html.slim +5 -0
  42. data/pg_engine/app/views/admin/users/new.html.slim +5 -0
  43. data/pg_engine/app/views/admin/users/show.html.slim +27 -0
  44. data/pg_engine/config/initializers/active_admin.rb +355 -0
  45. data/pg_engine/config/initializers/devise.rb +313 -0
  46. data/pg_engine/config/locales/devise.en.yml +65 -0
  47. data/pg_engine/config/routes.rb +11 -0
  48. data/pg_engine/db/migrate/20240205194218_devise_create_users.rb +47 -0
  49. data/pg_engine/db/migrate/20240208234111_unaccent.rb +5 -0
  50. data/pg_engine/db/migrate/20240208234901_install_audited.rb +32 -0
  51. data/pg_engine/db/migrate/20240210025702_create_active_admin_comments.rb +16 -0
  52. data/pg_engine/db/migrate/20240211152951_create_accounts.rb +24 -0
  53. data/pg_engine/db/migrate/20240211153049_create_user_accounts.rb +20 -0
  54. data/pg_engine/db/seeds.rb +5 -0
  55. data/pg_engine/lib/pg_engine/core_ext.rb +14 -14
  56. data/pg_engine/lib/pg_engine/engine.rb +16 -2
  57. data/pg_engine/lib/pg_engine/route_helpers.rb +2 -2
  58. data/pg_engine/lib/tasks/auto_anotar_modelos.rake +2 -2
  59. data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +206 -0
  60. data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +189 -0
  61. data/pg_engine/spec/controllers/admin/users_controller_spec.rb +180 -0
  62. data/pg_engine/spec/factories/accounts.rb +11 -0
  63. data/pg_engine/spec/factories/user_accounts.rb +21 -0
  64. data/pg_engine/spec/factories/users.rb +59 -0
  65. data/pg_engine/spec/models/account_spec.rb +13 -0
  66. data/pg_engine/spec/models/user_account_spec.rb +13 -0
  67. data/pg_engine/spec/models/user_spec.rb +13 -0
  68. data/pg_layout/lib/pg_layout/engine.rb +0 -1
  69. data/pg_rails/lib/version.rb +1 -1
  70. data/pg_scaffold/lib/generators/pg_pundit/templates/policy.rb +1 -1
  71. data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +4 -4
  72. data/pg_scaffold/lib/generators/pg_slim/templates/show.html.slim +4 -4
  73. data/pg_scaffold/lib/pg_scaffold/monkey_patches/mejoras_de_atributos.rb +2 -2
  74. data/pg_scaffold/spec/generators_spec.rb +1 -1
  75. metadata +56 -4
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Assuming you have not yet modified this file, each configuration option below
4
+ # is set to its default value. Note that some are commented out while others
5
+ # are not: uncommented lines are intended to protect your configuration from
6
+ # breaking changes in upgrades (i.e., in the event that future versions of
7
+ # Devise change the default values for those options).
8
+ #
9
+ # Use this hook to configure devise mailer, warden hooks and so forth.
10
+ # Many of these configuration options can be set straight in your model.
11
+ Devise.setup do |config|
12
+ # The secret key used by Devise. Devise uses this key to generate
13
+ # random tokens. Changing this key will render invalid all existing
14
+ # confirmation, reset password and unlock tokens in the database.
15
+ # Devise will use the `secret_key_base` as its `secret_key`
16
+ # by default. You can change it below and use your own secret key.
17
+ # config.secret_key = 'd243e2c4fbcd52571258623e43c6aae7d981651de9c7a219ac785a6f2750c497c972331d2ab275034cf551f296759affa9fdd952a5f459631e41193200b55366'
18
+
19
+ # ==> Controller configuration
20
+ # Configure the parent class to the devise controllers.
21
+ config.parent_controller = 'PgEngine::DeviseController'
22
+
23
+ # ==> Mailer Configuration
24
+ # Configure the e-mail address which will be shown in Devise::Mailer,
25
+ # note that it will be overwritten if you use your own mailer class
26
+ # with default "from" parameter.
27
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28
+
29
+ # Configure the class responsible to send e-mails.
30
+ # config.mailer = 'Devise::Mailer'
31
+
32
+ # Configure the parent class responsible to send e-mails.
33
+ # config.parent_mailer = 'ActionMailer::Base'
34
+
35
+ # ==> ORM configuration
36
+ # Load and configure the ORM. Supports :active_record (default) and
37
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
38
+ # available as additional gems.
39
+ require 'devise/orm/active_record'
40
+
41
+ # ==> Configuration for any authentication mechanism
42
+ # Configure which keys are used when authenticating a user. The default is
43
+ # just :email. You can configure it to use [:username, :subdomain], so for
44
+ # authenticating a user, both parameters are required. Remember that those
45
+ # parameters are used only when authenticating and not when retrieving from
46
+ # session. If you need permissions, you should implement that in a before filter.
47
+ # You can also supply a hash where the value is a boolean determining whether
48
+ # or not authentication should be aborted when the value is not present.
49
+ # config.authentication_keys = [:email]
50
+
51
+ # Configure parameters from the request object used for authentication. Each entry
52
+ # given should be a request method and it will automatically be passed to the
53
+ # find_for_authentication method and considered in your model lookup. For instance,
54
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
56
+ # config.request_keys = []
57
+
58
+ # Configure which authentication keys should be case-insensitive.
59
+ # These keys will be downcased upon creating or modifying a user and when used
60
+ # to authenticate or find a user. Default is :email.
61
+ config.case_insensitive_keys = [:email]
62
+
63
+ # Configure which authentication keys should have whitespace stripped.
64
+ # These keys will have whitespace before and after removed upon creating or
65
+ # modifying a user and when used to authenticate or find a user. Default is :email.
66
+ config.strip_whitespace_keys = [:email]
67
+
68
+ # Tell if authentication through request.params is enabled. True by default.
69
+ # It can be set to an array that will enable params authentication only for the
70
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
71
+ # enable it only for database (email + password) authentication.
72
+ # config.params_authenticatable = true
73
+
74
+ # Tell if authentication through HTTP Auth is enabled. False by default.
75
+ # It can be set to an array that will enable http authentication only for the
76
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
77
+ # enable it only for database authentication.
78
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
79
+ # enable this with :database unless you are using a custom strategy.
80
+ # The supported strategies are:
81
+ # :database = Support basic authentication with authentication key + password
82
+ # config.http_authenticatable = false
83
+
84
+ # If 401 status code should be returned for AJAX requests. True by default.
85
+ # config.http_authenticatable_on_xhr = true
86
+
87
+ # The realm used in Http Basic Authentication. 'Application' by default.
88
+ # config.http_authentication_realm = 'Application'
89
+
90
+ # It will change confirmation, password recovery and other workflows
91
+ # to behave the same regardless if the e-mail provided was right or wrong.
92
+ # Does not affect registerable.
93
+ # config.paranoid = true
94
+
95
+ # By default Devise will store the user in session. You can skip storage for
96
+ # particular strategies by setting this option.
97
+ # Notice that if you are skipping storage for all authentication paths, you
98
+ # may want to disable generating routes to Devise's sessions controller by
99
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
100
+ config.skip_session_storage = [:http_auth]
101
+
102
+ # By default, Devise cleans up the CSRF token on authentication to
103
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
104
+ # requests for sign in and sign up, you need to get a new CSRF token
105
+ # from the server. You can disable this option at your own risk.
106
+ # config.clean_up_csrf_token_on_authentication = true
107
+
108
+ # When false, Devise will not attempt to reload routes on eager load.
109
+ # This can reduce the time taken to boot the app but if your application
110
+ # requires the Devise mappings to be loaded during boot time the application
111
+ # won't boot properly.
112
+ # config.reload_routes = true
113
+
114
+ # ==> Configuration for :database_authenticatable
115
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116
+ # using other algorithms, it sets how many times you want the password to be hashed.
117
+ # The number of stretches used for generating the hashed password are stored
118
+ # with the hashed password. This allows you to change the stretches without
119
+ # invalidating existing passwords.
120
+ #
121
+ # Limiting the stretches to just one in testing will increase the performance of
122
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
124
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
125
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126
+ config.stretches = Rails.env.test? ? 1 : 12
127
+
128
+ # Set up a pepper to generate the hashed password.
129
+ # config.pepper = 'c23be87dd0d0a148bf792b4ad49c493ce23da3bb60a9ed3bb2e5757b63d573ea34fc49cbe63e61ef67cb2d0d03f002efc19ca354e01c6fca0d70c3f40ea584fe'
130
+
131
+ # Send a notification to the original email when the user's email is changed.
132
+ # config.send_email_changed_notification = false
133
+
134
+ # Send a notification email when the user's password is changed.
135
+ # config.send_password_change_notification = false
136
+
137
+ # ==> Configuration for :confirmable
138
+ # A period that the user is allowed to access the website even without
139
+ # confirming their account. For instance, if set to 2.days, the user will be
140
+ # able to access the website for two days without confirming their account,
141
+ # access will be blocked just in the third day.
142
+ # You can also set it to nil, which will allow the user to access the website
143
+ # without confirming their account.
144
+ # Default is 0.days, meaning the user cannot access the website without
145
+ # confirming their account.
146
+ # config.allow_unconfirmed_access_for = 2.days
147
+
148
+ # A period that the user is allowed to confirm their account before their
149
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
150
+ # their account within 3 days after the mail was sent, but on the fourth day
151
+ # their account can't be confirmed with the token any more.
152
+ # Default is nil, meaning there is no restriction on how long a user can take
153
+ # before confirming their account.
154
+ # config.confirm_within = 3.days
155
+
156
+ # If true, requires any email changes to be confirmed (exactly the same way as
157
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
158
+ # db field (see migrations). Until confirmed, new email is stored in
159
+ # unconfirmed_email column, and copied to email column on successful confirmation.
160
+ config.reconfirmable = true
161
+
162
+ # Defines which key will be used when confirming an account
163
+ # config.confirmation_keys = [:email]
164
+
165
+ # ==> Configuration for :rememberable
166
+ # The time the user will be remembered without asking for credentials again.
167
+ # config.remember_for = 2.weeks
168
+
169
+ # Invalidates all the remember me tokens when the user signs out.
170
+ config.expire_all_remember_me_on_sign_out = true
171
+
172
+ # If true, extends the user's remember period when remembered via cookie.
173
+ # config.extend_remember_period = false
174
+
175
+ # Options to be passed to the created cookie. For instance, you can set
176
+ # secure: true in order to force SSL only cookies.
177
+ # config.rememberable_options = {}
178
+
179
+ # ==> Configuration for :validatable
180
+ # Range for password length.
181
+ config.password_length = 6..128
182
+
183
+ # Email regex used to validate email formats. It simply asserts that
184
+ # one (and only one) @ exists in the given string. This is mainly
185
+ # to give user feedback and not to assert the e-mail validity.
186
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187
+
188
+ # ==> Configuration for :timeoutable
189
+ # The time you want to timeout the user session without activity. After this
190
+ # time the user will be asked for credentials again. Default is 30 minutes.
191
+ # config.timeout_in = 30.minutes
192
+
193
+ # ==> Configuration for :lockable
194
+ # Defines which strategy will be used to lock an account.
195
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196
+ # :none = No lock strategy. You should handle locking by yourself.
197
+ # config.lock_strategy = :failed_attempts
198
+
199
+ # Defines which key will be used when locking and unlocking an account
200
+ # config.unlock_keys = [:email]
201
+
202
+ # Defines which strategy will be used to unlock an account.
203
+ # :email = Sends an unlock link to the user email
204
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205
+ # :both = Enables both strategies
206
+ # :none = No unlock strategy. You should handle unlocking by yourself.
207
+ # config.unlock_strategy = :both
208
+
209
+ # Number of authentication tries before locking an account if lock_strategy
210
+ # is failed attempts.
211
+ # config.maximum_attempts = 20
212
+
213
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
214
+ # config.unlock_in = 1.hour
215
+
216
+ # Warn on the last attempt before the account is locked.
217
+ # config.last_attempt_warning = true
218
+
219
+ # ==> Configuration for :recoverable
220
+ #
221
+ # Defines which key will be used when recovering the password for an account
222
+ # config.reset_password_keys = [:email]
223
+
224
+ # Time interval you can reset your password with a reset password key.
225
+ # Don't put a too small interval or your users won't have the time to
226
+ # change their passwords.
227
+ config.reset_password_within = 6.hours
228
+
229
+ # When set to false, does not sign a user in automatically after their password is
230
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
231
+ # config.sign_in_after_reset_password = true
232
+
233
+ # ==> Configuration for :encryptable
234
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
236
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237
+ # for default behavior) and :restful_authentication_sha1 (then you should set
238
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239
+ #
240
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
241
+ # config.encryptor = :sha512
242
+
243
+ # ==> Scopes configuration
244
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
245
+ # "users/sessions/new". It's turned off by default because it's slower if you
246
+ # are using only default views.
247
+ # config.scoped_views = false
248
+
249
+ # Configure the default scope given to Warden. By default it's the first
250
+ # devise role declared in your routes (usually :user).
251
+ # config.default_scope = :user
252
+
253
+ # Set this configuration to false if you want /users/sign_out to sign out
254
+ # only the current scope. By default, Devise signs out all scopes.
255
+ # config.sign_out_all_scopes = true
256
+
257
+ # ==> Navigation configuration
258
+ # Lists the formats that should be treated as navigational. Formats like
259
+ # :html should redirect to the sign in page when the user does not have
260
+ # access, but formats like :xml or :json, should return 401.
261
+ #
262
+ # If you have any extra navigational formats, like :iphone or :mobile, you
263
+ # should add them to the navigational formats lists.
264
+ #
265
+ # The "*/*" below is required to match Internet Explorer requests.
266
+ # config.navigational_formats = ['*/*', :html, :turbo_stream]
267
+
268
+ # The default HTTP method used to sign out a resource. Default is :delete.
269
+ config.sign_out_via = :delete
270
+
271
+ # ==> OmniAuth
272
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
273
+ # up on your models and hooks.
274
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275
+
276
+ # ==> Warden configuration
277
+ # If you want to use other strategies, that are not supported by Devise, or
278
+ # change the failure app, you can configure them inside the config.warden block.
279
+ #
280
+ # config.warden do |manager|
281
+ # manager.intercept_401 = false
282
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
283
+ # end
284
+
285
+ # ==> Mountable engine configurations
286
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
287
+ # is mountable, there are some extra configurations to be taken into account.
288
+ # The following options are available, assuming the engine is mounted as:
289
+ #
290
+ # mount MyEngine, at: '/my_engine'
291
+ #
292
+ # The router that invoked `devise_for`, in the example above, would be:
293
+ # config.router_name = :my_engine
294
+ #
295
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
296
+ # so you need to do it manually. For the users scope, it would be:
297
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
298
+
299
+ # ==> Hotwire/Turbo configuration
300
+ # When using Devise with Hotwire/Turbo, the http status for error responses
301
+ # and some redirects must match the following. The default in Devise for existing
302
+ # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
303
+ # these new defaults that match Hotwire/Turbo behavior.
304
+ # Note: These might become the new default in future versions of Devise.
305
+ config.responder.error_status = :unprocessable_entity
306
+ config.responder.redirect_status = :see_other
307
+
308
+ # ==> Configuration for :registerable
309
+
310
+ # When set to false, does not sign a user in automatically after their password is
311
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
312
+ # config.sign_in_after_change_password = true
313
+ end
@@ -0,0 +1,65 @@
1
+ # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your email address has been successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid %{authentication_keys} or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account is locked."
15
+ not_found_in_database: "Invalid %{authentication_keys} or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your email address before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock instructions"
26
+ email_changed:
27
+ subject: "Email Changed"
28
+ password_change:
29
+ subject: "Password Changed"
30
+ omniauth_callbacks:
31
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32
+ success: "Successfully authenticated from %{kind} account."
33
+ passwords:
34
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37
+ updated: "Your password has been changed successfully. You are now signed in."
38
+ updated_not_active: "Your password has been changed successfully."
39
+ registrations:
40
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41
+ signed_up: "Welcome! You have signed up successfully."
42
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46
+ updated: "Your account has been updated successfully."
47
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
48
+ sessions:
49
+ signed_in: "Signed in successfully."
50
+ signed_out: "Signed out successfully."
51
+ already_signed_out: "Signed out successfully."
52
+ unlocks:
53
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56
+ errors:
57
+ messages:
58
+ already_confirmed: "was already confirmed, please try signing in"
59
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60
+ expired: "has expired, please request a new one"
61
+ not_found: "not found"
62
+ not_locked: "was not locked"
63
+ not_saved:
64
+ one: "1 error prohibited this %{resource} from being saved:"
65
+ other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -0,0 +1,11 @@
1
+ include PgEngine::RouteHelpers
2
+
3
+ Rails.application.routes.draw do
4
+ devise_for :users
5
+ namespace :admin, path: 'a' do
6
+ pg_resource(:users)
7
+ pg_resource(:accounts)
8
+ pg_resource(:user_accounts)
9
+ end
10
+ ActiveAdmin.routes(self)
11
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeviseCreateUsers < ActiveRecord::Migration[7.1]
4
+ def change
5
+ create_table :users do |t|
6
+ ## Database authenticatable
7
+ t.string :email, null: false, default: ""
8
+ t.string :encrypted_password, null: false, default: ""
9
+
10
+ ## Recoverable
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+
14
+ ## Rememberable
15
+ t.datetime :remember_created_at
16
+
17
+ ## Trackable
18
+ t.integer :sign_in_count, default: 0, null: false
19
+ t.datetime :current_sign_in_at
20
+ t.datetime :last_sign_in_at
21
+ t.string :current_sign_in_ip
22
+ t.string :last_sign_in_ip
23
+
24
+ ## Confirmable
25
+ t.string :confirmation_token
26
+ t.datetime :confirmed_at
27
+ t.datetime :confirmation_sent_at
28
+ t.string :unconfirmed_email # Only if using reconfirmable
29
+
30
+ ## Lockable
31
+ t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32
+ t.string :unlock_token # Only if unlock strategy is :email or :both
33
+ t.datetime :locked_at
34
+
35
+ t.boolean :developer, null: false, default: false
36
+
37
+ t.timestamps null: false
38
+ end
39
+
40
+ add_column :users, :discarded_at, :datetime
41
+
42
+ add_index :users, :email, unique: true
43
+ add_index :users, :reset_password_token, unique: true
44
+ add_index :users, :confirmation_token, unique: true
45
+ add_index :users, :unlock_token, unique: true
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ class Unaccent < ActiveRecord::Migration[7.1]
2
+ def change
3
+ enable_extension "unaccent"
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ class InstallAudited < ActiveRecord::Migration[7.1]
4
+ def self.up
5
+ create_table :audits, :force => true do |t|
6
+ t.column :auditable_id, :integer
7
+ t.column :auditable_type, :string
8
+ t.column :associated_id, :integer
9
+ t.column :associated_type, :string
10
+ t.column :user_id, :integer
11
+ t.column :user_type, :string
12
+ t.column :username, :string
13
+ t.column :action, :string
14
+ t.column :audited_changes, :jsonb
15
+ t.column :version, :integer, :default => 0
16
+ t.column :comment, :string
17
+ t.column :remote_address, :string
18
+ t.column :request_uuid, :string
19
+ t.column :created_at, :datetime
20
+ end
21
+
22
+ add_index :audits, [:auditable_type, :auditable_id, :version], :name => 'auditable_index'
23
+ add_index :audits, [:associated_type, :associated_id], :name => 'associated_index'
24
+ add_index :audits, [:user_id, :user_type], :name => 'user_index'
25
+ add_index :audits, :request_uuid
26
+ add_index :audits, :created_at
27
+ end
28
+
29
+ def self.down
30
+ drop_table :audits
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ class CreateActiveAdminComments < ActiveRecord::Migration[7.1]
2
+ def self.up
3
+ create_table :active_admin_comments do |t|
4
+ t.string :namespace
5
+ t.text :body
6
+ t.references :resource, polymorphic: true
7
+ t.references :author, polymorphic: true
8
+ t.timestamps
9
+ end
10
+ add_index :active_admin_comments, [:namespace]
11
+ end
12
+
13
+ def self.down
14
+ drop_table :active_admin_comments
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # generado con pg_rails
2
+
3
+ class CreateAccounts < ActiveRecord::Migration[7.1]
4
+ def change
5
+ create_table :accounts do |t|
6
+ t.integer :plan, null: false
7
+ t.string :nombre, null: false
8
+ t.string :hashid
9
+
10
+
11
+ t.references :creado_por, index: true
12
+ t.references :actualizado_por, index: true
13
+
14
+
15
+ t.datetime :discarded_at
16
+
17
+ t.timestamps
18
+ end
19
+
20
+
21
+ add_foreign_key :accounts, :users, column: 'creado_por_id'
22
+ add_foreign_key :accounts, :users, column: 'actualizado_por_id'
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # generado con pg_rails
2
+
3
+ class CreateUserAccounts < ActiveRecord::Migration[7.1]
4
+ def change
5
+ create_table :user_accounts do |t|
6
+ t.references :user, index: true, null: false, foreign_key: true
7
+ t.references :account, index: true, null: false, foreign_key: true
8
+ t.integer :profiles, array: true, null: false, default: []
9
+
10
+ t.references :creado_por, index: true
11
+ t.references :actualizado_por, index: true
12
+
13
+ t.timestamps
14
+ end
15
+
16
+
17
+ add_foreign_key :user_accounts, :users, column: 'creado_por_id'
18
+ add_foreign_key :user_accounts, :users, column: 'actualizado_por_id'
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ ['mrosso10@gmail.com'].each do |mail|
2
+ unless User.exists?(email: mail)
3
+ User.create(email: mail, password: 'admin123', confirmed_at: Time.now, developer: true)
4
+ end
5
+ end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # require 'activesupport/time'
4
- module ActiveSupport
5
- class TimeWithZone
6
- def to_s(format = :default)
7
- if format == :db
8
- utc.to_s(format)
9
- elsif formatter = ::Time::DATE_FORMATS[format] # rubocop:disable Lint/AssignmentInCondition
10
- formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
11
- else
12
- # "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format
13
- time.strftime('%d/%m/%Y %H:%M')
14
- end
15
- end
16
- end
17
- end
4
+ # module ActiveSupport
5
+ # class TimeWithZone
6
+ # def to_s(format = :default)
7
+ # if format == :db
8
+ # utc.to_s(format)
9
+ # elsif formatter = ::Time::DATE_FORMATS[format]
10
+ # formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
11
+ # else
12
+ # # "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format
13
+ # time.strftime('%d/%m/%Y %H:%M')
14
+ # end
15
+ # end
16
+ # end
17
+ # end
@@ -2,11 +2,25 @@
2
2
 
3
3
  module PgEngine
4
4
  class Engine < ::Rails::Engine
5
- isolate_namespace PgEngine
6
-
7
5
  config.i18n.default_locale = :es
8
6
  config.time_zone = 'America/Argentina/Buenos_Aires'
9
7
 
8
+ config.generators do |g|
9
+ g.test_framework :pg_rspec
10
+ g.orm :pg_active_record
11
+
12
+ g.fallbacks[:pg_rspec] = :rspec
13
+ g.fallbacks[:pg_active_record] = :active_record
14
+ end
15
+
16
+ if Rails.env.local?
17
+ initializer 'configurar_factories', after: 'factory_bot.set_factory_paths' do
18
+ # Para que tome las factories de pg_engine/spec/factories
19
+ # además de las de dummy/spec/factories
20
+ FactoryBot.definition_file_paths << "#{root}/spec/factories"
21
+ end
22
+ end
23
+
10
24
  initializer 'configurar_pg_rails' do
11
25
  # SimpleForm
12
26
  require "#{PgEngine::Engine.root}/config/simple_form/simple_form"
@@ -1,7 +1,7 @@
1
1
  module PgEngine
2
2
  module RouteHelpers
3
- def pg_resource(key)
4
- resources(key) do
3
+ def pg_resource(key, options = {})
4
+ resources(key, options) do
5
5
  collection do
6
6
  get :abrir_modal
7
7
  post :buscar
@@ -27,7 +27,7 @@ if Rails.env.development?
27
27
  'require' => '',
28
28
  'exclude_tests' => 'true',
29
29
  'exclude_fixtures' => 'true',
30
- 'exclude_factories' => 'true',
30
+ 'exclude_factories' => 'false',
31
31
  'exclude_serializers' => 'true',
32
32
  'exclude_scaffolds' => 'true',
33
33
  'exclude_controllers' => 'true',
@@ -35,7 +35,7 @@ if Rails.env.development?
35
35
  'exclude_sti_subclasses' => 'false',
36
36
  'ignore_model_sub_dir' => 'false',
37
37
  'ignore_columns' => nil,
38
- 'ignore_routes' => nil,
38
+ 'ignore_routes' => 'rails|active_admin',
39
39
  'ignore_unknown_models' => 'false',
40
40
  # 'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(",") %>',
41
41
  # 'hide_default_column_types' => '<%= AnnotateModels::NO_DEFAULT_COL_TYPES.join(",") %>',