pg_rails 7.0.8.pre.alpha.62 → 7.0.8.pre.alpha.63

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afcf64379ab25a58e3b1d626f71371cc63448503880d182b8ad1e1164dbccf7e
4
- data.tar.gz: 9917f1be640ccdbabbc1d7c12ca561d5714f1b4227e3899c3c1cc96749157284
3
+ metadata.gz: 8d32d439bc5fe9dd6527c13d1800daf3381c2590b883844e772ca336732efeec
4
+ data.tar.gz: f9aff03d93288060f00dfb7efcb6c9160ffc2f7ac6ba9cd3c59aa6f3934d5bbe
5
5
  SHA512:
6
- metadata.gz: a620ba16efe37ac2794a11676bcecb89ad101053abcb04147a246b2c3d074de03799b01d1d0ad7578855d05347f793aec52a62a6722a4e755ee161aa156a98bf
7
- data.tar.gz: 8d63151e40a4a105137d3a097b9ec09690c159b2130620d078bc5c428895522631c5ffc732acd20b4cd32094470f2e72aca5a05050e13cfc8381207662d61c2a
6
+ metadata.gz: 397c4960f4e804ed8b88096542573b34475a935426db607cb14542a70991697c76404bae1460b0a8859eb3dbe6eefc2b9f829ebebf9cb019a9501b89c5b24790
7
+ data.tar.gz: dd5e763c4fe36a2f5b7115dffcadceba504e8bdd99a874c727e5ce1197698dafadb142b5601ada51d61a980421c6beef2fbea865fa3df1a15dd0391e96054d82
@@ -0,0 +1 @@
1
+ //= link_tree ../images
@@ -20,8 +20,6 @@ module PgEngine
20
20
  def index
21
21
  @collection = filtros_y_policy atributos_para_buscar
22
22
  @collection = sort_collection(@collection)
23
- @records_filtered = policy_scope(clase_modelo).any? if @collection.empty?
24
- # FIXME: si hay pero en páginas anteriores, mostrar texto correspondiente
25
23
  pg_respond_index
26
24
  end
27
25
 
@@ -208,6 +206,7 @@ module PgEngine
208
206
 
209
207
  def render_listing
210
208
  @collection = @collection.page(params[:page]).per(current_page_size)
209
+ @records_filtered = default_scope_for_current_model.any? if @collection.empty?
211
210
  end
212
211
 
213
212
  def buscar_instancia
@@ -272,6 +271,12 @@ module PgEngine
272
271
  @filtros.filtrar(scope)
273
272
  end
274
273
 
274
+ def default_scope_for_current_model
275
+ PgEngine::FiltrosBuilder.new(
276
+ self, clase_modelo, []
277
+ ).filtrar(policy_scope(clase_modelo))
278
+ end
279
+
275
280
  def do_sort(scope, field, direction)
276
281
  # TODO: restringir ciertos campos?
277
282
  unless scope.model.column_names.include?(field.to_s) ||
@@ -21,7 +21,7 @@ module Users
21
21
 
22
22
  def render_message
23
23
  msg = <<~HTML
24
- <div class="alert alert-info mt-4">
24
+ <div class="alert alert-info mt-4 d-inline-block">
25
25
  #{I18n.t 'devise.registrations.signed_up_but_unconfirmed'}
26
26
  </div>
27
27
  HTML
@@ -5,8 +5,9 @@ module PgEngine
5
5
  end
6
6
 
7
7
  def render_turbo_stream_title
8
+ title = [breadcrumbs.last&.name, I18n.t('app_name')].compact.join(' - ')
8
9
  # rubocop:disable Rails/SkipsModelValidations
9
- turbo_stream.update_all 'title', "#{breadcrumbs.last&.name} - #{Rails.application.class.module_parent_name}"
10
+ turbo_stream.update_all 'title', title
10
11
  # rubocop:enable Rails/SkipsModelValidations
11
12
  end
12
13
 
@@ -92,7 +92,7 @@ module PgEngine
92
92
  def print_currency(number, simbolo: '$', precision: nil)
93
93
  return if number.blank?
94
94
 
95
- # FIXME: testear
95
+ # TODO!: testear
96
96
  precision ||= if (number % 0.01).positive?
97
97
  3
98
98
  else
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PgEngine
4
+ class DeviseFailureApp < Devise::FailureApp
5
+ def respond
6
+ if warden_message == :unconfirmed
7
+ render_unconfirmed
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def user_email
16
+ params[:user][:email]
17
+ rescue StandardError => e
18
+ pg_warn e, :warn
19
+ end
20
+
21
+ def render_unconfirmed
22
+ self.content_type = 'text/vnd.turbo-stream.html'
23
+ self.status = 200
24
+ self.response_body = <<~HTML
25
+ <turbo-stream action="update" target="flash">
26
+ <template>
27
+ <div class="alert alert-warning d-flex align-items-center">
28
+ <div class="bi bi-exclamation-circle me-3"></div>
29
+ <span>
30
+ Tu cuenta aún no está confirmada.
31
+ <br>
32
+ Revisá tu bandeja de entrada o&nbsp;
33
+ <a href="/users/confirmation/new?email=#{user_email}">hacé click acá para reenviar el correo</a>
34
+ </span>
35
+ </div>
36
+ </template>
37
+ </turbo-stream>
38
+ HTML
39
+ end
40
+ end
41
+ end
@@ -52,7 +52,7 @@ class Email < ApplicationRecord
52
52
 
53
53
  validate do
54
54
  if to.present? && !to.split(/[,;]/).all? { |dest| dest.match(/\A[^@\s]+@[^@\s]+\z/) }
55
- # FIXME: testear
55
+ # TODO!: testear
56
56
  errors.add(:to, 'no es válido')
57
57
  end
58
58
  end
@@ -5,4 +5,4 @@
5
5
  h4 Gracias por tu mensaje
6
6
  p.m-0 Te responderemos a la brevedad
7
7
  .col-auto.fs-2
8
- | 🌱
8
+ = image_tag 'plantita-sm', width: '30px'
@@ -1,4 +1,8 @@
1
1
  / # locals: (object: nil, asociable: false)
2
+
3
+ .d-none
4
+ / Preload
5
+ = image_tag 'plantita-sm'
2
6
  .text-center
3
7
  #mensaje_contacto
4
8
  h2 Ponete en contacto
@@ -7,7 +7,7 @@ Rails.application.routes.draw do
7
7
  devise_for :users, controllers: {
8
8
  confirmations: 'users/confirmations',
9
9
  registrations: 'users/registrations'
10
- }
10
+ }, failure_app: PgEngine::DeviseFailureApp
11
11
  namespace :admin, path: 'a' do
12
12
  pg_resource(:emails)
13
13
  pg_resource(:users)
@@ -2,23 +2,20 @@
2
2
 
3
3
  module PgEngine
4
4
  class EmailObserver
5
- def self.delivered_email(message)
5
+ def self.delivered_email(message) # rubocop:disable Metrics/AbcSize
6
6
  message_id = message.message_id
7
7
  mailer = message.delivery_handler.to_s
8
8
  status = get_status(message)
9
-
10
9
  if message['email'].present?
11
10
  email = message['email'].unparsed_value
12
11
  email.update_columns(message_id:, mailer:, status:) # rubocop:disable Rails/SkipsModelValidations
13
- email.encoded_eml.attach({ io: StringIO.new(message.encoded), filename: "email-#{email.id}.eml" })
14
12
  else
15
- pg_warn 'El mail no tenía objeto Email asociado.', :warn
16
- # FIX: el content puede ser TXT
17
- # Email.create!(message_id: message.message_id, body_html: message.encoded,
18
- # subject: subject, recipient: recipient,
19
- # date: DateTime.now, mailer: message.delivery_handler.to_s, associated: associated(message),
20
- # status: get_status(message), observations: get_observations(message))
13
+ to = [message.to].flatten.join(', ')
14
+ from = [message.from].flatten.join(', ')
15
+ email = Email.create!(message_id:, subject: message.subject, to:, mailer:, status:, from_address: from,
16
+ from_name: '')
21
17
  end
18
+ email.encoded_eml.attach({ io: StringIO.new(message.encoded), filename: "email-#{email.id}.eml" })
22
19
  rescue StandardError => e
23
20
  pg_warn e, :error
24
21
  end
@@ -15,4 +15,27 @@ describe Devise::SessionsController do
15
15
  expect(response).to have_http_status(:ok)
16
16
  end
17
17
  end
18
+
19
+ describe '#create' do
20
+ subject do
21
+ post :create, params: { user: { email: user.email, password: } }
22
+ end
23
+
24
+ let(:password) { 'cosas1234' }
25
+ let(:confirmed_at) { nil }
26
+ let(:user) { create :user, confirmed_at:, password: }
27
+
28
+ it do
29
+ subject
30
+ expect(response.body).to include 'Tu cuenta aún no está confirmada.'
31
+ end
32
+
33
+ context 'cuando está confirmado' do
34
+ let(:confirmed_at) { Time.zone.now }
35
+
36
+ it do
37
+ expect { subject }.to change(controller, :user_signed_in?).from(false).to(true)
38
+ end
39
+ end
40
+ end
18
41
  end
@@ -16,9 +16,9 @@ export default class extends Controller {
16
16
  const baseAlert = document.querySelector('.alert-danger')
17
17
  if (!invalidField && !baseAlert) {
18
18
  const errorTitle = this.element.querySelector('.error-title')
19
- // FIXME: testear con capybara
19
+ // TODO!: testear con capybara
20
20
  errorTitle.innerText = 'Lo lamentamos mucho pero ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.'
21
- // FIXME: link a contacto
21
+ // TODO!: link a contacto
22
22
  const form = this.element.querySelector('form')
23
23
  const errorMsg = `${form.id} - ${form.action} - ${form.dataset.errors}`
24
24
  console.error(errorMsg)
@@ -39,7 +39,7 @@ class Navbar
39
39
  show: item['policy'] ? eval(item['policy']) : true
40
40
  }
41
41
  rescue StandardError
42
- # FIXME: testear
42
+ # TODO!: testear
43
43
  pg_err item
44
44
  return []
45
45
  end
@@ -1,5 +1,3 @@
1
- <h2><%= t(".resend_confirmation_instructions") %></h2>
2
-
3
1
  <%= pg_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4
2
  <%= f.mensajes_de_error %>
5
3
  <%= f.full_error :confirmation_token %>
@@ -9,7 +7,7 @@
9
7
  required: true,
10
8
  autofocus: true,
11
9
  value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
12
- input_html: { autocomplete: "email" } %>
10
+ input_html: { value: params[:email], autocomplete: "email" } %>
13
11
  </div>
14
12
 
15
13
  <div class="form-actions">
@@ -1,8 +1,16 @@
1
1
  doctype html
2
2
  html
3
3
  head
4
- title = Rails.application.class.module_parent_name
4
+ meta charset="UTF-8"
5
+ meta http-equiv="X-UA-Compatible" content="IE=edge"
5
6
  meta name="viewport" content="width=device-width,initial-scale=1"
7
+ - cache :title_icon
8
+ title = t('app_name')
9
+ - begin
10
+ = render partial: 'layouts/favicon'
11
+ - rescue ActionView::MissingTemplate => e
12
+ - pg_err e
13
+
6
14
  - if @turbo_no_cache
7
15
  meta name="turbo-cache-control" content="no-cache"
8
16
  / El morph no estaría siendo de utilidad
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.62'
4
+ VERSION = '7.0.8-alpha.63'
5
5
  end
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.62
4
+ version: 7.0.8.pre.alpha.63
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-05-08 00:00:00.000000000 Z
11
+ date: 2024-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -906,6 +906,9 @@ files:
906
906
  - pg_engine/app/admin/mensaje_contactos.rb
907
907
  - pg_engine/app/admin/user_accounts.rb
908
908
  - pg_engine/app/admin/users.rb
909
+ - pg_engine/app/assets/config/pg_engine_manifest.js
910
+ - pg_engine/app/assets/images/plantita-sm.png
911
+ - pg_engine/app/assets/images/plantita.png
909
912
  - pg_engine/app/assets/javascripts/active_admin.js
910
913
  - pg_engine/app/assets/stylesheets/active_admin.scss
911
914
  - pg_engine/app/assets/stylesheets/pg_rails_b5.scss
@@ -935,6 +938,7 @@ files:
935
938
  - pg_engine/app/helpers/pg_engine/print_helper.rb
936
939
  - pg_engine/app/helpers/pg_engine/route_helper.rb
937
940
  - pg_engine/app/inputs/pg_engine/fecha_input.rb
941
+ - pg_engine/app/lib/pg_engine/devise_failure_app.rb
938
942
  - pg_engine/app/lib/pg_engine/error_helper.rb
939
943
  - pg_engine/app/lib/pg_engine/filtros_builder.rb
940
944
  - pg_engine/app/lib/pg_form_builder.rb