From 7ed4c0bf6fb7b51466ee80c7a7026ea67660030c Mon Sep 17 00:00:00 2001 From: Roland Jesse Date: Sat, 21 Jul 2012 23:39:26 +0200 Subject: [PATCH] FogBugz #135: Prepare the Mail-Output for the 2day / 7day birthday reminders. --- app/controllers/birthdays_controller.rb | 7 ++-- app/mailers/user_mailer.rb | 6 ++++ .../upcoming_birthdays_notification.html.erb | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 app/views/user_mailer/upcoming_birthdays_notification.html.erb diff --git a/app/controllers/birthdays_controller.rb b/app/controllers/birthdays_controller.rb index ada8769..4408dcc 100644 --- a/app/controllers/birthdays_controller.rb +++ b/app/controllers/birthdays_controller.rb @@ -12,10 +12,11 @@ class BirthdaysController < ApplicationController # crontab: # 30 3 * * * wget --post-data '' http://contact-o-rama.de/birthdays/do_mailing def do_mailing - birthdays = get_birthdays_next_7d - logger.debug "birthdays.nil? = " + birthdays.nil?.to_s + "......" + birthdays_2d = get_birthdays_next_2d + birthdays_7d = get_birthdays_next_7d + logger.debug "birthdays_2d.nil? = " + birthdays_2d.nil?.to_s + "......" unless birthdays.nil? - birthdays_by_email = group_birthdays_by_email(birthdays) + birthdays_by_email = group_birthdays_by_email(birthdays_7d) birthdays_by_email.each do |email, bdays| UserMailer.next_weeks_birthday_notification(email, bdays).deliver end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index bbb640c..f0dec74 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -7,6 +7,12 @@ class UserMailer < ActionMailer::Base mail(:to => email, :subject => "Contact-o-Rama: Geburtstage in den nächsten 7 Tagen.") end + def upcoming_birthdays_notification(email, birthdays_2days, birthdays_7days) + @birthday_contacts_2days = birthdays_2days + @birthday_contacts_2days = birthdays_7days + mail(:to => email, :subject => "Contact-o-Rama: anstehende Geburtstage") + end + # obsolete # def next_weeks_birthday_notification(birthdays) # logger.debug "----------------< we don't send no email, yet >----------------------" diff --git a/app/views/user_mailer/upcoming_birthdays_notification.html.erb b/app/views/user_mailer/upcoming_birthdays_notification.html.erb new file mode 100644 index 0000000..1e0c8ed --- /dev/null +++ b/app/views/user_mailer/upcoming_birthdays_notification.html.erb @@ -0,0 +1,32 @@ +<% unless (@birthday_contacts_2days.blank? && @birthday_contacts_7days.blank?) %> + + + +<% end %> + +<% unless @birthday_contacts_2days.blank? %> +

Übermorgen, <%= (Date.today + 2).to_s %>: + +<% end %> + +<% unless @birthday_contacts_7days.blank? %> +

In einer Woche, also am <%= (Date.today + 7).to_s %>: + +<% end %> + +<% unless @birthday_contacts_2days.blank? && @birthday_contacts_7days.blank? %> +
+

Passende Kontaktdaten gibt's vielleicht bei Contact-o-Rama.

+

+ Contact-o-Rama: anstehende Geburtstage + +
+<% end %>