pg_rails 7.0.8.pre.alpha.50 → 7.0.8.pre.alpha.52

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: ec90b6f4737df51fd11299a90574cd3ad866c7836aae3dbca2ee92e233839ba4
4
- data.tar.gz: 8f16fc698d6a2ae0da96671b478c3a4d1cdefd4ff191a82e6f513e26c8ca9783
3
+ metadata.gz: 876fb2da0e2e5139b70ba574e13ea948c56033482c92735ddf35f6d3b6c2008f
4
+ data.tar.gz: e14f3345126ab9ad158aef8d2869d392e257d323175ae53d620b98a68c7c6d08
5
5
  SHA512:
6
- metadata.gz: 1e95e14b14a79a2ceeb30713ce56e44413f14a35affc51262ec0fc9ebfca7e283e19874566444a22241e128a0b4745f228148f838ff12aef22c36e1de9c62370
7
- data.tar.gz: 6cab64c3dc2a6492a14b2b8af5c7d0b5d28752eae52e3e36d6543a4f81ee7289c38e78212e0835108e35f598485cf269b334527ac8a43ca26f4e64dba29a3fbd
6
+ metadata.gz: 295aae4c9c6c02b32f91d5da8c5089527efd9d64fbad58ed45471e048289ba90b3293cba4a83b7be0c5ad15cf55a0659de83105982734dddafba4f1b04307a31
7
+ data.tar.gz: 462cd7d0875ad74e1a9d866da48022ff730d250f306ab7953f87edc9acb2a147f759c677655650d06f1a81aa0ec9e89ca69ea96c9e22025345d435377ef03511
@@ -0,0 +1,28 @@
1
+ ActiveAdmin.register MensajeContacto do
2
+ permit_params :nombre, :email, :telefono, :mensaje
3
+
4
+ index do
5
+ selectable_column
6
+ id_column
7
+ column :nombre
8
+ column :email
9
+ column :telefono
10
+ column :mensaje
11
+ actions
12
+ end
13
+
14
+ filter :nombre
15
+ filter :email
16
+ filter :telefono
17
+ filter :mensaje
18
+
19
+ form do |f|
20
+ f.inputs do
21
+ f.input :nombre
22
+ f.input :email
23
+ f.input :telefono
24
+ f.input :mensaje
25
+ end
26
+ f.actions
27
+ end
28
+ end
@@ -1,7 +1,7 @@
1
1
  module PgEngine
2
2
  module Resource
3
3
  def self.included(clazz)
4
- clazz.before_action :authenticate_user!
4
+ # clazz.before_action :authenticate_user!
5
5
  clazz.helper_method :atributos_para_listar
6
6
  clazz.helper_method :atributos_para_mostrar
7
7
  clazz.helper_method :current_page_size
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Public
6
+ class MensajeContactosController < PublicController
7
+ include PgEngine::Resource
8
+
9
+ before_action { @clase_modelo = MensajeContacto }
10
+
11
+ before_action(only: :index) { authorize MensajeContacto }
12
+
13
+ before_action :set_instancia_modelo, only: %i[new create]
14
+
15
+ layout 'pg_layout/container_logo'
16
+
17
+ def create
18
+ if @mensaje_contacto.save
19
+ render turbo_stream: turbo_stream.update('mensaje_contacto', partial: 'gracias')
20
+ else
21
+ render :new, status: :unprocessable_entity
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def atributos_permitidos
28
+ %i[nombre email telefono mensaje]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class MensajeContactoDecorator < 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,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # == Schema Information
4
+ #
5
+ # Table name: mensaje_contactos
6
+ #
7
+ # id :bigint not null, primary key
8
+ # email :string
9
+ # mensaje :string
10
+ # nombre :string
11
+ # telefono :string
12
+ # created_at :datetime not null
13
+ # updated_at :datetime not null
14
+ #
15
+
16
+ class MensajeContacto < ApplicationRecord
17
+ audited
18
+
19
+ validates :nombre, :email, :mensaje, presence: true
20
+ validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/
21
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ class MensajeContactoPolicy < 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
+ true
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ .d-inline-block.text-start
2
+ .alert.alert-success.p-4 data-turbo-temporary="true" role="alert"
3
+ .row.align-items-center
4
+ .col-auto
5
+ h4 Gracias por tu mensaje
6
+ p.m-0 Te responderemos a la brevedad
7
+ .col-auto.fs-2
8
+ | 🌱
@@ -0,0 +1,21 @@
1
+ / # locals: (object: nil, asociable: false)
2
+ .text-center
3
+ #mensaje_contacto
4
+ h2 Ponete en contacto
5
+ .d-inline-block style="width: 30em; max-width: 100%"
6
+ div data-controller="pg_form"
7
+ = pg_form_for(@mensaje_contacto || object, asociable:) do |f|
8
+ = f.mensajes_de_error
9
+
10
+ = hidden_field_tag :asociable, true if asociable
11
+ = f.input :nombre, input_html: { style: 'max-width: 22em' }
12
+ = f.input :email, input_html: { style: 'max-width: 23em' }
13
+ = f.input :telefono, hint: '(Opcional)', input_html: { style: 'max-width: 15em' }
14
+ = f.input :mensaje, as: :text, input_html: { rows: 5 }
15
+ .mt-2
16
+ = f.button :submit, value: 'Enviar'
17
+
18
+ css:
19
+ form input {
20
+ margin: auto;
21
+ }
@@ -1,6 +1,9 @@
1
1
  include PgEngine::RouteHelpers
2
2
 
3
3
  Rails.application.routes.draw do
4
+ namespace :public, path: '' do
5
+ pg_resource(:mensaje_contactos, only: [:new, :create], path: 'contacto')
6
+ end
4
7
  devise_for :users, controllers: {
5
8
  confirmations: 'users/confirmations',
6
9
  registrations: 'users/registrations'
@@ -0,0 +1,15 @@
1
+ # generado con pg_rails
2
+
3
+ class CreateMensajeContactos < ActiveRecord::Migration[7.1]
4
+ def change
5
+ create_table :mensaje_contactos do |t|
6
+ t.string :nombre
7
+ t.string :email
8
+ t.string :telefono
9
+ t.string :mensaje
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ require 'rails_helper'
6
+
7
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
8
+ # It demonstrates how one might use RSpec to specify the controller code that
9
+ # was generated by Rails when you ran the scaffold generator.
10
+ #
11
+ # It assumes that the implementation code is generated by the rails scaffold
12
+ # generator. If you are using any extension libraries to generate different
13
+ # controller code, this generated spec may or may not pass.
14
+ #
15
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
16
+ # of tools you can use to make these specs even more expressive, but we're
17
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
18
+ #
19
+ # Compared to earlier versions of this generator, there is very limited use of
20
+ # stubs and message expectations in this spec. Stubs are only used when there
21
+ # is no simpler way to get a handle on the object needed for the example.
22
+ # Message expectations are only used when there is no simpler way to specify
23
+ # that an instance is receiving a specific message.
24
+ #
25
+ # Also compared to earlier versions of this generator, there are no longer any
26
+ # expectations of assigns and templates rendered. These features have been
27
+ # removed from Rails core in Rails 5, but can be added back in via the
28
+ # `rails-controller-testing` gem.
29
+
30
+ RSpec.describe Public::MensajeContactosController do
31
+ render_views
32
+ # This should return the minimal set of attributes required to create a valid
33
+ # MensajeContacto. As you add validations to MensajeContacto, be sure to
34
+ # adjust the attributes here as well.
35
+ let(:valid_attributes) do
36
+ attributes_for(:mensaje_contacto)
37
+ end
38
+
39
+ let(:invalid_attributes) do
40
+ {
41
+ nombre: nil
42
+ }
43
+ end
44
+
45
+ let(:logged_user) { create :user, :developer }
46
+
47
+ before do
48
+ sign_in logged_user if logged_user.present?
49
+ end
50
+
51
+ describe 'routing' do
52
+ it 'routes GET index correctly' do
53
+ route = { get: '/contacto/new' }
54
+ expect(route).to route_to(controller: 'public/mensaje_contactos', action: 'new')
55
+ end
56
+ end
57
+
58
+ describe 'GET #new' do
59
+ it 'returns a success response' do
60
+ get :new, params: {}
61
+ expect(response).to be_successful
62
+ end
63
+ end
64
+
65
+ describe 'POST #create' do
66
+ context 'with valid params' do
67
+ it 'creates a new MensajeContacto' do
68
+ expect do
69
+ post :create, params: { mensaje_contacto: valid_attributes }
70
+ end.to change(MensajeContacto, :count).by(1)
71
+ end
72
+
73
+ it 'redirects to the created mensaje_contacto' do
74
+ post :create, params: { mensaje_contacto: valid_attributes }
75
+ expect(response).to have_http_status(:ok)
76
+ end
77
+ end
78
+
79
+ context 'with invalid params' do
80
+ it 'returns a unprocessable_entity response' do
81
+ post :create, params: { mensaje_contacto: invalid_attributes }
82
+ expect(response).to have_http_status(:unprocessable_entity)
83
+ end
84
+
85
+ it 'renders the new template' do
86
+ post :create, params: { mensaje_contacto: invalid_attributes }
87
+ expect(response).to render_template(:new)
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ FactoryBot.define do
6
+ factory :mensaje_contacto do
7
+ nombre { Faker::Lorem.sentence }
8
+ email { Faker::Internet.email }
9
+ telefono { Faker::Lorem.sentence }
10
+ mensaje { Faker::Lorem.sentence }
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ require 'rails_helper'
6
+
7
+ RSpec.describe MensajeContacto do
8
+ let(:mensaje_contacto) { create(:mensaje_contacto) }
9
+
10
+ it 'se persiste' do
11
+ expect(mensaje_contacto).to be_persisted
12
+ end
13
+ end
@@ -1,9 +1,3 @@
1
- <% if @navbar.logo_xl_url.present? %>
2
- <div class="mx-3 my-4 m-md-5">
3
- <%= image_tag @navbar.logo_xl_url, class: 'img-fluid' %>
4
- </div>
5
- <% end %>
6
-
7
1
  <h2><%= t(".sign_up") %></h2>
8
2
  <div id="form-signup" data-controller="pg_form">
9
3
  <%= pg_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
@@ -1,9 +1,3 @@
1
- <% if @navbar.logo_xl_url.present? %>
2
- <div class="mx-3 my-4 m-md-5">
3
- <%= image_tag @navbar.logo_xl_url, class: 'img-fluid' %>
4
- </div>
5
- <% end %>
6
-
7
1
  <h2><%= t(".sign_in") %></h2>
8
2
 
9
3
  <%= render partial: 'pg_layout/flash_container' %>
@@ -0,0 +1,10 @@
1
+ - content_for :content do
2
+ .container-fluid.pt-4
3
+ .text-center
4
+ - if @navbar.logo_xl_url.present?
5
+ .mb-4
6
+ = image_tag @navbar.logo_xl_url, class: 'img-fluid', style: 'max-height: 4em'
7
+
8
+ = content_for?(:container_logo_content) ? yield(:container_logo_content) : yield
9
+
10
+ = render template: 'layouts/pg_layout/base'
@@ -1,5 +1,5 @@
1
- - content_for :content do
2
- .container.text-center.pt-4
1
+ - content_for :container_logo_content do
2
+ .text-center
3
3
  = yield
4
4
 
5
5
  css:
@@ -8,4 +8,4 @@
8
8
  margin: auto;
9
9
  }
10
10
 
11
- = render template: 'layouts/pg_layout/base'
11
+ = render template: 'layouts/pg_layout/container_logo'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.50'
4
+ VERSION = '7.0.8-alpha.52'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.50
4
+ version: 7.0.8.pre.alpha.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
@@ -846,6 +846,7 @@ files:
846
846
  - pg_engine/app/admin/accounts.rb
847
847
  - pg_engine/app/admin/audits.rb
848
848
  - pg_engine/app/admin/dashboard.rb
849
+ - pg_engine/app/admin/mensaje_contactos.rb
849
850
  - pg_engine/app/admin/user_accounts.rb
850
851
  - pg_engine/app/admin/users.rb
851
852
  - pg_engine/app/assets/javascripts/active_admin.js
@@ -858,9 +859,11 @@ files:
858
859
  - pg_engine/app/controllers/pg_engine/base_controller.rb
859
860
  - pg_engine/app/controllers/pg_engine/devise_controller.rb
860
861
  - pg_engine/app/controllers/pg_engine/require_sign_in.rb
862
+ - pg_engine/app/controllers/public/mensaje_contactos_controller.rb
861
863
  - pg_engine/app/controllers/users/confirmations_controller.rb
862
864
  - pg_engine/app/controllers/users/registrations_controller.rb
863
865
  - pg_engine/app/decorators/account_decorator.rb
866
+ - pg_engine/app/decorators/mensaje_contacto_decorator.rb
864
867
  - pg_engine/app/decorators/pg_engine/base_decorator.rb
865
868
  - pg_engine/app/decorators/user_account_decorator.rb
866
869
  - pg_engine/app/decorators/user_decorator.rb
@@ -878,10 +881,12 @@ files:
878
881
  - pg_engine/app/lib/pg_form_builder.rb
879
882
  - pg_engine/app/models/account.rb
880
883
  - pg_engine/app/models/current.rb
884
+ - pg_engine/app/models/mensaje_contacto.rb
881
885
  - pg_engine/app/models/pg_engine/base_record.rb
882
886
  - pg_engine/app/models/user.rb
883
887
  - pg_engine/app/models/user_account.rb
884
888
  - pg_engine/app/policies/account_policy.rb
889
+ - pg_engine/app/policies/mensaje_contacto_policy.rb
885
890
  - pg_engine/app/policies/pg_engine/application_policy.rb
886
891
  - pg_engine/app/policies/user_account_policy.rb
887
892
  - pg_engine/app/policies/user_policy.rb
@@ -904,6 +909,8 @@ files:
904
909
  - pg_engine/app/views/pg_engine/base/edit.html.slim
905
910
  - pg_engine/app/views/pg_engine/base/index.html.slim
906
911
  - pg_engine/app/views/pg_engine/base/new.html.slim
912
+ - pg_engine/app/views/public/mensaje_contactos/_gracias.html.slim
913
+ - pg_engine/app/views/public/mensaje_contactos/new.html.slim
907
914
  - pg_engine/config/initializers/action_mailer.rb
908
915
  - pg_engine/config/initializers/active_admin.rb
909
916
  - pg_engine/config/initializers/anycable.rb
@@ -925,6 +932,7 @@ files:
925
932
  - pg_engine/db/migrate/20240222115722_create_active_storage_tables.active_storage.rb
926
933
  - pg_engine/db/migrate/20240305200900_nombre_user.rb
927
934
  - pg_engine/db/migrate/20240314114503_remove_hash_ids.rb
935
+ - pg_engine/db/migrate/20240428152916_create_mensaje_contactos.rb
928
936
  - pg_engine/db/seeds.rb
929
937
  - pg_engine/lib/pg_engine.rb
930
938
  - pg_engine/lib/pg_engine/configuracion.rb
@@ -941,9 +949,11 @@ files:
941
949
  - pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
942
950
  - pg_engine/spec/controllers/devise/sessions_controller_spec.rb
943
951
  - pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
952
+ - pg_engine/spec/controllers/public/mensaje_contactos_controller_spec.rb
944
953
  - pg_engine/spec/controllers/users/confirmations_controller_spec.rb
945
954
  - pg_engine/spec/controllers/users/registrations_controller_spec.rb
946
955
  - pg_engine/spec/factories/accounts.rb
956
+ - pg_engine/spec/factories/mensaje_contactos.rb
947
957
  - pg_engine/spec/factories/user_accounts.rb
948
958
  - pg_engine/spec/factories/users.rb
949
959
  - pg_engine/spec/fixtures/test.pdf
@@ -952,6 +962,7 @@ files:
952
962
  - pg_engine/spec/lib/pg_engine/utils/pg_engine/pg_logger_spec.rb
953
963
  - pg_engine/spec/lib/pg_form_builder_spec.rb
954
964
  - pg_engine/spec/models/account_spec.rb
965
+ - pg_engine/spec/models/mensaje_contacto_spec.rb
955
966
  - pg_engine/spec/models/pg_engine/base_record_spec.rb
956
967
  - pg_engine/spec/models/user_account_spec.rb
957
968
  - pg_engine/spec/models/user_spec.rb
@@ -994,6 +1005,7 @@ files:
994
1005
  - pg_layout/app/views/kaminari/_paginator.html.slim
995
1006
  - pg_layout/app/views/kaminari/_prev_page.html.slim
996
1007
  - pg_layout/app/views/layouts/pg_layout/base.html.slim
1008
+ - pg_layout/app/views/layouts/pg_layout/container_logo.html.slim
997
1009
  - pg_layout/app/views/layouts/pg_layout/containerized.html.slim
998
1010
  - pg_layout/app/views/layouts/pg_layout/devise.html.slim
999
1011
  - pg_layout/app/views/pg_layout/_flash.html.slim