FogBugz #135: format mails to be sent for 2 and/or 7 days in advance.

This commit is contained in:
Roland Jesse 2012-07-24 22:26:27 +02:00
parent 1ce92adc3f
commit f8f8d94ee3
3 changed files with 32 additions and 43 deletions

View file

@ -31,7 +31,7 @@ class BirthdaysController < ApplicationController
unless birthdays.nil? unless birthdays.nil?
birthdays_by_email = group_birthdays_by_email(birthdays) birthdays_by_email = group_birthdays_by_email(birthdays)
birthdays_by_email.each do |email, bdays| birthdays_by_email.each do |email, bdays|
UserMailer.next_weeks_birthday_notification(email, bdays, num_days).deliver UserMailer.upcoming_birthdays_notification(email, bdays, num_days).deliver
end end
end end
end end

View file

@ -1,22 +1,18 @@
# -*- coding: iso-8859-1 -*- # -*- coding: utf-8 -*-
class UserMailer < ActionMailer::Base class UserMailer < ActionMailer::Base
default :from => "info@contact-o-rama.com" default :from => "info@contact-o-rama.com"
# obsolete
def next_weeks_birthday_notification(email, birthdays) def next_weeks_birthday_notification(email, birthdays)
@birthday_contacts = birthdays @birthday_contacts = birthdays
mail(:to => email, :subject => "Contact-o-Rama: Geburtstage in den nächsten 7 Tagen.") mail(:to => email, :subject => "Contact-o-Rama: Geburtstage in den nächsten 7 Tagen.")
end end
def upcoming_birthdays_notification(email, birthdays_2days, birthdays_7days) def upcoming_birthdays_notification(email, birthdays, num_days)
@birthday_contacts_2days = birthdays_2days return if birthdays.blank?
@birthday_contacts_2days = birthdays_7days
@birthday_contacts = birthdays
@num_days = num_days
mail(:to => email, :subject => "Contact-o-Rama: anstehende Geburtstage") mail(:to => email, :subject => "Contact-o-Rama: anstehende Geburtstage")
end end
# obsolete
# def next_weeks_birthday_notification(birthdays)
# logger.debug "----------------< we don't send no email, yet >----------------------"
# @birthday_contacts = birthdays
# mail(:to => "contact-o-rama@gasbottle-county.eu", :subject => "Contact-o-Rama: Geburtstage in den nächsten 7 Tagen.")
# end
end end

View file

@ -1,32 +1,25 @@
<% unless (@birthday_contacts_2days.blank? && @birthday_contacts_7days.blank?) %> <table width="95%" border="0" cellspacing="0" cellpadding="25">
<table width="95%" border="0" cellspacing="0" cellpadding="25"> <tr>
<tr> <th bgcolor="#ed8200" width="100%" align="left">
<th bgcolor="#ed8200" width="100%"> <span style="color: #fff">Contact</span><span style="color: #fddfbf">-o-Rama:</span> <span style="color: #fff">anstehende Geburtstage</span>
<span style="color: #fff">Contact</span><span style="color: #fddfbf">-o-Rama:</span> <span style="color: #fff">anstehende Geburtstage</span> </th>
</td> </tr>
</tr>
<% end %> <tr>
<td>
<% unless @birthday_contacts_2days.blank? %> <% if @num_days == 2 %>
<h2>Übermorgen, <%= (Date.today + 2).to_s %>: <h2>Übermorgen (<%= (Date.today + @num_days).strftime("%-d.%m.") %>):</h2>
<ul> <% else %>
<% @birthday_contacts_2days.each do |c| %> <h2>In einer Woche (am <%= (Date.today + @num_days).strftime("%-d.%m.") %>):</h2>
<li><%= c.firstname %> <%= c.lastname %></li>
<% end %> <% end %>
</ul>
<% end %>
<% unless @birthday_contacts_7days.blank? %> <ul>
<h2>In einer Woche, also am <%= (Date.today + 7).to_s %>: <% @birthday_contacts.each do |c| %>
<ul> <li><%= c.firstname %> <%= c.lastname %></li>
<% @birthday_contacts_7days.each do |c| %> <% end %>
<li><%= c.firstname %> <%= c.lastname %></li> </ul>
<% end %>
</ul> <p>Passende Kontaktdaten gibt's vielleicht bei <a href="http://ocontact-o-rama.de">Contact-o-Rama</a>.</p>
<% end %> </td>
</tr>
<% unless @birthday_contacts_2days.blank? && @birthday_contacts_7days.blank? %> </table>
<hr>
<p>Passende Kontaktdaten gibt's vielleicht bei <a href="http://ocontact-o-rama.de">Contact-o-Rama</a>.</p>
</table>
<% end %>