pg_rails 7.0.8.pre.alpha.9 → 7.0.8.pre.alpha.11
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 +4 -4
 - data/pg_associable/app/javascript/modal_controller.js +1 -1
 - data/pg_engine/app/controllers/admin/users_controller.rb +16 -4
 - data/pg_engine/app/controllers/pg_engine/base_controller.rb +2 -2
 - data/pg_engine/app/controllers/pg_engine/devise_controller.rb +16 -3
 - data/pg_engine/app/helpers/pg_engine/print_helper.rb +2 -2
 - data/pg_engine/app/lib/pg_form_builder.rb +21 -0
 - data/pg_engine/app/models/pg_engine/base_record.rb +4 -1
 - data/pg_engine/app/models/user.rb +20 -5
 - data/pg_engine/app/views/pg_engine/base/edit.html.slim +5 -0
 - data/pg_engine/app/views/pg_engine/base/index.html.slim +1 -1
 - data/pg_engine/app/views/pg_engine/base/new.html.slim +5 -0
 - data/pg_engine/config/initializers/simple_form_monkey_patch.rb +12 -0
 - data/pg_engine/config/locales/es.yml +4 -0
 - data/pg_engine/config/routes.rb +1 -0
 - data/pg_engine/config/simple_form/simple_form_bootstrap.rb +2 -4
 - data/pg_engine/db/migrate/20240305200900_nombre_user.rb +6 -0
 - data/pg_engine/db/seeds.rb +1 -1
 - data/pg_engine/lib/tasks/auto_anotar_modelos.rake +2 -1
 - data/pg_engine/spec/controllers/devise/registrations_controller_spec.rb +33 -0
 - data/pg_engine/spec/controllers/devise/sessions_controller_spec.rb +18 -0
 - data/pg_engine/spec/factories/users.rb +2 -0
 - data/pg_engine/spec/lib/pg_form_builder_spec.rb +14 -0
 - data/pg_engine/spec/models/pg_engine/base_record_spec.rb +5 -3
 - data/pg_layout/app/lib/navbar.rb +13 -3
 - data/pg_layout/app/views/devise/registrations/edit.html.erb +2 -0
 - data/pg_layout/app/views/devise/registrations/new.html.erb +3 -2
 - data/pg_layout/app/views/devise/sessions/new.html.erb +11 -0
 - data/pg_layout/app/views/pg_layout/_flash.html.slim +2 -1
 - data/pg_layout/app/views/pg_layout/_navbar.html.erb +13 -2
 - data/pg_rails/lib/version.rb +1 -1
 - data/pg_scaffold/lib/generators/pg_slim/pg_slim_generator.rb +2 -2
 - metadata +8 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fd8e2d2862617656464a77ffbb81da7f6a4446d013905748392a062e8f3dab7c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: '082f99be749adde90a68693ebfe00ee234c6a83429c18c0f02b9aff6b831ae53'
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d34c9e84d88801ea1b973b275ab94923fb0941bdf9e204fa2a3d76321f9bec079427e3df7d9fae905ef31e3144cda6d92c061ca510f108c66084ec68258de446
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 18fed1f31567205e9ad8bff9e455f9c5e48bf0be4966e2ba9c08fca716995720934e0b8f0011ab1a2bcf7cd39edbd92fb708b296d926849cae2c815c5a1a4352
         
     | 
| 
         @@ -26,22 +26,34 @@ module Admin 
     | 
|
| 
       26 
26 
     | 
    
         
             
                  pg_respond_update
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
                skip_before_action :authenticate_user!, only: [:login_as]
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                # :nocov:
         
     | 
| 
      
 32 
     | 
    
         
            +
                def login_as
         
     | 
| 
      
 33 
     | 
    
         
            +
                  if current_user&.developer? || Rails.env.development?
         
     | 
| 
      
 34 
     | 
    
         
            +
                    usuario = User.find(params[:id])
         
     | 
| 
      
 35 
     | 
    
         
            +
                    sign_in(:user, usuario)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  redirect_to '/'
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
                # :nocov:
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       29 
41 
     | 
    
         
             
                private
         
     | 
| 
       30 
42 
     | 
    
         | 
| 
       31 
43 
     | 
    
         
             
                def atributos_permitidos
         
     | 
| 
       32 
     | 
    
         
            -
                  %i[email password developer]
         
     | 
| 
      
 44 
     | 
    
         
            +
                  %i[email nombre apellido password developer]
         
     | 
| 
       33 
45 
     | 
    
         
             
                end
         
     | 
| 
       34 
46 
     | 
    
         | 
| 
       35 
47 
     | 
    
         
             
                def atributos_para_buscar
         
     | 
| 
       36 
     | 
    
         
            -
                  %i[email developer]
         
     | 
| 
      
 48 
     | 
    
         
            +
                  %i[email nombre apellido developer]
         
     | 
| 
       37 
49 
     | 
    
         
             
                end
         
     | 
| 
       38 
50 
     | 
    
         | 
| 
       39 
51 
     | 
    
         
             
                def atributos_para_listar
         
     | 
| 
       40 
     | 
    
         
            -
                  %i[email developer]
         
     | 
| 
      
 52 
     | 
    
         
            +
                  %i[email nombre apellido developer]
         
     | 
| 
       41 
53 
     | 
    
         
             
                end
         
     | 
| 
       42 
54 
     | 
    
         | 
| 
       43 
55 
     | 
    
         
             
                def atributos_para_mostrar
         
     | 
| 
       44 
     | 
    
         
            -
                  %i[email developer]
         
     | 
| 
      
 56 
     | 
    
         
            +
                  %i[email nombre apellido developer]
         
     | 
| 
       45 
57 
     | 
    
         
             
                end
         
     | 
| 
       46 
58 
     | 
    
         
             
              end
         
     | 
| 
       47 
59 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,9 +1,22 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module PgEngine
         
     | 
| 
       2 
2 
     | 
    
         
             
              class DeviseController < ApplicationController
         
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 3 
     | 
    
         
            +
                before_action :configure_permitted_parameters
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                layout :layout_by_resource
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def layout_by_resource
         
     | 
| 
      
 8 
     | 
    
         
            +
                  if controller_name == 'registrations' && action_name.in?(%w[edit update])
         
     | 
| 
      
 9 
     | 
    
         
            +
                    'pg_layout/layout'
         
     | 
| 
      
 10 
     | 
    
         
            +
                  else
         
     | 
| 
      
 11 
     | 
    
         
            +
                    'pg_layout/devise'
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                protected
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def configure_permitted_parameters
         
     | 
| 
      
 18 
     | 
    
         
            +
                  devise_parameter_sanitizer.permit(:sign_up, keys: %i[nombre apellido])
         
     | 
| 
      
 19 
     | 
    
         
            +
                  devise_parameter_sanitizer.permit(:account_update, keys: %i[nombre apellido])
         
     | 
| 
       7 
20 
     | 
    
         
             
                end
         
     | 
| 
       8 
21 
     | 
    
         
             
              end
         
     | 
| 
       9 
22 
     | 
    
         
             
            end
         
     | 
| 
         @@ -98,10 +98,10 @@ module PgEngine 
     | 
|
| 
       98 
98 
     | 
    
         
             
                  'No'
         
     | 
| 
       99 
99 
     | 
    
         
             
                end
         
     | 
| 
       100 
100 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
                def print_currency(number, simbolo: '$')
         
     | 
| 
      
 101 
     | 
    
         
            +
                def print_currency(number, simbolo: '$', precision: nil)
         
     | 
| 
       102 
102 
     | 
    
         
             
                  return if number.blank?
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                  precision  
     | 
| 
      
 104 
     | 
    
         
            +
                  precision ||= (number % 1).positive? ? 2 : 0
         
     | 
| 
       105 
105 
     | 
    
         
             
                  "#{simbolo} #{number_with_precision(number, delimiter: '.', separator: ',',
         
     | 
| 
       106 
106 
     | 
    
         
             
                                                              precision:)}"
         
     | 
| 
       107 
107 
     | 
    
         
             
                end
         
     | 
| 
         @@ -4,6 +4,27 @@ class PgFormBuilder < SimpleForm::FormBuilder 
     | 
|
| 
       4 
4 
     | 
    
         
             
              include PgAssociable::FormBuilderMethods
         
     | 
| 
       5 
5 
     | 
    
         
             
              include PgEngine::ErrorHelper
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
              def default_prefix(attribute_name)
         
     | 
| 
      
 8 
     | 
    
         
            +
                at_name = object.class.human_attribute_name(attribute_name.to_s).downcase
         
     | 
| 
      
 9 
     | 
    
         
            +
                "#{articulo(attribute_name)} #{at_name}"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def articulo(attribute_name)
         
     | 
| 
      
 13 
     | 
    
         
            +
                gender = I18n.t("gender.#{attribute_name}", default: nil)
         
     | 
| 
      
 14 
     | 
    
         
            +
                if gender.present?
         
     | 
| 
      
 15 
     | 
    
         
            +
                  gender == 'f' ? 'La' : 'El'
         
     | 
| 
      
 16 
     | 
    
         
            +
                else
         
     | 
| 
      
 17 
     | 
    
         
            +
                  at_name = object.class.human_attribute_name(attribute_name.to_s).downcase
         
     | 
| 
      
 18 
     | 
    
         
            +
                  at_name.ends_with?('a') ? 'La' : 'El'
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              def input(attribute_name, options = {}, &)
         
     | 
| 
      
 23 
     | 
    
         
            +
                options[:error_prefix] ||= default_prefix(attribute_name)
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                super(attribute_name, options, &)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       7 
28 
     | 
    
         
             
              def mensajes_de_error
         
     | 
| 
       8 
29 
     | 
    
         
             
                base_errors = object.errors[:base]
         
     | 
| 
       9 
30 
     | 
    
         
             
                base_message = (base_errors.map(&:to_s).join('<br>') if base_errors.present?)
         
     | 
| 
         @@ -34,9 +34,12 @@ module PgEngine 
     | 
|
| 
       34 
34 
     | 
    
         
             
                end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                def self.human_attribute_name(attribute, options = {})
         
     | 
| 
       37 
     | 
    
         
            -
                  # Si es un enumerized
         
     | 
| 
       38 
37 
     | 
    
         
             
                  if attribute.to_s.ends_with?('_text')
         
     | 
| 
      
 38 
     | 
    
         
            +
                    # Si es un enumerized
         
     | 
| 
       39 
39 
     | 
    
         
             
                    super(attribute[0..-6], options)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  elsif attribute.to_s.ends_with?('_f')
         
     | 
| 
      
 41 
     | 
    
         
            +
                    # Si es un decorated method
         
     | 
| 
      
 42 
     | 
    
         
            +
                    super(attribute[0..-3], options)
         
     | 
| 
       40 
43 
     | 
    
         
             
                  else
         
     | 
| 
       41 
44 
     | 
    
         
             
                    super(attribute, options)
         
     | 
| 
       42 
45 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -36,10 +36,9 @@ class User < ApplicationRecord 
     | 
|
| 
       36 
36 
     | 
    
         
             
              # ApplicationRecord should be defined on Application
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
              # Include default devise modules. Others available are:
         
     | 
| 
       39 
     | 
    
         
            -
              # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
         
     | 
| 
       40 
39 
     | 
    
         
             
              devise :database_authenticatable, :registerable,
         
     | 
| 
       41 
     | 
    
         
            -
                     :recoverable, :rememberable, 
     | 
| 
       42 
     | 
    
         
            -
                     : 
     | 
| 
      
 40 
     | 
    
         
            +
                     :recoverable, :rememberable,
         
     | 
| 
      
 41 
     | 
    
         
            +
                     :lockable, :timeoutable, :trackable, :confirmable
         
     | 
| 
       43 
42 
     | 
    
         | 
| 
       44 
43 
     | 
    
         
             
              audited
         
     | 
| 
       45 
44 
     | 
    
         
             
              include Discard::Model
         
     | 
| 
         @@ -47,12 +46,28 @@ class User < ApplicationRecord 
     | 
|
| 
       47 
46 
     | 
    
         
             
              has_many :user_accounts
         
     | 
| 
       48 
47 
     | 
    
         
             
              has_many :accounts, through: :user_accounts
         
     | 
| 
       49 
48 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
              validates : 
     | 
| 
      
 49 
     | 
    
         
            +
              validates :nombre, :apellido, presence: true
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              validates_presence_of   :email
         
     | 
| 
      
 52 
     | 
    
         
            +
              validates_uniqueness_of :email, message: 'ya pertenece a un usuario'
         
     | 
| 
      
 53 
     | 
    
         
            +
              validates_format_of     :email, with: /\A[^@\s]+@[^@\s]+\z/
         
     | 
| 
      
 54 
     | 
    
         
            +
              validates_presence_of     :password, if: :password_required?
         
     | 
| 
      
 55 
     | 
    
         
            +
              validates_confirmation_of :password, if: :password_required?, message: 'Las contraseñas no coinciden'
         
     | 
| 
      
 56 
     | 
    
         
            +
              validates_length_of       :password, if: :password_required?, within: 6..128,
         
     | 
| 
      
 57 
     | 
    
         
            +
                                                   message: 'es demasiado corta (6 caracteres mínimo)'
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              def password_required?
         
     | 
| 
      
 60 
     | 
    
         
            +
                !persisted? || !password.nil? || !password_confirmation.nil?
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
       51 
62 
     | 
    
         | 
| 
       52 
63 
     | 
    
         
             
              scope :query, ->(param) { where('email ILIKE ?', "%#{param}%") }
         
     | 
| 
       53 
64 
     | 
    
         | 
| 
       54 
65 
     | 
    
         
             
              def to_s
         
     | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
      
 66 
     | 
    
         
            +
                nombre_completo
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              def nombre_completo
         
     | 
| 
      
 70 
     | 
    
         
            +
                "#{nombre} #{apellido}"
         
     | 
| 
       56 
71 
     | 
    
         
             
              end
         
     | 
| 
       57 
72 
     | 
    
         | 
| 
       58 
73 
     | 
    
         
             
              def current_account
         
     | 
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SimpleForm
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Components
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Errors
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def error_text
         
     | 
| 
      
 5 
     | 
    
         
            +
                    text = has_custom_error? ? options[:error] : errors.reject(&:empty?).send(error_method)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    return if text.blank?
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    "#{html_escape(options[:error_prefix])} #{html_escape(text)}".lstrip.html_safe
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
    
        data/pg_engine/config/routes.rb
    CHANGED
    
    
| 
         @@ -56,8 +56,7 @@ SimpleForm.setup do |config| 
     | 
|
| 
       56 
56 
     | 
    
         
             
                b.optional :readonly
         
     | 
| 
       57 
57 
     | 
    
         
             
                b.use :label, class: 'form-label'
         
     | 
| 
       58 
58 
     | 
    
         
             
                b.use :input, class: 'form-control', error_class: 'is-invalid'
         
     | 
| 
       59 
     | 
    
         
            -
                b.use : 
     | 
| 
       60 
     | 
    
         
            -
                b.optional :error, wrap_with: { class: 'invalid-feedback' }
         
     | 
| 
      
 59 
     | 
    
         
            +
                b.use :error, wrap_with: { class: 'invalid-feedback' }
         
     | 
| 
       61 
60 
     | 
    
         
             
                b.use :hint, wrap_with: { class: 'form-text' }
         
     | 
| 
       62 
61 
     | 
    
         
             
              end
         
     | 
| 
       63 
62 
     | 
    
         | 
| 
         @@ -66,8 +65,7 @@ SimpleForm.setup do |config| 
     | 
|
| 
       66 
65 
     | 
    
         
             
                b.optional :readonly
         
     | 
| 
       67 
66 
     | 
    
         
             
                b.use :label, class: 'form-label'
         
     | 
| 
       68 
67 
     | 
    
         
             
                b.use :input, class: 'form-select', error_class: 'is-invalid'
         
     | 
| 
       69 
     | 
    
         
            -
                b.use : 
     | 
| 
       70 
     | 
    
         
            -
                b.optional :error, wrap_with: { class: 'invalid-feedback' }
         
     | 
| 
      
 68 
     | 
    
         
            +
                b.use :error, wrap_with: { class: 'invalid-feedback' }
         
     | 
| 
       71 
69 
     | 
    
         
             
                b.use :hint, wrap_with: { class: 'form-text' }
         
     | 
| 
       72 
70 
     | 
    
         
             
              end
         
     | 
| 
       73 
71 
     | 
    
         | 
    
        data/pg_engine/db/seeds.rb
    CHANGED
    
    | 
         @@ -3,6 +3,6 @@ DatabaseCleaner.clean_with(:truncation, except: %w(ar_internal_metadata users ac 
     | 
|
| 
       3 
3 
     | 
    
         
             
            MAIL = 'mrosso10@gmail.com'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            unless User.where(email: MAIL).exists?
         
     | 
| 
       6 
     | 
    
         
            -
              FactoryBot.create :user, email: MAIL, password: 'admin123',
         
     | 
| 
      
 6 
     | 
    
         
            +
              FactoryBot.create :user, email: MAIL, nombre: 'Martín', apellido: 'Rosso', password: 'admin123',
         
     | 
| 
       7 
7 
     | 
    
         
             
                                       confirmed_at: Time.now, developer: true
         
     | 
| 
       8 
8 
     | 
    
         
             
            end
         
     | 
| 
         @@ -21,7 +21,8 @@ if Rails.env.development? 
     | 
|
| 
       21 
21 
     | 
    
         
             
                  'show_complete_foreign_keys'  => 'false',
         
     | 
| 
       22 
22 
     | 
    
         
             
                  'show_indexes'                => 'false',
         
     | 
| 
       23 
23 
     | 
    
         
             
                  'simple_indexes'              => 'true',
         
     | 
| 
       24 
     | 
    
         
            -
                  'model_dir'                   => 'app/models',
         
     | 
| 
      
 24 
     | 
    
         
            +
                  'model_dir'                   => ['app/models', 'app/overrides'],
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # 'model_dir'                   => 'app/models',
         
     | 
| 
       25 
26 
     | 
    
         
             
                  'root_dir'                    => '',
         
     | 
| 
       26 
27 
     | 
    
         
             
                  'include_version'             => 'false',
         
     | 
| 
       27 
28 
     | 
    
         
             
                  'require'                     => '',
         
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rails_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Devise::RegistrationsController do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                # rubocop:disable RSpec/InstanceVariable
         
     | 
| 
      
 6 
     | 
    
         
            +
                @request.env['devise.mapping'] = Devise.mappings[:user]
         
     | 
| 
      
 7 
     | 
    
         
            +
                # rubocop:enable RSpec/InstanceVariable
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              describe '#new' do
         
     | 
| 
      
 11 
     | 
    
         
            +
                subject { get :new }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                it do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  subject
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(response).to have_http_status(:ok)
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              describe '#edit' do
         
     | 
| 
      
 20 
     | 
    
         
            +
                subject { get :edit }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                let(:logger_user) { create :user, :admin }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                before do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  sign_in logger_user
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  subject
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(response).to have_http_status(:ok)
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rails_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Devise::SessionsController do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                # rubocop:disable RSpec/InstanceVariable
         
     | 
| 
      
 6 
     | 
    
         
            +
                @request.env['devise.mapping'] = Devise.mappings[:user]
         
     | 
| 
      
 7 
     | 
    
         
            +
                # rubocop:enable RSpec/InstanceVariable
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              describe '#new' do
         
     | 
| 
      
 11 
     | 
    
         
            +
                subject { get :new }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                it do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  subject
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(response).to have_http_status(:ok)
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -29,4 +29,18 @@ describe PgFormBuilder do 
     | 
|
| 
       29 
29 
     | 
    
         
             
                  it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
       31 
31 
     | 
    
         
             
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              describe '#default_prefix' do
         
     | 
| 
      
 34 
     | 
    
         
            +
                context 'cuando el atributo es masculino' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  subject { instancia.default_prefix(:nombre) }
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  it { expect(subject).to eq 'El nombre' }
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                context 'cuando el atributo es femenino' do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  subject { instancia.default_prefix(:fecha) }
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  it { expect(subject).to eq 'La fecha' }
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
       32 
46 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,12 +2,14 @@ require 'rails_helper' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe PgEngine::BaseRecord do
         
     | 
| 
       4 
4 
     | 
    
         
             
              describe '#human_attribute_name' do
         
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
                  described_class.human_attribute_name('bla_text')
         
     | 
| 
      
 5 
     | 
    
         
            +
                it do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  obj = described_class.human_attribute_name('bla_text')
         
     | 
| 
      
 7 
     | 
    
         
            +
                  expect(obj).to eq described_class.human_attribute_name('bla')
         
     | 
| 
       7 
8 
     | 
    
         
             
                end
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
                it do
         
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
      
 11 
     | 
    
         
            +
                  obj = described_class.human_attribute_name('bla_f')
         
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(obj).to eq described_class.human_attribute_name('bla')
         
     | 
| 
       11 
13 
     | 
    
         
             
                end
         
     | 
| 
       12 
14 
     | 
    
         
             
              end
         
     | 
| 
       13 
15 
     | 
    
         
             
            end
         
     | 
    
        data/pg_layout/app/lib/navbar.rb
    CHANGED
    
    | 
         @@ -5,15 +5,25 @@ class Navbar 
     | 
|
| 
       5 
5 
     | 
    
         
             
                @user = user
         
     | 
| 
       6 
6 
     | 
    
         
             
              end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
              def topbar
         
     | 
| 
      
 9 
     | 
    
         
            +
                bar('topbar')
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       8 
12 
     | 
    
         
             
              def sidebar
         
     | 
| 
      
 13 
     | 
    
         
            +
                bar('sidebar')
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def bar(key)
         
     | 
| 
       9 
17 
     | 
    
         
             
                yaml_data = YAML.load_file("#{Rails.application.root}/config/pg_rails.yml")
         
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
      
 18 
     | 
    
         
            +
                bar_data = ActiveSupport::HashWithIndifferentAccess.new(yaml_data)[key]
         
     | 
| 
      
 19 
     | 
    
         
            +
                return [] if bar_data.blank?
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       11 
21 
     | 
    
         
             
                # rubocop:disable Security/Eval
         
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
      
 22 
     | 
    
         
            +
                bar_data.map do |item|
         
     | 
| 
       13 
23 
     | 
    
         
             
                  {
         
     | 
| 
       14 
24 
     | 
    
         
             
                    title: item['name'],
         
     | 
| 
       15 
25 
     | 
    
         
             
                    path: eval(item['path']),
         
     | 
| 
       16 
     | 
    
         
            -
                    show: true
         
     | 
| 
      
 26 
     | 
    
         
            +
                    show: item['policy'] ? eval(item['policy']) : true
         
     | 
| 
       17 
27 
     | 
    
         
             
                  }
         
     | 
| 
       18 
28 
     | 
    
         
             
                end
         
     | 
| 
       19 
29 
     | 
    
         
             
                # rubocop:enable Security/Eval
         
     | 
| 
         @@ -5,6 +5,8 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              <div class="form-inputs">
         
     | 
| 
       7 
7 
     | 
    
         
             
                <%= f.input :email, required: true, autofocus: true %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                <%= f.input :nombre, required: true %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                <%= f.input :apellido, required: true %>
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
11 
     | 
    
         
             
                <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
         
     | 
| 
       10 
12 
     | 
    
         
             
                  <p><%= t(".currently_waiting_confirmation_for_email", email: resource.unconfirmed_email) %></p>
         
     | 
| 
         @@ -1,12 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <h2><%= t(".sign_up") %></h2>
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            <%= pg_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
         
     | 
| 
       4 
     | 
    
         
            -
              <%= f. 
     | 
| 
      
 4 
     | 
    
         
            +
              <%= f.mensajes_de_error %>
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              <div class="form-inputs">
         
     | 
| 
      
 7 
     | 
    
         
            +
                <%= f.input :nombre, required: true, autofocus: true %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                <%= f.input :apellido, required: true %>
         
     | 
| 
       7 
9 
     | 
    
         
             
                <%= f.input :email,
         
     | 
| 
       8 
10 
     | 
    
         
             
                            required: true,
         
     | 
| 
       9 
     | 
    
         
            -
                            autofocus: true ,
         
     | 
| 
       10 
11 
     | 
    
         
             
                            input_html: { autocomplete: "email" }%>
         
     | 
| 
       11 
12 
     | 
    
         
             
                <%= f.input :password,
         
     | 
| 
       12 
13 
     | 
    
         
             
                            required: true,
         
     | 
| 
         @@ -18,3 +18,14 @@ 
     | 
|
| 
       18 
18 
     | 
    
         
             
            <% end %>
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            <%= render "devise/shared/links" %>
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            <% if Rails.env.development? %>
         
     | 
| 
      
 23 
     | 
    
         
            +
              <br>
         
     | 
| 
      
 24 
     | 
    
         
            +
              <br>
         
     | 
| 
      
 25 
     | 
    
         
            +
              <br>
         
     | 
| 
      
 26 
     | 
    
         
            +
              <ul>
         
     | 
| 
      
 27 
     | 
    
         
            +
                <% User.all.each do |user| %>
         
     | 
| 
      
 28 
     | 
    
         
            +
                  <li><%= link_to user, admin_login_as_path(id: user.id) %></li>
         
     | 
| 
      
 29 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 30 
     | 
    
         
            +
              </ul>
         
     | 
| 
      
 31 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -3,8 +3,9 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            - flash_to_show = flash.select { |flash_message| flash_message[0].to_sym.in? ApplicationController._flash_types }
         
     | 
| 
       4 
4 
     | 
    
         
             
            / slim-lint:enable LineLength
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
            / TODO: data-turbo-temporary, setear al activar toast?
         
     | 
| 
       6 
7 
     | 
    
         
             
            - flash_to_show.each do |flash_type, message|
         
     | 
| 
       7 
8 
     | 
    
         
             
              .toast(class="bg-#{flash_type_to_class(flash_type)}-subtle" role="alert" data-bs-autohide="true"
         
     | 
| 
       8 
     | 
    
         
            -
                     data- 
     | 
| 
      
 9 
     | 
    
         
            +
                     data-xturbo-temporary="true" aria-live="assertive" aria-atomic="true")
         
     | 
| 
       9 
10 
     | 
    
         
             
                .toast-body
         
     | 
| 
       10 
11 
     | 
    
         
             
                  = message
         
     | 
| 
         @@ -9,16 +9,25 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  <!-- <span class="navbar-toggler-icon"></span> -->
         
     | 
| 
       10 
10 
     | 
    
         
             
                </button>
         
     | 
| 
       11 
11 
     | 
    
         
             
                <div class="collapse navbar-collapse" id="navbarSupportedContent">
         
     | 
| 
       12 
     | 
    
         
            -
                  <ul class="navbar-nav  
     | 
| 
      
 12 
     | 
    
         
            +
                  <ul class="navbar-nav xme-auto mb-2 mb-lg-0">
         
     | 
| 
       13 
13 
     | 
    
         
             
                    <% if user_signed_in? %>
         
     | 
| 
       14 
14 
     | 
    
         
             
                      <li class="nav-item dropdown">
         
     | 
| 
       15 
15 
     | 
    
         
             
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
         
     | 
| 
       16 
     | 
    
         
            -
                          <%= current_user 
     | 
| 
      
 16 
     | 
    
         
            +
                          <%= current_user %>
         
     | 
| 
       17 
17 
     | 
    
         
             
                        </a>
         
     | 
| 
       18 
18 
     | 
    
         
             
                        <ul class="dropdown-menu">
         
     | 
| 
       19 
19 
     | 
    
         
             
                          <li>
         
     | 
| 
       20 
20 
     | 
    
         
             
                            <%= link_to "Mi perfil", edit_user_registration_path, class: 'dropdown-item' %>
         
     | 
| 
       21 
21 
     | 
    
         
             
                          </li>
         
     | 
| 
      
 22 
     | 
    
         
            +
                          <% @navbar.topbar.each do |entry| %>
         
     | 
| 
      
 23 
     | 
    
         
            +
                            <% next if @navbar.hide_entry?(entry) %>
         
     | 
| 
      
 24 
     | 
    
         
            +
                            <li>
         
     | 
| 
      
 25 
     | 
    
         
            +
                              <a class="dropdown-item" href="<%= entry[:path] %>">
         
     | 
| 
      
 26 
     | 
    
         
            +
                                <%= entry[:title] %>
         
     | 
| 
      
 27 
     | 
    
         
            +
                              </a>
         
     | 
| 
      
 28 
     | 
    
         
            +
                            </li>
         
     | 
| 
      
 29 
     | 
    
         
            +
                          <% end %>
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       22 
31 
     | 
    
         
             
                          <li>
         
     | 
| 
       23 
32 
     | 
    
         
             
                            <%= link_to "Cerrar sesión", destroy_user_session_path, data: { 'turbo-method': 'delete' }, class: 'dropdown-item' %>
         
     | 
| 
       24 
33 
     | 
    
         
             
                          </li>
         
     | 
| 
         @@ -40,6 +49,8 @@ 
     | 
|
| 
       40 
49 
     | 
    
         
             
                      </li>
         
     | 
| 
       41 
50 
     | 
    
         
             
                    <% end %>
         
     | 
| 
       42 
51 
     | 
    
         
             
                  </ul>
         
     | 
| 
      
 52 
     | 
    
         
            +
                  <%= content_for :navbar_ext %>
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
       43 
54 
     | 
    
         
             
                </div>
         
     | 
| 
       44 
55 
     | 
    
         
             
              </div>
         
     | 
| 
       45 
56 
     | 
    
         
             
            </nav>
         
     | 
    
        data/pg_rails/lib/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pg_rails
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 7.0.8.pre.alpha. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 7.0.8.pre.alpha.11
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Martín Rosso
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-03-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: Rails goodies.
         
     | 
| 
       14 
14 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -84,9 +84,12 @@ files: 
     | 
|
| 
       84 
84 
     | 
    
         
             
            - pg_engine/app/views/admin/users/new.html.slim
         
     | 
| 
       85 
85 
     | 
    
         
             
            - pg_engine/app/views/admin/users/show.html.slim
         
     | 
| 
       86 
86 
     | 
    
         
             
            - pg_engine/app/views/pg_engine/base/download.xlsx.axlsx
         
     | 
| 
      
 87 
     | 
    
         
            +
            - pg_engine/app/views/pg_engine/base/edit.html.slim
         
     | 
| 
       87 
88 
     | 
    
         
             
            - pg_engine/app/views/pg_engine/base/index.html.slim
         
     | 
| 
      
 89 
     | 
    
         
            +
            - pg_engine/app/views/pg_engine/base/new.html.slim
         
     | 
| 
       88 
90 
     | 
    
         
             
            - pg_engine/config/initializers/active_admin.rb
         
     | 
| 
       89 
91 
     | 
    
         
             
            - pg_engine/config/initializers/devise.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - pg_engine/config/initializers/simple_form_monkey_patch.rb
         
     | 
| 
       90 
93 
     | 
    
         
             
            - pg_engine/config/locales/devise.en.yml
         
     | 
| 
       91 
94 
     | 
    
         
             
            - pg_engine/config/locales/es.yml
         
     | 
| 
       92 
95 
     | 
    
         
             
            - pg_engine/config/routes.rb
         
     | 
| 
         @@ -99,6 +102,7 @@ files: 
     | 
|
| 
       99 
102 
     | 
    
         
             
            - pg_engine/db/migrate/20240211152951_create_accounts.rb
         
     | 
| 
       100 
103 
     | 
    
         
             
            - pg_engine/db/migrate/20240211153049_create_user_accounts.rb
         
     | 
| 
       101 
104 
     | 
    
         
             
            - pg_engine/db/migrate/20240222115722_create_active_storage_tables.active_storage.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - pg_engine/db/migrate/20240305200900_nombre_user.rb
         
     | 
| 
       102 
106 
     | 
    
         
             
            - pg_engine/db/seeds.rb
         
     | 
| 
       103 
107 
     | 
    
         
             
            - pg_engine/lib/pg_engine.rb
         
     | 
| 
       104 
108 
     | 
    
         
             
            - pg_engine/lib/pg_engine/configuracion.rb
         
     | 
| 
         @@ -112,6 +116,8 @@ files: 
     | 
|
| 
       112 
116 
     | 
    
         
             
            - pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb
         
     | 
| 
       113 
117 
     | 
    
         
             
            - pg_engine/spec/controllers/admin/users_controller_spec.rb
         
     | 
| 
       114 
118 
     | 
    
         
             
            - pg_engine/spec/controllers/concerns/pg_engine/error_helper_spec.rb
         
     | 
| 
      
 119 
     | 
    
         
            +
            - pg_engine/spec/controllers/devise/registrations_controller_spec.rb
         
     | 
| 
      
 120 
     | 
    
         
            +
            - pg_engine/spec/controllers/devise/sessions_controller_spec.rb
         
     | 
| 
       115 
121 
     | 
    
         
             
            - pg_engine/spec/factories/accounts.rb
         
     | 
| 
       116 
122 
     | 
    
         
             
            - pg_engine/spec/factories/user_accounts.rb
         
     | 
| 
       117 
123 
     | 
    
         
             
            - pg_engine/spec/factories/users.rb
         
     |