eac_rails_base0 0.46.0 → 0.47.0

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: c96092667c86b10c873e3a50592375478186f66a8532f05b237fe7ec591c604f
4
- data.tar.gz: df32971dca2efcd3e13005ec8220f5f05fce87f3019f701e49bbc8aff45ab802
3
+ metadata.gz: 9dbf7853e319ed40781d1ba226a0a69ab73429884cbd6355c9ffc53cd8e3ac62
4
+ data.tar.gz: acf438c17b387f7b2fc025d92371809a4ec2dc68c2373678bd91c275d5e3e011
5
5
  SHA512:
6
- metadata.gz: e9c801d5573d57f06281c1fa02e7a85b13b54ce491d5fc363a640526b4fcbf306d1a641c76c1fcdbc6e40a96d36f2841b72c40a6f1c13c61ab30423811f5f922
7
- data.tar.gz: 770749e226208d837accc62737169c36f30e38a5fdcfc1e5997b68cf6cda4ca23906a4006a0470a030c035ee08c0d96f249a51e2080902aa296223b399ac997f
6
+ metadata.gz: db2d718db7eca5f9720efcd5e3d4cf7618364611b9d08ca8329da68abcdab1acee7a414dc3dae7c676aaaf8f68c8948c5a568fbb5b958a3b3a95790087039340
7
+ data.tar.gz: '08a70dac3579768cd8d3f7596e064a4ba16e2b8e8fa17b7263743669e5aab78b12bf70463324d853fca00126c7bbd516d0499f2d47aa0e790e9498ca314019f9'
@@ -8,5 +8,25 @@ module EacRailsBase0
8
8
  ["#{klass}.#{section}", klass.send(section)]
9
9
  end.to_h
10
10
  end
11
+
12
+ def send_test
13
+ @record = ::EacRailsBase0::EmailSendTest.new
14
+ end
15
+
16
+ def send_test_submit
17
+ @record = ::EacRailsBase0::EmailSendTest.new(send_test_submit_params)
18
+ if @record.save
19
+ flash[:success] = t('eac_rails_base0.mailer.send_test_successful', address: @record.address)
20
+ redirect_to action: :send_test
21
+ else
22
+ render :send_test
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def send_test_submit_params
29
+ params[::EacRailsBase0::EmailSendTest.model_name.param_key].permit(:alternative_address)
30
+ end
11
31
  end
12
32
  end
@@ -36,9 +36,12 @@ module EacRailsBase0
36
36
  end
37
37
 
38
38
  def mailer_main_menu_admin_entries
39
- {
40
- t('eac_rails_base0.mailer.info') => [main_app.info_eac_rails_base0_mailer_index_path]
41
- }
39
+ %w[info send_test].map do |action|
40
+ [
41
+ t("eac_rails_base0.mailer.#{action}"),
42
+ main_app.send("#{action}_eac_rails_base0_mailer_index_path")
43
+ ]
44
+ end.to_h
42
45
  end
43
46
 
44
47
  def eac_users_support_main_menu_admin_entries
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ class SendTestMailer < ::ApplicationMailer
5
+ def main
6
+ @subject = "#{t('eac_rails_base0.mailer.send_test')} [#{::Time.zone.now}]"
7
+ mail(to: params.fetch(:address), subject: @subject)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRailsBase0
6
+ class EmailSendTest < ::EacRailsUtils::Models::Tableless
7
+ attribute :alternative_address, ::String
8
+
9
+ validates :alternative_address, allow_blank: true, format: { with: URI::MailTo::EMAIL_REGEXP }
10
+ validates :logged_user_address, allow_blank: true, format: { with: URI::MailTo::EMAIL_REGEXP }
11
+ validates :address, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP }
12
+
13
+ def save
14
+ return false unless valid?
15
+
16
+ send_mail
17
+ true
18
+ end
19
+
20
+ def address
21
+ alternative_address.presence || logged_user_address.presence
22
+ end
23
+
24
+ def logged_user_address
25
+ ::EacUsersSupport::User.current_user.if_present(&:email)
26
+ end
27
+
28
+ def send_mail
29
+ ::EacRailsBase0::SendTestMailer.with(address: address).main.deliver_later
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ <h2><%= t('eac_rails_base0.mailer.send_test') %></h2>
2
+ <%= common_form(@record, url: send_test_eac_rails_base0_mailer_index_path,
3
+ method: :post, submit_label: t('eac_rails_base0.mailer.send_submit')) do |f| %>
4
+ <%= f.email_field :alternative_address %>
5
+ <% end %>
@@ -0,0 +1 @@
1
+ <h2><%= @subject %></h2>
@@ -2,6 +2,9 @@ en:
2
2
  eac_rails_base0:
3
3
  mailer:
4
4
  info: 'E-mail information'
5
+ send_submit: 'Enviar'
6
+ send_test: 'E-mail sending test'
7
+ send_test_successful: 'E-mail sended to %{address}'
5
8
  main_menu:
6
9
  admin:
7
10
  mailer: E-mail
@@ -29,6 +29,9 @@ pt-BR:
29
29
  unsetted: Não especificada
30
30
  mailer:
31
31
  info: 'Informações de e-mail'
32
+ send_submit: 'Enviar'
33
+ send_test: 'Envio de e-mail de teste'
34
+ send_test_successful: 'E-mail enviado para %{address}'
32
35
  main_menu:
33
36
  admin:
34
37
  aranha: Aranha
@@ -9,10 +9,13 @@ Rails.application.routes.draw do
9
9
  mount ::BrRailties::Engine => '/br_railties'
10
10
 
11
11
  namespace(:eac_rails_base0) do
12
- resources(:mailer, include: []) do
12
+ resources(:mailer, only: []) do
13
13
  collection do
14
14
  get :info
15
+ get :send_test
15
16
  end
16
17
  end
17
18
  end
19
+
20
+ post '/eac_rails_base0/mailer/send_test', to: 'eac_rails_base0/mailer#send_test_submit'
18
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsBase0
4
- VERSION = '0.46.0'
4
+ VERSION = '0.47.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.46.0
4
+ version: 0.47.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -581,7 +581,9 @@ files:
581
581
  - app/helpers/eac_rails_base0/app_version_helper.rb
582
582
  - app/helpers/eac_rails_base0/layout_helper.rb
583
583
  - app/helpers/eac_rails_base0/panel_default_helper.rb
584
+ - app/mailers/eac_rails_base0/send_test_mailer.rb
584
585
  - app/models/eac_rails_base0/application_record.rb
586
+ - app/tableless_models/eac_rails_base0/email_send_test.rb
585
587
  - app/uploaders/eac_rails_base0/default_file_uploader.rb
586
588
  - app/views/devise/confirmations/new.html.erb
587
589
  - app/views/devise/mailer/confirmation_instructions.html.erb
@@ -593,6 +595,8 @@ files:
593
595
  - app/views/devise/sessions/new.html.erb
594
596
  - app/views/devise/shared/_links.html.erb
595
597
  - app/views/eac_rails_base0/mailer/info.html.erb
598
+ - app/views/eac_rails_base0/mailer/send_test.html.erb
599
+ - app/views/eac_rails_base0/send_test_mailer/main.html.erb
596
600
  - app/views/layouts/eac_rails_base0/_flash.html.erb
597
601
  - app/views/layouts/eac_rails_base0/_main_menu.html.erb
598
602
  - app/views/layouts/eac_rails_base0/_navbar_user.html.erb