pg_rails 7.0.6 → 7.0.7

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.
Files changed (68) 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/spec/pg_associable/helpers_spec.rb +4 -3
  5. data/pg_engine/app/admin/accounts.rb +25 -0
  6. data/pg_engine/{lib/templates/activeadmin → app/admin}/audits.rb +3 -3
  7. data/pg_engine/app/admin/dashboard.rb +34 -0
  8. data/pg_engine/app/admin/user_accounts.rb +26 -0
  9. data/pg_engine/{lib/templates/activeadmin → app/admin}/users.rb +1 -2
  10. data/pg_engine/app/assets/javascripts/active_admin.js +1 -0
  11. data/pg_engine/app/assets/stylesheets/active_admin.scss +17 -0
  12. data/pg_engine/app/controllers/admin/accounts_controller.rb +33 -0
  13. data/pg_engine/app/controllers/admin/user_accounts_controller.rb +33 -0
  14. data/pg_engine/app/controllers/admin/users_controller.rb +47 -0
  15. data/pg_engine/app/controllers/pg_engine/resource_helper.rb +1 -0
  16. data/pg_engine/app/decorators/account_decorator.rb +16 -0
  17. data/pg_engine/app/decorators/user_account_decorator.rb +19 -0
  18. data/pg_engine/app/decorators/user_decorator.rb +20 -0
  19. data/pg_engine/app/helpers/pg_engine/flash_helper.rb +1 -1
  20. data/pg_engine/app/models/account.rb +39 -0
  21. data/pg_engine/app/models/user.rb +61 -0
  22. data/pg_engine/app/models/user_account.rb +46 -0
  23. data/pg_engine/app/policies/account_policy.rb +31 -0
  24. data/pg_engine/app/policies/pg_engine/application_policy.rb +1 -1
  25. data/pg_engine/app/policies/user_account_policy.rb +31 -0
  26. data/pg_engine/app/policies/user_policy.rb +31 -0
  27. data/pg_engine/app/views/admin/accounts/_account.html.slim +1 -0
  28. data/pg_engine/app/views/admin/accounts/_form.html.slim +12 -0
  29. data/pg_engine/app/views/admin/accounts/edit.html.slim +5 -0
  30. data/pg_engine/app/views/admin/accounts/new.html.slim +5 -0
  31. data/pg_engine/app/views/admin/accounts/show.html.slim +27 -0
  32. data/pg_engine/app/views/admin/user_accounts/_form.html.slim +12 -0
  33. data/pg_engine/app/views/admin/user_accounts/_user_account.html.slim +1 -0
  34. data/pg_engine/app/views/admin/user_accounts/edit.html.slim +5 -0
  35. data/pg_engine/app/views/admin/user_accounts/new.html.slim +5 -0
  36. data/pg_engine/app/views/admin/user_accounts/show.html.slim +24 -0
  37. data/pg_engine/app/views/admin/users/_form.html.slim +12 -0
  38. data/pg_engine/app/views/admin/users/_user.html.slim +1 -0
  39. data/pg_engine/app/views/admin/users/edit.html.slim +5 -0
  40. data/pg_engine/app/views/admin/users/new.html.slim +5 -0
  41. data/pg_engine/app/views/admin/users/show.html.slim +27 -0
  42. data/pg_engine/config/initializers/active_admin.rb +355 -0
  43. data/pg_engine/config/initializers/devise.rb +313 -0
  44. data/pg_engine/config/locales/devise.en.yml +65 -0
  45. data/pg_engine/config/routes.rb +11 -0
  46. data/pg_engine/db/migrate/20240205194218_devise_create_users.rb +47 -0
  47. data/pg_engine/db/migrate/20240208234111_unaccent.rb +5 -0
  48. data/pg_engine/db/migrate/20240208234901_install_audited.rb +32 -0
  49. data/pg_engine/db/migrate/20240210025702_create_active_admin_comments.rb +16 -0
  50. data/pg_engine/db/migrate/20240211152951_create_accounts.rb +24 -0
  51. data/pg_engine/db/migrate/20240211153049_create_user_accounts.rb +20 -0
  52. data/pg_engine/db/seeds.rb +5 -0
  53. data/pg_engine/lib/pg_engine/engine.rb +16 -2
  54. data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +206 -0
  55. data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +189 -0
  56. data/pg_engine/spec/controllers/admin/users_controller_spec.rb +180 -0
  57. data/pg_engine/spec/factories/accounts.rb +11 -0
  58. data/pg_engine/spec/factories/user_accounts.rb +21 -0
  59. data/pg_engine/spec/factories/users.rb +59 -0
  60. data/pg_engine/spec/models/account_spec.rb +13 -0
  61. data/pg_engine/spec/models/user_account_spec.rb +13 -0
  62. data/pg_engine/spec/models/user_spec.rb +13 -0
  63. data/pg_layout/lib/pg_layout/engine.rb +0 -1
  64. data/pg_rails/lib/version.rb +1 -1
  65. data/pg_scaffold/lib/generators/pg_pundit/templates/policy.rb +1 -1
  66. data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +4 -4
  67. data/pg_scaffold/spec/generators_spec.rb +1 -1
  68. metadata +56 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c4644fc0bcd9abce95b7cd8ac88f7779b7d8e6096590863d11fd1bbad1f1b7b
4
- data.tar.gz: df1ffd480c688adc40f24613b9d00eb57fe45940067191a942bd18e9d53e1209
3
+ metadata.gz: c615490752a2afcaa4959f18c3b58bc214849a0912c308aea4b75a48122aa859
4
+ data.tar.gz: d4e8cc1fc2418a2691ef25607776de7ab1b6936367379cb4571c12925836933c
5
5
  SHA512:
6
- metadata.gz: c9afa947ca3962f7e81973a798664900bccdc15ab6dd500c5b8573f5177212585cf35e78194c1219b6137f6dd3198d4e23ffd982702fdc2cac3cbf8ae1f2c8df
7
- data.tar.gz: 4f26bb070447c9c07829628a2d99a7a8a0ec9a7ac8298ab2f4118444316cffa775ff3254577488d2c139d637468c995bc97c5b9d4adf561f17529cfe398d89c5
6
+ metadata.gz: 3c7cad41dc0953598c49c7a48ca188e24a62d8dea1d1aed95f530e5eb92faa18bbf1033aac19c8adf963f759e7d0de52e905b4001354afb282373a257f8042be
7
+ data.tar.gz: 8ecd2f4a9617b57b3938f307502883681d70dab249a6f0fbb0789855b411465dac411ffe7dc3056ee0b49a40f84db8a77ce71739bd7dbc9ad81691b42c4de591
data/README.md CHANGED
@@ -73,3 +73,16 @@ Acceder a la app en <http://localhost:3000/>.
73
73
  4. `bundle exec rails g pg_scaffold Admin/CategoriaDeCosa nombre:string{required} "tipo:integer{enum,required}" fecha:date tiempo:datetime --model-name=CategoriaDeCosa --discard --activeadmin`
74
74
  5. `bundle exec rails g pg_scaffold Admin/Cosa nombre:string{required} "tipo:integer{enum,required}" categoria_de_cosa:references{required} --model-name=Cosa --discard --activeadmin`
75
75
  6. Setup asociacion creable en cosas/_form
76
+
77
+
78
+
79
+ be rake app:pg_engine_engine:install:migrations
80
+
81
+ be rails pg_engine_engine:install:migrations
82
+
83
+
84
+ "build": "esbuild pg_rails/js/index.js --bundle --sourcemap --format=esm --outdir=pg_rails/builds --public-path=/assets",
85
+ "build:css:compile": "sass ./pg_rails/scss/pg_rails.scss:./pg_rails/builds/application.css --no-source-map --load-path=node_modules",
86
+ "build:css:prefix": "postcss ./pg_rails/builds/application.css --use=autoprefixer --output=./pg_rails/builds/application.css",
87
+ "build:css": "yarn build:css:compile && yarn build:css:prefix",
88
+
@@ -1,9 +1,5 @@
1
- require "#{__dir__}/../../app/helpers/pg_associable/helpers"
2
- require "#{__dir__}/../../app/helpers/pg_associable/form_builder_methods"
3
-
4
1
  module PgAssociable
5
2
  class Engine < ::Rails::Engine
6
- isolate_namespace PgAssociable
7
3
  # initializer 'configurar_simple_form', after: 'factory_bot.set_fixture_replacement' do
8
4
  initializer 'configurar_pg_scaffold' do
9
5
  require 'pg_associable/simple_form_initializer'
@@ -2,10 +2,11 @@ require 'rails_helper'
2
2
 
3
3
  describe PgAssociable::Helpers do
4
4
  describe '#pg_respond_buscar' do
5
- let(:user) { create :user }
5
+ let(:user) { create :user, :developer }
6
6
  let(:ctrl) do
7
- clazz = Class.new(PgEngine::BaseController)
8
- clazz.new
7
+ # clazz = Class.new(Admin::CosasController)
8
+ # clazz.new
9
+ Admin::CosasController.new
9
10
  end
10
11
  let!(:cosa) { create :cosa }
11
12
 
@@ -0,0 +1,25 @@
1
+ ActiveAdmin.register Account do
2
+ permit_params :plan, :nombre, :hashid
3
+
4
+ index do
5
+ selectable_column
6
+ id_column
7
+ column :plan
8
+ column :nombre
9
+ column :hashid
10
+ actions
11
+ end
12
+
13
+ filter :plan
14
+ filter :nombre
15
+ filter :hashid
16
+
17
+ form do |f|
18
+ f.inputs do
19
+ f.input :plan
20
+ f.input :nombre
21
+ f.input :hashid
22
+ end
23
+ f.actions
24
+ end
25
+ end
@@ -1,7 +1,7 @@
1
1
  ActiveAdmin.register Audited::Audit do
2
- permit_params [:auditable_id, :auditable_type, :associated_id, :associated_type, :user_id,
3
- :user_type, :username, :action, :audited_changes, :version, :comment,
4
- :remote_address, :request_uuid, :created_at]
2
+ permit_params %i[auditable_id auditable_type associated_id associated_type user_id
3
+ user_type username action audited_changes version comment
4
+ remote_address request_uuid created_at]
5
5
 
6
6
  # :id
7
7
  # :discarded_at, :fecha, :nombre, :tiempo, :tipo, :created_at, :updated_at, :actualizado_por_id, :creado_por_id
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveAdmin.register_page 'Dashboard' do
4
+ menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
5
+
6
+ content title: proc { I18n.t('active_admin.dashboard') } do
7
+ div class: 'blank_slate_container', id: 'dashboard_default_message' do
8
+ span class: 'blank_slate' do
9
+ span I18n.t('active_admin.dashboard_welcome.welcome')
10
+ small I18n.t('active_admin.dashboard_welcome.call_to_action')
11
+ end
12
+ end
13
+
14
+ # Here is an example of a simple dashboard with columns and panels.
15
+ #
16
+ # columns do
17
+ # column do
18
+ # panel "Recent Posts" do
19
+ # ul do
20
+ # Post.recent(5).map do |post|
21
+ # li link_to(post.title, admin_post_path(post))
22
+ # end
23
+ # end
24
+ # end
25
+ # end
26
+
27
+ # column do
28
+ # panel "Info" do
29
+ # para "Welcome to ActiveAdmin."
30
+ # end
31
+ # end
32
+ # end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ ActiveAdmin.register UserAccount do
2
+ decorate_with UserAccountDecorator
3
+ permit_params :user_id, :account_id, profiles: []
4
+
5
+ index do
6
+ selectable_column
7
+ id_column
8
+ column :user
9
+ column :account
10
+ column :profiles
11
+ actions
12
+ end
13
+
14
+ filter :user
15
+ filter :account
16
+ filter :profiles
17
+
18
+ form do |f|
19
+ f.inputs do
20
+ f.input :user
21
+ f.input :account
22
+ f.input :profiles, as: :select
23
+ end
24
+ f.actions
25
+ end
26
+ end
@@ -1,6 +1,6 @@
1
1
  ActiveAdmin.register User do
2
2
  decorate_with UserDecorator
3
- permit_params :email, :password, :password_confirmation, :confirmed_at, profiles: []
3
+ permit_params :email, :password, :password_confirmation, :confirmed_at
4
4
 
5
5
  index do
6
6
  selectable_column
@@ -19,7 +19,6 @@ ActiveAdmin.register User do
19
19
  else
20
20
  f.input :email
21
21
  f.input :password unless f.object.persisted?
22
- f.input :profiles, as: :select
23
22
  end
24
23
  end
25
24
  f.actions
@@ -0,0 +1 @@
1
+ //= require active_admin/base
@@ -0,0 +1,17 @@
1
+ // Sass variable overrides must be declared before loading up Active Admin's styles.
2
+ //
3
+ // To view the variables that Active Admin provides, take a look at
4
+ // `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
5
+ // Active Admin source.
6
+ //
7
+ // For example, to change the sidebar width:
8
+ // $sidebar-width: 242px;
9
+
10
+ // Active Admin's got SASS!
11
+ @import "active_admin/mixins";
12
+ @import "active_admin/base";
13
+
14
+ // Overriding any non-variable Sass must be done after the fact.
15
+ // For example, to change the default status-tag color:
16
+ //
17
+ // .status_tag { background: #6090DB; }
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Admin
6
+ class AccountsController < AdminController
7
+ before_action { @clase_modelo = Account }
8
+
9
+ before_action(only: :index) { authorize Account }
10
+
11
+ before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
12
+
13
+ add_breadcrumb Account.nombre_plural, :admin_accounts_path
14
+
15
+ private
16
+
17
+ def atributos_permitidos
18
+ %i[plan nombre hashid]
19
+ end
20
+
21
+ def atributos_para_buscar
22
+ %i[plan nombre hashid]
23
+ end
24
+
25
+ def atributos_para_listar
26
+ %i[plan nombre hashid]
27
+ end
28
+
29
+ def atributos_para_mostrar
30
+ %i[plan nombre hashid]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Admin
6
+ class UserAccountsController < AdminController
7
+ before_action { @clase_modelo = UserAccount }
8
+
9
+ before_action(only: :index) { authorize UserAccount }
10
+
11
+ before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
12
+
13
+ add_breadcrumb UserAccount.nombre_plural, :admin_user_accounts_path
14
+
15
+ private
16
+
17
+ def atributos_permitidos
18
+ %i[user_id account_id profiles]
19
+ end
20
+
21
+ def atributos_para_buscar
22
+ %i[user account profiles]
23
+ end
24
+
25
+ def atributos_para_listar
26
+ %i[user account profiles]
27
+ end
28
+
29
+ def atributos_para_mostrar
30
+ %i[user account profiles]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Admin
6
+ class UsersController < AdminController
7
+ before_action { @clase_modelo = User }
8
+
9
+ before_action(only: :index) { authorize User }
10
+
11
+ before_action only: %i[update] do
12
+ params[:user].delete(:password) if params[:user][:password].blank?
13
+ end
14
+
15
+ before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
16
+
17
+ add_breadcrumb User.nombre_plural, :admin_users_path
18
+
19
+ def create
20
+ @user.skip_confirmation!
21
+ pg_respond_create
22
+ end
23
+
24
+ def update
25
+ @user.skip_reconfirmation!
26
+ pg_respond_update
27
+ end
28
+
29
+ private
30
+
31
+ def atributos_permitidos
32
+ %i[email password developer]
33
+ end
34
+
35
+ def atributos_para_buscar
36
+ %i[email developer]
37
+ end
38
+
39
+ def atributos_para_listar
40
+ %i[email developer]
41
+ end
42
+
43
+ def atributos_para_mostrar
44
+ %i[email developer]
45
+ end
46
+ end
47
+ end
@@ -225,6 +225,7 @@ module PgEngine
225
225
  authorize instancia_modelo
226
226
 
227
227
  # TODO: problema en create y update cuando falla la validacion
228
+ # Reproducir el error antes de arreglarlo
228
229
  self.instancia_modelo = instancia_modelo.decorate if action_name.in? %w[show edit new]
229
230
  end
230
231
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class AccountDecorator < PgEngine::BaseDecorator
6
+ delegate_all
7
+
8
+ # Define presentation-specific methods here. Helpers are accessed through
9
+ # `helpers` (aka `h`). You can override attributes, for example:
10
+ #
11
+ # def created_at
12
+ # helpers.content_tag :span, class: 'time' do
13
+ # object.created_at.strftime("%a %m/%d/%y")
14
+ # end
15
+ # end
16
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class UserAccountDecorator < PgEngine::BaseDecorator
6
+ delegate_all
7
+
8
+ def profiles
9
+ object.profiles.join(', ')
10
+ end
11
+ # Define presentation-specific methods here. Helpers are accessed through
12
+ # `helpers` (aka `h`). You can override attributes, for example:
13
+ #
14
+ # def created_at
15
+ # helpers.content_tag :span, class: 'time' do
16
+ # object.created_at.strftime("%a %m/%d/%y")
17
+ # end
18
+ # end
19
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class UserDecorator < PgEngine::BaseDecorator
6
+ delegate_all
7
+
8
+ def default_module
9
+ :admin
10
+ end
11
+
12
+ # Define presentation-specific methods here. Helpers are accessed through
13
+ # `helpers` (aka `h`). You can override attributes, for example:
14
+ #
15
+ # def created_at
16
+ # helpers.content_tag :span, class: 'time' do
17
+ # object.created_at.strftime("%a %m/%d/%y")
18
+ # end
19
+ # end
20
+ end
@@ -1,7 +1,7 @@
1
1
  module PgEngine
2
2
  module FlashHelper
3
3
  def render_turbo_stream_flash_messages
4
- turbo_stream.prepend 'flash', partial: 'layouts/flash'
4
+ turbo_stream.prepend 'flash', partial: 'pg_layout/flash'
5
5
  end
6
6
 
7
7
  def render_turbo_stream_title
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # == Schema Information
4
+ #
5
+ # Table name: accounts
6
+ #
7
+ # id :bigint not null, primary key
8
+ # discarded_at :datetime
9
+ # hashid :string
10
+ # nombre :string not null
11
+ # plan :integer not null
12
+ # created_at :datetime not null
13
+ # updated_at :datetime not null
14
+ # actualizado_por_id :bigint
15
+ # creado_por_id :bigint
16
+ #
17
+ # Indexes
18
+ #
19
+ # index_accounts_on_actualizado_por_id (actualizado_por_id)
20
+ # index_accounts_on_creado_por_id (creado_por_id)
21
+ #
22
+ # Foreign Keys
23
+ #
24
+ # fk_rails_... (actualizado_por_id => users.id)
25
+ # fk_rails_... (creado_por_id => users.id)
26
+ #
27
+ # generado con pg_rails
28
+
29
+ class Account < ApplicationRecord
30
+ audited
31
+ include Discard::Model
32
+
33
+ belongs_to :creado_por, optional: true, class_name: 'User'
34
+ belongs_to :actualizado_por, optional: true, class_name: 'User'
35
+
36
+ enumerize :plan, in: { completar: 0, los: 1, valores: 2 }
37
+
38
+ validates :plan, :nombre, presence: true
39
+ end
@@ -0,0 +1,61 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: users
4
+ #
5
+ # id :bigint not null, primary key
6
+ # confirmation_sent_at :datetime
7
+ # confirmation_token :string
8
+ # confirmed_at :datetime
9
+ # current_sign_in_at :datetime
10
+ # current_sign_in_ip :string
11
+ # developer :boolean default(FALSE), not null
12
+ # discarded_at :datetime
13
+ # email :string default(""), not null
14
+ # encrypted_password :string default(""), not null
15
+ # failed_attempts :integer default(0), not null
16
+ # last_sign_in_at :datetime
17
+ # last_sign_in_ip :string
18
+ # locked_at :datetime
19
+ # remember_created_at :datetime
20
+ # reset_password_sent_at :datetime
21
+ # reset_password_token :string
22
+ # sign_in_count :integer default(0), not null
23
+ # unconfirmed_email :string
24
+ # unlock_token :string
25
+ # created_at :datetime not null
26
+ # updated_at :datetime not null
27
+ #
28
+ # Indexes
29
+ #
30
+ # index_users_on_confirmation_token (confirmation_token) UNIQUE
31
+ # index_users_on_email (email) UNIQUE
32
+ # index_users_on_reset_password_token (reset_password_token) UNIQUE
33
+ # index_users_on_unlock_token (unlock_token) UNIQUE
34
+ #
35
+ class User < ApplicationRecord
36
+ # ApplicationRecord should be defined on Application
37
+
38
+ # Include default devise modules. Others available are:
39
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
40
+ devise :database_authenticatable, :registerable,
41
+ :recoverable, :rememberable, :validatable,
42
+ :confirmable, :lockable, :timeoutable, :trackable
43
+
44
+ audited
45
+ include Discard::Model
46
+
47
+ has_many :user_accounts
48
+ has_many :accounts, through: :user_accounts
49
+
50
+ validates :email, presence: true
51
+
52
+ scope :query, ->(param) { where('email ILIKE ?', "%#{param}%") }
53
+
54
+ def to_s
55
+ email
56
+ end
57
+
58
+ def current_account
59
+ accounts.first
60
+ end
61
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # == Schema Information
4
+ #
5
+ # Table name: user_accounts
6
+ #
7
+ # id :bigint not null, primary key
8
+ # profiles :integer default([]), not null, is an Array
9
+ # created_at :datetime not null
10
+ # updated_at :datetime not null
11
+ # account_id :bigint not null
12
+ # actualizado_por_id :bigint
13
+ # creado_por_id :bigint
14
+ # user_id :bigint not null
15
+ #
16
+ # Indexes
17
+ #
18
+ # index_user_accounts_on_account_id (account_id)
19
+ # index_user_accounts_on_actualizado_por_id (actualizado_por_id)
20
+ # index_user_accounts_on_creado_por_id (creado_por_id)
21
+ # index_user_accounts_on_user_id (user_id)
22
+ #
23
+ # Foreign Keys
24
+ #
25
+ # fk_rails_... (account_id => accounts.id)
26
+ # fk_rails_... (actualizado_por_id => users.id)
27
+ # fk_rails_... (creado_por_id => users.id)
28
+ # fk_rails_... (user_id => users.id)
29
+ #
30
+ # generado con pg_rails
31
+
32
+ class UserAccount < ApplicationRecord
33
+ audited
34
+
35
+ belongs_to :user
36
+ belongs_to :account
37
+
38
+ belongs_to :creado_por, optional: true, class_name: 'User'
39
+ belongs_to :actualizado_por, optional: true, class_name: 'User'
40
+
41
+ enumerize :profiles, in: {
42
+ admin: 1,
43
+ dueño: 2,
44
+ invitado: 3
45
+ }, multiple: true
46
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class AccountPolicy < ApplicationPolicy
6
+ class Scope < ApplicationPolicy::Scope
7
+ # def resolve
8
+ # if policy.acceso_total?
9
+ # scope.all
10
+ # else
11
+ # scope.none
12
+ # end
13
+ # end
14
+ end
15
+
16
+ # def puede_editar?
17
+ # acceso_total? && !record.readonly?
18
+ # end
19
+
20
+ # def puede_crear?
21
+ # acceso_total? || user.asesor?
22
+ # end
23
+
24
+ # def puede_borrar?
25
+ # acceso_total? && !record.readonly?
26
+ # end
27
+
28
+ # def acceso_total?
29
+ # user.developer?
30
+ # end
31
+ end
@@ -88,7 +88,7 @@ module PgEngine
88
88
  end
89
89
 
90
90
  def acceso_total?
91
- user&.admin?
91
+ user&.developer?
92
92
  end
93
93
 
94
94
  def objeto_borrado?
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class UserAccountPolicy < ApplicationPolicy
6
+ class Scope < ApplicationPolicy::Scope
7
+ # def resolve
8
+ # if policy.acceso_total?
9
+ # scope.all
10
+ # else
11
+ # scope.none
12
+ # end
13
+ # end
14
+ end
15
+
16
+ # def puede_editar?
17
+ # acceso_total? && !record.readonly?
18
+ # end
19
+
20
+ # def puede_crear?
21
+ # acceso_total? || user.asesor?
22
+ # end
23
+
24
+ # def puede_borrar?
25
+ # acceso_total? && !record.readonly?
26
+ # end
27
+
28
+ # def acceso_total?
29
+ # user.developer?
30
+ # end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class UserPolicy < ApplicationPolicy
6
+ class Scope < ApplicationPolicy::Scope
7
+ # def resolve
8
+ # if policy.acceso_total?
9
+ # scope.all
10
+ # else
11
+ # scope.none
12
+ # end
13
+ # end
14
+ end
15
+
16
+ # def puede_editar?
17
+ # acceso_total? && !record.readonly?
18
+ # end
19
+
20
+ # def puede_crear?
21
+ # acceso_total? || user.asesor?
22
+ # end
23
+
24
+ # def puede_borrar?
25
+ # acceso_total? && !record.readonly?
26
+ # end
27
+
28
+ # def acceso_total?
29
+ # user.developer?
30
+ # end
31
+ end
@@ -0,0 +1 @@
1
+ h1 el partiaaal
@@ -0,0 +1,12 @@
1
+ / # locals: (object: nil, asociable: false)
2
+
3
+ div style="max-width: 300px"
4
+ = pg_form_for(@account || object) do |f|
5
+ = f.mensajes_de_error
6
+
7
+ = hidden_field_tag :asociable, true if asociable
8
+ = f.input :plan
9
+ = f.input :nombre
10
+ = f.input :hashid
11
+ .mt-2
12
+ = f.button :submit
@@ -0,0 +1,5 @@
1
+ - content_for :title do
2
+ | Modificar #{@clase_modelo.nombre_singular.downcase}
3
+
4
+ .p-3
5
+ = render 'form'
@@ -0,0 +1,5 @@
1
+ - content_for :title do
2
+ | Crear #{@clase_modelo.nombre_singular.downcase}
3
+
4
+ .p-3
5
+ = render 'form'