Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move newsletter subscription to backend #663

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//= require activestorage
//= require turbolinks
//= require cookieconsent.min
//= require newsletter_sign_up
//= require jscookie

$(document).on("turbolinks:load", function () {
Expand Down
42 changes: 0 additions & 42 deletions app/assets/javascripts/newsletter_sign_up.js

This file was deleted.

6 changes: 6 additions & 0 deletions app/controllers/notification_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def create
end
end

def newsletter_subscribe
email = params.permit(:email)[:email]
list_name = 'Návody.Digital'
SubscribeToNewsletterJob.perform_later(email, list_name) if email
end

def confirm
@subscriptions = NotificationSubscription.where(confirmation_token: params[:id])
@subscriptions.each do |subscription|
Expand Down
16 changes: 6 additions & 10 deletions app/views/components/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span class="sdn-footer__newsletter-heading"><label for="email-input">Novinky emailom</label> <small class="sdn-footer__newsletter-heading-tooltip">(raz mesačne)</small></span>
<div id="newsletter-success" style="display: none">
<p style="color: white;">
<strong>Na Váš e-mail sme poslali potvrdzovaciu správu.</strong>
<strong>Už len jeden krok. Na Váš e-mail príde potvrdzovacia správa.</strong>
<br>
Ďakujeme za Váš záujem.
</p>
Expand All @@ -15,16 +15,12 @@
<strong></strong>
</p>
</div>
<form id="newsletter-form" role="form" action="https://my.sendinblue.com/users/subscribe/js_id/29wti/id/4" data-action="https://my.sendinblue.com/users/subscribeembed/js_id/29wti/id/4" method="post">
<div class="govuk-form-group sdn-footer__newsletter-form-group">
<input type="hidden" name="js_id" id="js_id" value="29wti">
<input type="hidden" name="listid" id="listid" value="45">
<input type="hidden" name="from_url" id="from_url" value="yes">
<input type="hidden" name="hdn_email_txt" id="hdn_email_txt" value="">
<input type="email" name="email" id="email-input" required class="govuk-input sdn-footer__newsletter-input" autocomplete="email" placeholder="Zadajte emailovú adresu"/>
<button type="submit" class="govuk-button sdn-footer__newsletter-button">Prihlásiť</button>
<%= form_tag newsletter_subscribe_notification_subscription_groups_path, id: 'newsletter-form', remote: true do %>
<div class='govuk-form-group sdn-footer__newsletter-form-group'>
<%= email_field_tag :email, '', class: 'govuk-input sdn-footer__newsletter-input', placeholder: 'Zadajte emailovú adresu' %>
<%= submit_tag 'Prihlásiť', class: 'govuk-button sdn-footer__newsletter-button' %>
</div>
</form>
<% end %>
<span class="sdn-footer__newsletter-disclaimer">
Prihlásením dávam dobrovoľný súhlas OZ Slovensko.Digital na zasielanie bezplatného newslettera na mnou zadaný e-mail. Tento súhlas môžem kdykoľvek odvolať na <%= mail_to ENV['DEFAULT_EMAIL_FROM'], ENV['DEFAULT_EMAIL_FROM'], class: 'sdn-footer__link' %>. Oboznámil(a) som sa s informáciami v sekcii <%= link_to 'Ochrana osobných údajov', page_path('ochrana-osobnych-udajov'), class: 'sdn-footer__link' %>.</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$('#newsletter-form').hide();
$('#newsletter-success').show();
if ($('#newsletter-warning').is(':visible')) {
$('#newsletter-warning').hide();
}
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
end

resources :notification_subscription_groups, controller: :notification_subscriptions, path: 'notifikacie' do
post :newsletter_subscribe, on: :collection, path: 'novinky'
get :confirm, on: :member, path: 'potvrdit'
end

Expand Down
Loading