Skip to content

Commit

Permalink
Merge branch 'master' into feat/personalised-ical-feed
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasPeters committed Sep 7, 2024
2 parents b5c6d20 + e581f4b commit 7ef1da6
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def create_invoice(csv, payments, payment_type, start_date, end_date = nil)
# Check on the name to allow previous years to be exported.

["", "8000", "#{ p.activity.name } - #{ p.member_id }", '0',
p.currency + payment.transaction_fee, ""]
p.currency, ""]
elsif p.activity.group.nil? ||
(!p.activity.group.nil? && p.activity.group.ledgernr.blank?)
["", "1302", "#{ p.activity.name } - #{ p.member_id }", p.activity.VAT,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create
end

# require valid password to confirm email
unless user.valid_password?(confirmation_params[:password])
unless user.valid_password?(confirmation_params[:password].to_s)
flash[:alert] = I18n.t('devise.failure.invalid_password')
redirect_to(user_confirmation_path(confirmation_token: confirmation_params[:confirmation_token]))
return
Expand Down
6 changes: 4 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def mail(recipient, sender, subject, html, text, attachment = nil)
raise(ArgumentError) if html.blank? && text.blank?

if ENV['MAILGUN_DOMAIN'].blank? || ENV['MAILGUN_TOKEN'].blank?
Rails.logger.error("mailgun credentials not send, cannot send email")
Rails.logger.error("mailgun credentials not set, cannot send email. Printing email instead.")
Rails.logger.info(html)
return
end

Expand All @@ -47,7 +48,8 @@ def mails(recipient, sender, subject, html, text, attachment = nil)
raise(ArgumentError) if (html.blank? && text.blank?) || recipient.blank?

if ENV['MAILGUN_DOMAIN'].blank? || ENV['MAILGUN_TOKEN'].blank?
Rails.logger.debug("mailgun credentials not send, cannot send email")
Rails.logger.debug("mailgun credentials not set, cannot send email. Printing email instead.")
Rails.logger.info(html)
return
end

Expand Down
53 changes: 43 additions & 10 deletions app/mailers/mailings/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,47 @@ class Devise < ApplicationMailer
include ::Devise::Controllers::UrlHelpers

def confirmation_instructions(record, token, _opts = {})
Rails.logger.debug(confirmation_url(record, confirmation_token: token)) if Rails.env.development?
url = confirmation_url(record, confirmation_token: token)
# FIXME: confirmation_url might occassionaly return an url to the activation page. We don't know why
url = url.sub("/activate", "/confirmation")

if Rails.env.development?
Rails.logger.debug { "Sending confirmation instructions to #{ record.credentials.name } <#{ record.unconfirmed_email }> with activation URL #{ url }" }
end

html = render_to_string(locals: {
name: record.credentials.name,
confirmation_url: confirmation_url(record, confirmation_token: token),
confirmation_url: url,
subject: "#{ I18n.t('association_name') } | #{ I18n.t('mailings.devise.confirmation_instructions.confirm_email') }"
})

text = <<~PLAINTEXT
#{ I18n.t('mailings.greeting') } #{ record.credentials.name },
#{ I18n.t('mailings.devise.confirmation_instructions.link_instructions', confirm_link: confirmation_url(record, confirmation_token: token)) }
#{ I18n.t('mailings.devise.confirmation_instructions.link_instructions', confirm_link: url) }
#{ I18n.t('mailings.best_regards') }
#{ I18n.t('mailings.signature') }
PLAINTEXT

return mail(record.unconfirmed_email ||= record.email, nil, I18n.t('mailings.devise.confirmation_instructions.activate_account'), html, text)
mail(record.unconfirmed_email ||= record.email, nil, I18n.t('mailings.devise.confirmation_instructions.activate_account'), html, text)
end

def activation_instructions(record, token, _opts = {})
url = new_member_confirmation_url(confirmation_token: token)
Rails.logger.debug(url) if Rails.env.development?
# FIXME: confirmation_url might occassionaly return an url to the activation page. We don't know why
url = url.sub("/confirmation", "/activate")

if Rails.env.development?
Rails.logger.debug { "Sending activation instructions to #{ record.credentials.name } <#{ record.email }> with activation URL #{ url }" }
end

html = render_to_string(locals: {
name: record.credentials.first_name,
activation_url: url,
subject: "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }"
subject: "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }",
whatsapp_promo_link: whatsapp_promo_link
})

text = <<~MARKDOWN
Expand All @@ -46,9 +58,12 @@ def activation_instructions(record, token, _opts = {})
#{ I18n.t('mailings.devise.activation_instructions.about_sticky') }
#{ I18n.t('mailings.devise.activation_instructions.activity_updates_html',
facebook_group_link_start: '<a href="https://www.facebook.com/groups/814759978565158">'.html_safe,
facebook_page_link_start: '<a href="https://www.facebook.com/stickyutrecht">'.html_safe,
instagram_page_link_start: '<a href="https://www.instagram.com/stickyutrecht/">'.html_safe,
linkedin_page_link_start: '<a href="https://www.linkedin.com/company/studievereniging-sticky">'.html_safe,
sticky_site_link_start: '<a href="https://svsticky.nl">'.html_safe,
# rubocop:disable Rails/OutputSafety
whatsapp_promo_link_start: "<a href=\"#{ whatsapp_promo_link }\">".html_safe,
# rubocop:enable Rails/OutputSafety
link_end: '</a>'.html_safe) }
## #{ I18n.t('mailings.devise.activation_instructions.corner_stones.education.name') }
Expand All @@ -65,7 +80,14 @@ def activation_instructions(record, token, _opts = {})
#{ I18n.t('mailings.devise.activation_instructions.corner_stones.sociability.description') }
## #{ I18n.t('mailings.devise.activation_instructions.and_now', url: url) }
#{ I18n.t('mailings.devise.activation_instructions.wrap_up', url: url) }
#{ I18n.t(
'mailings.devise.activation_instructions.wrap_up_html',
#{' '}
url: url,
#{' '}
koala_link_start: '<a href="https://koala.svsticky.nl/">'.html_safe,
link_end: '</a>'.html_safe
) }
#{ I18n.t('mailings.devise.activation_instructions.account_activation_link', url: url) }
Expand All @@ -74,7 +96,18 @@ def activation_instructions(record, token, _opts = {})
#{ I18n.t('mailings.signature') }
MARKDOWN

return mail(record.email, nil, "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }", html, text)
mail(record.email, nil, "#{ I18n.t('mailings.devise.activation_instructions.welcome') } | #{ I18n.t('mailings.devise.confirmation_instructions.activate_account') }", html, text)
end

private

def whatsapp_promo_link
if I18n.locale == :en
"https://svsticky.nl/promochannel"
else
# Fallback is NL
"https://svsticky.nl/promokanaal"
end
end

def reset_password_instructions(record, token, _opts = {})
Expand Down
6 changes: 3 additions & 3 deletions app/views/devise/confirmations/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- if flash[:alert]
.alert.alert-danger
%span
%span.dark:text-white
= flash[:alert]

- if flash[:notice]
Expand All @@ -18,7 +18,7 @@
= flash[:notice]

%fieldset
%h4
%h4.dark:text-white
= I18n.t :activate, scope: 'devise.confirmations'

.form-group
Expand Down Expand Up @@ -48,7 +48,7 @@
-# i18n todo
.row
.text-center
.text-center.dark:text-white
= link_to (I18n.t 'devise.registrations.password_recovery'), new_user_password_path
|
= link_to (I18n.t 'devise.registrations.login'), new_user_session_path
2 changes: 1 addition & 1 deletion app/views/devise/confirmations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
= flash[:notice]

%fieldset
%h4= I18n.t 'devise.confirmations.new.instruction'
%h4.dark:text-white= I18n.t 'devise.confirmations.new.instruction'

.form-group
.input-group-prepend
Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/confirmations/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
= flash[:notice]

%fieldset
%h4= I18n.t 'devise.confirmations.new.instruction'
%h4.dark:text-white= I18n.t 'devise.confirmations.new.instruction'

.form-group
.input-group
Expand All @@ -39,7 +39,7 @@
= f.submit t('devise.confirmations.new.submit'), :class => 'btn btn-primary btn-block'

.row
.text-center
.text-center.dark:text-white
= link_to (I18n.t 'devise.registrations.login'), new_user_session_path
|
= link_to (I18n.t 'devise.registrations.sign_up'), new_registration_path
4 changes: 2 additions & 2 deletions app/views/layouts/doorkeeper.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

.shadow.px-10.py-4.rounded-md.bg-white.mx-auto.dark:bg-gray-800.dark

- if current_user.present?
%h2.mt-2
- if current_user.present? and current_user.credentials.first_name?
%h2.mt-2.dark:text-white
= I18n.t('layouts.doorkeeper.hi')
%b= current_user.credentials.first_name
= I18n.t('layouts.doorkeeper.identity_confirmation', name: current_user.credentials.name)
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/mailer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
.content{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;"}
%table.main{:bgcolor => "#fff", :cellpadding => "0", :cellspacing => "0", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;", :width => "100%"}
%tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"}
%td.alert.alert-warning{:align => "center", :bgcolor => "#CE2029", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #CE2029; margin: 0; padding: 20px;", :valign => "top"}
%td.alert.alert-warning{:align => "center", :bgcolor => "#61518f", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #61518f; margin: 0; padding: 20px;", :valign => "top"}
= I18n.t('association_name')

%tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"}
Expand Down
17 changes: 10 additions & 7 deletions app/views/mailings/devise/activation_instructions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
= t('mailings.devise.activation_instructions.about_sticky')

= t('mailings.devise.activation_instructions.activity_updates_html',
facebook_group_link_start: raw("<a href=\"https://www.facebook.com/groups/814759978565158\">"),
facebook_page_link_start: raw("<a href=\"https://www.facebook.com/stickyutrecht\">"),
sticky_site_link_start: raw("<a href=\"https://svsticky.nl\">"),
link_end: raw("</a>"))
instagram_page_link_start: '<a href="https://www.instagram.com/stickyutrecht/">'.html_safe,
linkedin_page_link_start: '<a href="https://www.linkedin.com/company/studievereniging-sticky">'.html_safe,
sticky_site_link_start: '<a href="https://svsticky.nl">'.html_safe,
whatsapp_promo_link_start: "<a href=\"#{whatsapp_promo_link}\">".html_safe,
link_end: '</a>'.html_safe)

%tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"}
%td.content-block{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;", :valign => "top"}
Expand All @@ -32,7 +33,7 @@
%h2
= t('mailings.devise.activation_instructions.corner_stones.business.name')
= t('mailings.devise.activation_instructions.corner_stones.business.description_html',
job_offer_page_link_start: raw('<a href="https://svsticky.nl/partners/vacatures">'),
job_offer_page_link_start: raw('<a href="https://svsticky.nl/carriere/vacatures">'),
link_end: raw("</a>"))

%h2
Expand All @@ -41,12 +42,14 @@

%h2
= t('mailings.devise.activation_instructions.and_now')
= t('mailings.devise.activation_instructions.wrap_up')
= t('mailings.devise.activation_instructions.wrap_up_html',
koala_link_start: raw('<a href="https://koala.svsticky.nl">'),
link_end: raw('</a>'))

= t('mailings.devise.activation_instructions.account_activation_instructions')
%tr{:style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"}
%td.content-block.aligncenter{:align => "center", :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;", :valign => "top"}
%a.btn-primary{:href => activation_url, :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; background-color: #348eda; margin: 0; border-color: #348eda; border-style: solid; border-width: 10px 20px;"}
%a.btn-primary{:href => activation_url, :style => "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; background-color: #197052; margin: 0; border-color: #197052; border-style: solid; border-width: 10px 20px;"}
= t('mailings.devise.activation_instructions.activate_account')


Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ en:
atec: MSc Technical Artificial Intelligence
ckem: MSc Content & Knowledge Engineering
cosc: MSc Computing Science
ds: MSc Data Science
gmte: MSc Game and Media Technology
gt: BSc Gametechnology
hci: MSc Human Computer Interaction
Expand Down
8 changes: 4 additions & 4 deletions config/locales/mailings.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ en:
account_activation_instructions: Activate your account by clicking the button below
account_activation_link: Activate your account for our member system by going to %{url}.
activate_account: Activate account
activity_updates_html: 'Do you always want to stay informed about these activities? Join the %{facebook_group_link_start} Sticky-members Facebook group %{link_end} and like %{facebook_page_link_start} our page %{link_end}! Aside from that, you can find all information that you could ever want on our website: %{sticky_site_link_start} svsticky.nl %{link_end}. You can also send a WhatsApp message to the Sticky Phone (+31617695025) saying "Hi + [your name], English" after saving it in your contacts. Then you’ll automatically be updated about future events!'
activity_updates_html: 'Do you always want to stay informed about these activities? Follow us on %{instagram_page_link_start} the Sticky-members Instagram%{link_end} and on %{linkedin_page_link_start} LinkedId%{link_end}! Aside from that, you can find all information that you could ever want on our website: %{sticky_site_link_start} svsticky.nl%{link_end}. You can also join our %{whatsapp_promo_link_start} WhatsApp promotion channel%{link_end} to be notified about upcoming activities!'
and_now: And now?
corner_stones:
business:
description_html: To give you the best possible picture of the different companies you could start working for in the future, we organise varying lectures, workshops, in-house days and drinks with these companies. These activities offer besides information about the company in question, also a nice opportunity to learn something extra or something completely new. Are you looking for a study-related job? You can find these at %{job_offer_page_link_start} svsticky.nl/partners/vacatures %{link_end}.
description_html: To give you the best possible picture of the different companies you could start working for in the future, we organise varying lectures, workshops, in-house days and drinks with these companies. These activities offer besides information about the company in question, also a nice opportunity to learn something extra or something completely new. Are you looking for a study-related job? You can find these at %{job_offer_page_link_start} svsticky.nl/carriere/vacatures%{link_end}.
name: Business
education:
description_html: We organise helper days, workshops and information meetings to support you with your study. The Commissioner for Education is your point of contact for anything to do with education and it's quality. You can conveniently buy the books you need and have them delivered at your home at the %{books_page_link_start} svsticky.nl/boeken %{link_end}!
description_html: We organise helper days, workshops and information meetings to support you with your study. The Commissioner for Education is your point of contact for anything to do with education and it's quality. You can conveniently buy the books you need and have them delivered at your home at the %{books_page_link_start} svsticky.nl/boeken%{link_end}!
name: Education
sociability:
description: Besides the study- and carrier-related activities stated above, we also organise many simply sociable activities, like the weekly drinks!
name: Sociability
reception_justification: You are receiving this e-mail, because you signed up for our mighty beautiful study association! At the end of this mail you will find a button to activate your account in our members portal. You could also skip this gorgeous introduction talk en scroll down immediately. We won't see that anyway (or will we?).
see_you_soon: See you soon!
welcome: Welcome to Sticky!
wrap_up: Curious about which activities we will soon organize? You can find more information in our member portal and you can enroll there too! In this member portal you can also edit your profile and upgrade your credit for snacks and drinks.
wrap_up_html: Curious about which activities we will soon organize? You can find more information in our member portal, %{koala_link_start} Koala%{link_end}, and you can enroll there too! In this member portal you can also edit your profile.
changed_instructions:
changed_email: Emailaddress changed
inform_change_text: Your emailaddress is changed to %{new_email}. Please contact us as soon as possible (by replying to this email) if this change was not done by you.
Expand Down
Loading

0 comments on commit 7ef1da6

Please sign in to comment.