alchemy_kono_mailup 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +26 -0
- data/app/assets/images/alchemy_kono_mailup/.keep +0 -0
- data/app/assets/javascripts/alchemy_kono_mailup/application.js +13 -0
- data/app/assets/stylesheets/alchemy_kono_mailup/application.css +15 -0
- data/app/controllers/alchemy/admin/essence_mailup_lists_controller.rb +22 -0
- data/app/controllers/alchemy_kono_mailup/admin/base_controller.rb +5 -0
- data/app/controllers/alchemy_kono_mailup/admin/mailup_configs_controller.rb +13 -0
- data/app/controllers/alchemy_kono_mailup/admin/tokens_controller.rb +16 -0
- data/app/helpers/alchemy_kono_mailup/application_helper.rb +22 -0
- data/app/models/alchemy/essence_mailup_list.rb +4 -0
- data/app/models/alchemy_kono_mailup/base_subscription_form.rb +11 -0
- data/app/models/alchemy_kono_mailup/mailup_config.rb +6 -0
- data/app/views/alchemy/essences/_essence_mailup_list_editor.html.erb +11 -0
- data/app/views/alchemy/essences/_essence_mailup_list_view.html.erb +3 -0
- data/app/views/alchemy_kono_mailup/admin/mailup_configs/main.html.erb +19 -0
- data/app/views/layouts/alchemy_kono_mailup/application.html.erb +14 -0
- data/config/initializers/alchemy.rb +26 -0
- data/config/initializers/kono_mailup.rb +9 -0
- data/config/routes.rb +21 -0
- data/db/migrate/20171127105007_create_alchemy_kono_mailup_alchemy_essence_mailup_lists.rb +13 -0
- data/lib/alchemy_kono_mailup.rb +21 -0
- data/lib/alchemy_kono_mailup/ability.rb +58 -0
- data/lib/alchemy_kono_mailup/engine.rb +22 -0
- data/lib/alchemy_kono_mailup/version.rb +3 -0
- data/lib/generators/alchemy_kono_mailup/install/USAGE +9 -0
- data/lib/generators/alchemy_kono_mailup/install/install_generator.rb +20 -0
- data/lib/generators/alchemy_kono_mailup/install/templates/initializers.rb +4 -0
- data/lib/generators/alchemy_kono_mailup/subscription_form/USAGE +7 -0
- data/lib/generators/alchemy_kono_mailup/subscription_form/subscription_form_generator.rb +75 -0
- data/lib/generators/alchemy_kono_mailup/subscription_form/templates/form_controller.rb.erb +70 -0
- data/lib/generators/alchemy_kono_mailup/subscription_form/templates/form_model.rb.erb +5 -0
- data/lib/generators/alchemy_kono_mailup/subscription_form/templates/form_view.html.erb +29 -0
- data/lib/tasks/alchemy_kono_mailup_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/alchemy/elements/article.scss +30 -0
- data/spec/dummy/app/assets/stylesheets/application.css +16 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/mailup_subscription_forms_controller.rb +73 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/mailup_subscription_form.rb +7 -0
- data/spec/dummy/app/views/alchemy/elements/_article_editor.html.erb +5 -0
- data/spec/dummy/app/views/alchemy/elements/_article_view.html.erb +7 -0
- data/spec/dummy/app/views/alchemy/elements/_mailup_subscription_editor.html.erb +3 -0
- data/spec/dummy/app/views/alchemy/elements/_mailup_subscription_view.html.erb +27 -0
- data/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/alchemy/config.yml +194 -0
- data/spec/dummy/config/alchemy/elements.yml +27 -0
- data/spec/dummy/config/alchemy/page_layouts.yml +8 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/devise.rb +265 -0
- data/spec/dummy/config/initializers/dragonfly.rb +35 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/kono_mailup.rb +13 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/alchemy.de.yml +31 -0
- data/spec/dummy/config/locales/alchemy.en.yml +31 -0
- data/spec/dummy/config/locales/alchemy.es.yml +31 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +9 -0
- data/spec/dummy/config/secrets_example.yml +24 -0
- data/spec/dummy/db/migrate/20171124145455_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +36 -0
- data/spec/dummy/db/migrate/20171124145456_add_missing_unique_indices.acts_as_taggable_on_engine.rb +26 -0
- data/spec/dummy/db/migrate/20171124145457_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +20 -0
- data/spec/dummy/db/migrate/20171124145458_add_missing_taggable_index.acts_as_taggable_on_engine.rb +15 -0
- data/spec/dummy/db/migrate/20171124145459_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +15 -0
- data/spec/dummy/db/migrate/20171124145460_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +23 -0
- data/spec/dummy/db/migrate/20171124145461_alchemy_two_point_six.alchemy.rb +379 -0
- data/spec/dummy/db/migrate/20171124145462_remove_do_not_index_from_alchemy_essence_texts.alchemy.rb +6 -0
- data/spec/dummy/db/migrate/20171124145463_remove_do_not_index_from_alchemy_essence_richtexts.alchemy.rb +6 -0
- data/spec/dummy/db/migrate/20171124145464_add_published_at_to_alchemy_pages.alchemy.rb +6 -0
- data/spec/dummy/db/migrate/20171124145465_add_parent_element_id_to_alchemy_elements.alchemy.rb +7 -0
- data/spec/dummy/db/migrate/20171124145466_add_link_text_to_alchemy_essence_files.alchemy.rb +6 -0
- data/spec/dummy/db/migrate/20171124145467_add_locale_to_alchemy_languages.alchemy.rb +8 -0
- data/spec/dummy/db/migrate/20171124145468_add_timebased_publishing_columns_to_pages.alchemy.rb +33 -0
- data/spec/dummy/db/migrate/20171124145469_add_image_file_format_to_alchemy_pictures.alchemy.rb +10 -0
- data/spec/dummy/db/migrate/20171124145470_change_alchemy_pages_locked_to_locked_at.alchemy.rb +23 -0
- data/spec/dummy/db/migrate/20171124145471_add_index_to_alchemy_pages_rgt.alchemy.rb +10 -0
- data/spec/dummy/db/migrate/20171124145472_add_foreign_key_indices_and_null_constraints.alchemy.rb +21 -0
- data/spec/dummy/db/migrate/20171124145473_add_foreign_keys.alchemy.rb +28 -0
- data/spec/dummy/db/migrate/20171124145474_create_alchemy_users.alchemy_devise.rb +34 -0
- data/spec/dummy/db/migrate/20171124145475_add_alchemy_roles_to_alchemy_users.alchemy_devise.rb +23 -0
- data/spec/dummy/db/migrate/20171124145476_add_indexes_to_alchemy_users.alchemy_devise.rb +12 -0
- data/spec/dummy/db/migrate/20171124145629_create_settings.kono_mailup.rb +18 -0
- data/spec/dummy/db/migrate/20171127115017_create_alchemy_kono_mailup_alchemy_essence_mailup_lists.alchemy_kono_mailup.rb +14 -0
- data/spec/dummy/db/schema.rb +351 -0
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/vendor/assets/javascripts/alchemy/admin/all.js +11 -0
- data/spec/dummy/vendor/assets/stylesheets/alchemy/admin/all.css +12 -0
- data/spec/models/alchemy_kono_mailup/alchemy/essence_mailup_list_spec.rb +7 -0
- metadata +393 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module AlchemyKonoMailup
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc "Creates Initializers"
|
7
|
+
def copy_initializer
|
8
|
+
|
9
|
+
route 'mount AlchemyKonoMailup::Engine => "/"'
|
10
|
+
|
11
|
+
generate 'kono_mailup:install --disable_routes'
|
12
|
+
|
13
|
+
rake 'alchemy_kono_mailup:install:migrations'
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module AlchemyKonoMailup
|
2
|
+
module Generators
|
3
|
+
class SubscriptionFormGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
argument :subscription_model, desc: 'Name of the FormModel', required: true, type: :string
|
7
|
+
class_option :form_fields, type: :string, required: false, desc: 'List of fields,columns separated with format custom_field_name:mailup_field_id,custom_field_name2:mailup_field_id2 '
|
8
|
+
|
9
|
+
desc "Create Form"
|
10
|
+
|
11
|
+
def copy_initializer
|
12
|
+
|
13
|
+
@model_name = subscription_model.classify
|
14
|
+
@controller_name = "#{@model_name.pluralize}Controller"
|
15
|
+
|
16
|
+
@custom_fields = options[:form_fields].split(',').
|
17
|
+
select { |f| f.match(/^.*:.*$/) }.
|
18
|
+
collect { |f| d=f.split(':'); { mailup_id: d[1].to_i, name: d[0] } }
|
19
|
+
|
20
|
+
|
21
|
+
form_name = subscription_model.underscore
|
22
|
+
|
23
|
+
#controllo se già presente un form con lo stesso nome
|
24
|
+
elements_path = Rails.root.join('config', 'alchemy', 'elements.yml')
|
25
|
+
puts File.foreach(elements_path).grep(/#{form_name}/).inspect
|
26
|
+
if File.foreach(elements_path).grep(/#{form_name}/).empty?
|
27
|
+
|
28
|
+
|
29
|
+
append_to_file 'config/alchemy/elements.yml' do
|
30
|
+
<<-YML
|
31
|
+
|
32
|
+
- name: #{form_name}
|
33
|
+
hint: true
|
34
|
+
unique: true
|
35
|
+
contents:
|
36
|
+
- name: newsletter_list
|
37
|
+
type: EssenceMailupList
|
38
|
+
validate:
|
39
|
+
- presence
|
40
|
+
|
41
|
+
YML
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
generate 'alchemy:elements --skip'
|
46
|
+
|
47
|
+
@routes_route = "#{@model_name.underscore}_create"
|
48
|
+
route "post '#{subscription_model}',to:'#{@model_name.pluralize.underscore}#create', as: :#{@routes_route}"
|
49
|
+
|
50
|
+
template "form_model.rb.erb", "app/models/#{@model_name.underscore}.rb"
|
51
|
+
template "form_controller.rb.erb", "app/controllers/#{@controller_name.underscore}.rb"
|
52
|
+
# cancella prima la view creata automaticamente
|
53
|
+
FileUtils.rm(Rails.root.join('app','views','alchemy','elements',"_#{form_name}_view.html.erb"))
|
54
|
+
template "form_view.html.erb", "app/views/alchemy/elements/_#{form_name}_view.html.erb"
|
55
|
+
|
56
|
+
|
57
|
+
say "Remember to add '#{form_name}' to the elements list of the desidered page layout \n"
|
58
|
+
|
59
|
+
|
60
|
+
else
|
61
|
+
say "Element with same name presente, change the name with --form_name=AnotherElementFormName"
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def symbolic_field_list
|
68
|
+
@custom_fields.collect{|f| ":#{f[:name]}"}
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class <%=@controller_name%> < Alchemy::BaseController
|
2
|
+
|
3
|
+
def create
|
4
|
+
|
5
|
+
@obj = <%=@model_name%>.new(clear_params)
|
6
|
+
@element = Alchemy::Element.find_by(id: @obj.element_id)
|
7
|
+
if @element.nil?
|
8
|
+
raise ActiveRecord::RecordNotFound, "Contact form id not found. Please pass the :element_id in a hidden field. Example: <%%= f.hidden_field :element_id, value: element.id %> "
|
9
|
+
end
|
10
|
+
@page = @element.page
|
11
|
+
@root_page = @page.get_language_root
|
12
|
+
|
13
|
+
if @obj.valid?
|
14
|
+
|
15
|
+
dati_inviati = {
|
16
|
+
Email: @obj.email,
|
17
|
+
Fields: [
|
18
|
+
<%-@custom_fields.each_with_index do |f,i| %>
|
19
|
+
{
|
20
|
+
Value: @obj.<%=f[:name]%>,
|
21
|
+
Id: <%=f[:mailup_id]%>
|
22
|
+
} <%= i==@custom_fields.length-1 ? '':',' %>
|
23
|
+
<%-end%>
|
24
|
+
]
|
25
|
+
}
|
26
|
+
|
27
|
+
Rails.logger.debug { dati_inviati.inspect }
|
28
|
+
|
29
|
+
|
30
|
+
begin
|
31
|
+
ris = KonoMailup::API.new(debug: true).console.
|
32
|
+
list(@obj.newsletter_list).
|
33
|
+
import_recipient(dati_inviati)
|
34
|
+
|
35
|
+
|
36
|
+
Rails.logger.info { "Nuova subscription: #{ris}" }
|
37
|
+
|
38
|
+
if (ris>0)
|
39
|
+
@obj=nil
|
40
|
+
redirect_to root_path, notice: 'Subscription Confirmed'
|
41
|
+
else
|
42
|
+
problems_with_api
|
43
|
+
end
|
44
|
+
rescue Exception => e
|
45
|
+
problems_with_api(error: e)
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
render template: 'alchemy/pages/show'
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def clear_params
|
56
|
+
params.require(<%= ":#{@model_name.underscore}" %>).
|
57
|
+
permit(:email,
|
58
|
+
:newsletter_list,
|
59
|
+
:element_id <%= symbolic_field_list.empty? ? '':",#{ symbolic_field_list.join(',') }" %>
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def problems_with_api(error: nil)
|
64
|
+
Rails.logger.warn { "Mailup API Problems #{error.try(:message)}" }
|
65
|
+
|
66
|
+
@obj.errors.add(:base, :problems_with_api)
|
67
|
+
render template: 'alchemy/pages/show'
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%%- cache(element) do -%>
|
2
|
+
|
3
|
+
<%%= element_view_for(element) do |el| -%>
|
4
|
+
|
5
|
+
<%% @obj ||= <%= @model_name %>.new(
|
6
|
+
newsletter_list: element.content_by_name(:newsletter_list).ingredient,
|
7
|
+
element_id: element.id
|
8
|
+
) %>
|
9
|
+
|
10
|
+
<%%= form_for(@obj, url: main_app.<%= "#{@routes_route}_path" %>) do |f| %>
|
11
|
+
|
12
|
+
<div><%%= f.label :email %><%%= f.text_field :email %></div>
|
13
|
+
|
14
|
+
<% symbolic_field_list.each do |f| %>
|
15
|
+
<div><%%= f.label <%=f%> %> <%%= f.text_field <%=f%> %></div>
|
16
|
+
<%end%>
|
17
|
+
|
18
|
+
<%%= f.hidden_field :newsletter_list %>
|
19
|
+
<%%= f.hidden_field :element_id %>
|
20
|
+
|
21
|
+
<div>
|
22
|
+
<%%= f.submit :subscribe %>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<%% end %>
|
26
|
+
|
27
|
+
|
28
|
+
<%%- end -%>
|
29
|
+
<%%- end -%>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,30 @@
|
|
1
|
+
article {
|
2
|
+
width: 50%;
|
3
|
+
font: 16px/20px Helvetica, Arial, sans-serif;
|
4
|
+
color: #333;
|
5
|
+
margin: 1em auto;
|
6
|
+
padding: 0.5em 1em;
|
7
|
+
background: #f4f4f4;
|
8
|
+
|
9
|
+
h2 {
|
10
|
+
font-size: 24px;
|
11
|
+
line-height: 1.25;
|
12
|
+
font-weight: bold;
|
13
|
+
}
|
14
|
+
|
15
|
+
a {
|
16
|
+
color: #5588D3;
|
17
|
+
}
|
18
|
+
|
19
|
+
img {
|
20
|
+
max-width: 100%;
|
21
|
+
}
|
22
|
+
|
23
|
+
figure {
|
24
|
+
margin: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
figcaption {
|
28
|
+
font-size: 14px;
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*= require_tree ./alchemy/elements
|
16
|
+
*/
|
File without changes
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class MailupSubscriptionFormsController < Alchemy::BaseController
|
2
|
+
|
3
|
+
def create
|
4
|
+
|
5
|
+
@mailup_subscription = MailupSubscriptionForm.new(clear_params)
|
6
|
+
@element = Alchemy::Element.find_by(id: @mailup_subscription.element_id)
|
7
|
+
if @element.nil?
|
8
|
+
raise ActiveRecord::RecordNotFound, "Contact form id not found. Please pass the :contact_form_id in a hidden field. Example: <%= f.hidden_field :contact_form_id, value: element.id %>"
|
9
|
+
end
|
10
|
+
@page = @element.page
|
11
|
+
@root_page = @page.get_language_root
|
12
|
+
|
13
|
+
if @mailup_subscription.valid?
|
14
|
+
|
15
|
+
dati_inviati = {
|
16
|
+
Email: @mailup_subscription.email,
|
17
|
+
Fields: [
|
18
|
+
{
|
19
|
+
Value: @mailup_subscription.first_name,
|
20
|
+
Id: 1
|
21
|
+
},
|
22
|
+
{
|
23
|
+
Value: @mailup_subscription.last_name,
|
24
|
+
Id: 2
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
28
|
+
|
29
|
+
Rails.logger.debug { dati_inviati.inspect }
|
30
|
+
|
31
|
+
|
32
|
+
begin
|
33
|
+
ris = KonoMailup::API.new(debug: true).console.
|
34
|
+
list(@mailup_subscription.newsletter_list).
|
35
|
+
import_recipient(dati_inviati)
|
36
|
+
|
37
|
+
|
38
|
+
Rails.logger.info { "Nuova subscription: #{ris}" }
|
39
|
+
|
40
|
+
if (ris>0)
|
41
|
+
@mailup_subscription=nil
|
42
|
+
redirect_to root_path, notice: 'Subscription Confirmed'
|
43
|
+
else
|
44
|
+
problems_with_api
|
45
|
+
end
|
46
|
+
rescue Exception => e
|
47
|
+
problems_with_api(error: e)
|
48
|
+
end
|
49
|
+
|
50
|
+
else
|
51
|
+
render template: 'alchemy/pages/show'
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def clear_params
|
58
|
+
params.require(:mailup_subscription_form).permit(:email,
|
59
|
+
:newsletter_list,
|
60
|
+
:element_id,
|
61
|
+
:first_name,
|
62
|
+
:last_name
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
def problems_with_api(error: nil)
|
67
|
+
Rails.logger.warn { "Mailup API Problems #{error.try(:message)}" }
|
68
|
+
|
69
|
+
@mailup_subscription.errors.add(:base, :problems_with_api)
|
70
|
+
render template: 'alchemy/pages/show'
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
File without changes
|
File without changes
|
File without changes
|