Remove mailchimp and add sendy

This commit is contained in:
2017-04-18 14:41:35 +02:00
parent c65513fd0a
commit cb1bf34588
12 changed files with 9 additions and 79 deletions
+1 -1
View File
@@ -32,6 +32,6 @@ class ApplicationController < ActionController::Base
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :street, :city, :zip, :support, :language, :age_category, :unsubscribed])
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :street, :city, :zip, :support, :language, :age_category])
end
end
+7 -16
View File
@@ -10,7 +10,7 @@ class SupportersController < ApplicationController
@supporter.password = random_password = SecureRandom.hex(5)
if !input_to_fast? && @supporter.save
SupporterMailer.welcome_email(@supporter, random_password).deliver_now
mailchimp_registration
sendy_registraion
redirect_to thanks_path
else
flash.now[:danger] = input_to_fast? ? t('.timeout') : t('input_error')
@@ -24,20 +24,11 @@ class SupportersController < ApplicationController
params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :li_membership, :age_category, :city, :comments)
end
def mailchimp_registration
return unless Rails.env.production?
mailchimp = Mailchimp::API.new(ENV['MAILCHIMP_API'])
mailchimp.lists.subscribe(ENV['CH420_LIST_ID'], { 'email' => @supporter.email }, merge_vars, 'html', false)
end
def merge_vars
{ 'EMAIL' => @supporter.email,
'FNAME' => @supporter.first_name,
'LNAME' => @supporter.last_name,
'SUPPORT' => @supporter.support,
'MEMBERSHIP' => @supporter.li_membership.to_s,
'AGE' => @supporter.age_category,
'LANG' => @supporter.language,
'ZIP' => @supporter.zip }
# We use sendy for newsletters atm
def sendy_registraion
uri = URI('http://newsletter.cannabis-initiative.ch/subscribe')
Net::HTTP.post_form(uri, list: ENV["SENDY_LIST_#{I18n.locale.upcase}"],
email: @supporter.email,
name: "#{@supporter.first_name} #{@supporter.last_name}")
end
end
-1
View File
@@ -53,7 +53,6 @@ class Supporter
field :coordinates, type: Array
field :comments, type: String
field :language, type: String
field :unsubscribed, type: Boolean, default: false
field :duplicate, type: Boolean, default: false
validates :first_name, presence: true
-2
View File
@@ -23,8 +23,6 @@
dd == t("age_category.#{current_supporter.age_category}")
dt = Supporter.human_attribute_name(:language)
dd = t("languages.#{current_supporter.language}")
dt = Supporter.human_attribute_name(:unsubscribed)
dd = current_supporter.unsubscribed? ? t('shared.yes') : t('shared.no')
p
= link_to t('.edit'), edit_supporter_registration_path(), class: 'pull-right'
@@ -19,7 +19,6 @@
= f.input :support, as: :radio_buttons, collection: t('support_type').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first
= f.input :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first
= f.input :language, as: :radio_buttons, collection: t('languages').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first
= f.input :unsubscribed, as: :boolean
.form-actions
= f.button :submit, t("devise.registrations.edit.update"), class: 'btn btn-primary'
p = link_to t("devise.shared.links.back"), :back