pg_rails 7.6.24 → 7.6.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5202df927d12827a79e5c89d668cc344dfbd434a266b39810d5585ffdc3ac932
4
- data.tar.gz: d74570bcf0eeb4a5d9f11fb5baf720585458a2026bb0683966a37556d7f2bf69
3
+ metadata.gz: 4b2c5672f192482e718fb6f12e66e7cfcd376e916c7663f13931aa526d931f42
4
+ data.tar.gz: cb427f6f6dd542648c697f53b3ddc688f8506919a809bfff3e32c6119612b1a4
5
5
  SHA512:
6
- metadata.gz: d83f4adfce2d2ad3b22996b88dd61df4818e5ee824f66a3b0ac8d5817063e653b4bcbe5c60d98363040ae72886437b4a4a752f2a41bcd36d692e51eca1374b49
7
- data.tar.gz: 45adb571a8d819d11d23a66ef49882496119e3e97e0741e63b59c5f0091d7686189564eabb60ee1c78d6da7fa57139d28340bbcc4a5d41bf7ceb396a28624567
6
+ metadata.gz: e98643fa17d81bcdfa0993cd66dbf532d36a6e1935a0144f88e67f2b54dad6e0ec81795fb9a5be9c35c42f6737e1ff8a51ed77f871104f691e711d8a16a8ffb5
7
+ data.tar.gz: df1e9eae5424d3ea481be959d24f33b09a5433ce0660f2bdc55ddda5595926ae753c7489c6ac90cc0956219b0909b0d6dd82cb784b2538d00f80820eb654d7cf
@@ -16,6 +16,12 @@ nav[aria-label=breadcrumb] a {
16
16
  display: inline-block;
17
17
  }
18
18
 
19
+ // Signup
20
+
21
+ #form-signup .form-inputs abbr {
22
+ display: none;
23
+ }
24
+
19
25
  // FORMS
20
26
 
21
27
  // Radio buttons
@@ -1,6 +1,8 @@
1
1
  class FlashContainerComponent < ViewComponent::Base
2
+ # z-1 es para que no se superponga con el dropdown de la navbar,
3
+ # ya que sticky-top setea un z-index de 1020 y el del dropdown es de 1000
2
4
  erb_template <<~HTML
3
- <div id="flash-container" class="d-flex justify-content-around sticky-top">
5
+ <div id="flash-container" class="d-flex justify-content-around sticky-top z-1">
4
6
  <div id="flash" class="flash position-relative w-100 d-flex justify-content-center">
5
7
  <%= content || render(partial: 'pg_layout/flash') %>
6
8
  </div>
@@ -15,7 +15,7 @@ module PgEngine
15
15
  if usuario.confirmed_at.present?
16
16
  sign_in(:user, usuario)
17
17
  # redirect_to after_sign_in_path_for(usuario)
18
- redirect_to users_root_path
18
+ redirect_to user_root_path
19
19
  else
20
20
  go_back('No está confirmado')
21
21
  end
@@ -36,6 +36,16 @@ module Users
36
36
  end
37
37
  end
38
38
 
39
+ def user_root
40
+ scope = policy_scope(Account)
41
+ if scope.count == 1
42
+ ua = Current.user.user_account_for(scope.first)
43
+ redirect_to tenant_root_path(ua.to_param)
44
+ else
45
+ redirect_to users_accounts_path
46
+ end
47
+ end
48
+
39
49
  # La user_account puede estar disabled
40
50
  def show
41
51
  add_breadcrumb @account, users_account_path(@account, tid: nil)
@@ -6,6 +6,7 @@ module Users
6
6
  yield resource if block_given?
7
7
 
8
8
  if resource.errors.empty?
9
+ sign_in(resource)
9
10
  set_flash_message!(:notice, :confirmed)
10
11
  respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
11
12
  else
@@ -4,6 +4,13 @@ module Users
4
4
  authorize resource, nil, policy_class: UserRegistrationPolicy
5
5
  end
6
6
 
7
+ # GET /resource/sign_up
8
+ def new
9
+ build_resource(accept_terms: true)
10
+ yield resource if block_given?
11
+ respond_with resource
12
+ end
13
+
7
14
  def create
8
15
  build_resource(sign_up_params)
9
16
 
@@ -72,8 +72,15 @@ module PgEngine
72
72
  if Current.tid.present?
73
73
  tenant_root_path(tid: Current.tid)
74
74
  else
75
- (Current.user.present? ? users_root_path : root_path)
75
+ (Current.user.present? ? user_root_path : root_path)
76
76
  end
77
77
  end
78
+
79
+ # :nocov:
80
+ deprecate :users_root_path, deprecator: PgEngine.deprecator
81
+ def users_root_path
82
+ user_root_path
83
+ end
84
+ # :nocov:
78
85
  end
79
86
  end
@@ -23,6 +23,12 @@ class PgFormBuilder < SimpleForm::FormBuilder
23
23
  def input(attribute_name, options = {}, &)
24
24
  options[:error_prefix] ||= default_prefix(attribute_name)
25
25
 
26
+ # Bootstraps's floating labels require an empty placeholder attribute
27
+ merged_wrapper = self.options[:wrapper].to_s + options[:wrapper].to_s
28
+ if merged_wrapper.include?('floating')
29
+ options[:placeholder] = ''
30
+ end
31
+
26
32
  super
27
33
  end
28
34
 
@@ -66,7 +66,7 @@ class User < ApplicationRecord
66
66
 
67
67
  has_many :notifications, as: :recipient, class_name: 'Noticed::Notification'
68
68
 
69
- validates :nombre, :apellido, presence: true
69
+ # validates :nombre, :apellido, presence: true
70
70
 
71
71
  has_one_attached :avatar do |attachable|
72
72
  attachable.variant :thumb, resize_to_fill: [80, 80]
@@ -43,7 +43,7 @@ es:
43
43
  confirmed_at: Fecha de confirmación
44
44
  actualizado_por: Actualizado por
45
45
  creado_por: Creado por
46
- accept_terms: Acepto los <a href="/terminos_y_condiciones" target="_blank">Términos y condiciones</a> y la <a href="/privacidad" target="_blank">Política de privacidad</a>
46
+ accept_terms: Acepto los <a href="/terminos_y_condiciones" target="_blank">términos y condiciones</a>
47
47
  enumerize:
48
48
  user_account:
49
49
  membership_status:
@@ -117,7 +117,7 @@ es:
117
117
  header: "Aceptar invitación"
118
118
  submit_button: "Aceptar"
119
119
  confirmations:
120
- confirmed: ¡Tu cuenta está confirmada! Ya podés iniciar sesión
120
+ confirmed: ¡Bien! Ahora tu cuenta está confirmada
121
121
  sessions:
122
122
  signed_in: ''
123
123
  signed_out: ''
@@ -128,7 +128,7 @@ es:
128
128
  unauthenticated: ''
129
129
  invited: "Tenés una invitación pendiente en tu correo electrónico"
130
130
  registrations:
131
- signed_up_but_unconfirmed: Te enviamos un correo electrónico con instrucciones para confirmar tu cuenta.
131
+ signed_up_but_unconfirmed: Por favor, revisá en tu bandeja de entrada las instrucciones para confirmar tu cuenta.
132
132
  new:
133
133
  sign_up: Crear una cuenta
134
134
  passwords:
@@ -31,10 +31,11 @@ Rails.application.routes.draw do
31
31
  put :update_invitation
32
32
  end
33
33
  end
34
-
35
- root to: 'accounts#index'
36
34
  end
37
35
 
36
+ # User root for devise's signed_in_root_path
37
+ get '/u', to: 'users/accounts#user_root', as: :user_root
38
+
38
39
  namespace :tenant, path: 'u/t(/:tid)' do
39
40
  pg_resource(:user_accounts, only: [:index, :show, :edit, :update, :destroy])
40
41
  scope controller: 'inline_edit', path: 'inline', as: :inline do
@@ -47,8 +48,7 @@ Rails.application.routes.draw do
47
48
  root to: 'dashboard#dashboard'
48
49
  end
49
50
 
50
- # root to: 'users/accounts#index'
51
- # FIXME: qué onda
51
+ # Si en la main app no se define una root path, se redirige al user_root
52
52
  root to: redirect('/u')
53
53
 
54
54
  namespace :admin, path: 'a' do
@@ -88,6 +88,44 @@ describe 'Users::AccountsController' do
88
88
  end
89
89
  end
90
90
 
91
+ describe 'user_root' do
92
+ subject do
93
+ get '/u'
94
+ end
95
+
96
+ context 'when no accounts' do
97
+ let(:user) { create :user }
98
+
99
+ it do
100
+ subject
101
+ expect(response).to redirect_to(users_accounts_path)
102
+ end
103
+ end
104
+
105
+ context 'when one account' do
106
+ it do
107
+ subject
108
+ ua = user.user_account_for(account)
109
+ expect(response).to redirect_to(tenant_root_path(ua.to_param))
110
+ # File.write(Rails.root.join('out.html'), response.body)
111
+ end
112
+ end
113
+
114
+ context 'when multiple accounts' do
115
+ before do
116
+ other_account = create(:account)
117
+ ActsAsTenant.without_tenant do
118
+ create(:user_account, account: other_account, user:)
119
+ end
120
+ end
121
+
122
+ it do
123
+ subject
124
+ expect(response).to redirect_to(users_accounts_path)
125
+ end
126
+ end
127
+ end
128
+
91
129
  describe 'index' do
92
130
  subject do
93
131
  get '/u/espacios'
@@ -18,10 +18,7 @@ describe 'Al Registrarse' do
18
18
  perform_enqueued_jobs do
19
19
  visit '/users/sign_up'
20
20
  fill_in 'user_email', with: Faker::Internet.email
21
- fill_in 'user_nombre', with: Faker::Name.name
22
- fill_in 'user_apellido', with: Faker::Name.name
23
21
  fill_in 'user_password', with: 'admin123'
24
- fill_in 'user_password_confirmation', with: 'admin123'
25
22
 
26
23
  accept_terms
27
24
 
@@ -31,7 +28,7 @@ describe 'Al Registrarse' do
31
28
 
32
29
  context 'cuando acepta los términos' do
33
30
  let(:accept_terms) do
34
- check 'user_accept_terms'
31
+ nil
35
32
  end
36
33
 
37
34
  it 'guarda el user' do
@@ -39,13 +36,13 @@ describe 'Al Registrarse' do
39
36
  ActsAsTenant.without_tenant do
40
37
  expect(Account.last.owner).to eq User.last
41
38
  end
42
- expect(page).to have_text('Te enviamos un correo electrónico con instrucciones')
39
+ expect(page).to have_text('las instrucciones para confirmar')
43
40
  end
44
41
  end
45
42
 
46
43
  context 'si no acepta los terms' do
47
44
  let(:accept_terms) do
48
- nil
45
+ uncheck 'user_accept_terms'
49
46
  end
50
47
 
51
48
  it do
@@ -77,12 +74,6 @@ describe 'Al Registrarse' do
77
74
  end
78
75
  end
79
76
 
80
- # drivers = %i[
81
- # selenium_headless
82
- # selenium_chrome_headless
83
- # selenium_chrome_headless_notebook
84
- # selenium_chrome_headless_iphone
85
- # ]
86
77
  drivers = %i[selenium_chrome_headless_iphone]
87
78
  drivers = [ENV['DRIVER'].to_sym] if ENV['DRIVER'].present?
88
79
 
@@ -0,0 +1 @@
1
+ p Creá tu cuenta!
@@ -1,27 +1,29 @@
1
- <h2><%= t(".sign_up") %></h2>
2
- <div id="form-signup" data-controller="pg_form">
3
- <%= pg_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
- <div class="form-inputs">
5
- <%= f.input :nombre, required: true, autofocus: true %>
6
- <%= f.input :apellido, required: true %>
7
- <%= f.input :email,
8
- required: true,
9
- input_html: { autocomplete: "email" }%>
10
- <%= f.input :password,
11
- required: true,
12
- hint: (t('devise.shared.minimum_password_length', count: @minimum_password_length) if @minimum_password_length),
13
- input_html: { autocomplete: "new-password" } %>
14
- <%= f.input :password_confirmation,
15
- required: true,
16
- input_html: { autocomplete: "new-password" } %>
17
- <%= f.input :accept_terms, as: :boolean, label: t('attributes.accept_terms').html_safe, error_prefix: '' %>
1
+ <div class="container mt-5" style="max-width: 80em">
2
+ <div class="row flex-wrap-reverse">
3
+ <div class="col-sm">
4
+ <%= render partial: 'signup_info' %>
18
5
  </div>
6
+ <div class="col-sm">
7
+ <div class="position-sticky z-1" style="top: 0.5em">
8
+ <h1 class="mb-4">Creá tu cuenta</h1>
9
+ <%# #form-signup se reemplaza por el mensaje de revisar la bandeja de entrada %>
10
+ <div class="text-center" id="form-signup" data-controller="pg_form">
11
+ <%= pg_form_for(resource, as: resource_name, url: registration_path(resource_name), wrapper: :floating_labels_form) do |f| %>
12
+ <div class="form-inputs m-auto d-inline-block" style="max-width: 20em">
13
+ <%= f.input :email, label: 'Tu email', input_html: { class: 'form-control-lg', autocomplete: "email" }%>
14
+ <%= f.input :password, label: 'Elegí una contraseña',
15
+ input_html: { class: 'form-control-lg', autocomplete: "new-password" } %>
16
+ <%= f.input :accept_terms, as: :boolean, label: t('attributes.accept_terms').html_safe, error_prefix: '', wrapper_html: { class: 'justify-content-center' } %>
17
+ </div>
19
18
 
20
- <div class="form-actions">
21
- <%= f.button :submit, t(".sign_up") %>
22
- </div>
23
- <% end %>
19
+ <div class="form-actions">
20
+ <%= f.button :submit, 'Registrarme' %>
21
+ </div>
22
+ <% end %>
24
23
 
25
- <%= render "devise/shared/links" %>
24
+ <%= render "devise/shared/links" %>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </div>
26
29
  </div>
27
-
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  module PgRails
4
- VERSION = '7.6.24'
5
+ VERSION = '7.6.26'
5
6
  end
7
+ # :nocov:
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.6.24
4
+ version: 7.6.26
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: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2025-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1020,6 +1020,7 @@ files:
1020
1020
  - pg_layout/app/views/devise/mailer/unlock_instructions.html.erb
1021
1021
  - pg_layout/app/views/devise/passwords/edit.html.erb
1022
1022
  - pg_layout/app/views/devise/passwords/new.html.erb
1023
+ - pg_layout/app/views/devise/registrations/_signup_info.html.slim
1023
1024
  - pg_layout/app/views/devise/registrations/edit.html.erb
1024
1025
  - pg_layout/app/views/devise/registrations/new.html.erb
1025
1026
  - pg_layout/app/views/devise/sessions/new.html.erb