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?
birthdays_by_email = group_birthdays_by_email(birthdays)
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

View file

@ -1,22 +1,18 @@
# -*- coding: iso-8859-1 -*-
# -*- coding: utf-8 -*-
class UserMailer < ActionMailer::Base
default :from => "info@contact-o-rama.com"
# obsolete
def next_weeks_birthday_notification(email, 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
def upcoming_birthdays_notification(email, birthdays_2days, birthdays_7days)
@birthday_contacts_2days = birthdays_2days
@birthday_contacts_2days = birthdays_7days
def upcoming_birthdays_notification(email, birthdays, num_days)
return if birthdays.blank?
@birthday_contacts = birthdays
@num_days = num_days
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 >----------------------"
# @birthday_contacts = birthdays
# mail(:to => "contact-o-rama@gasbottle-county.eu", :subject => "Contact-o-Rama: Geburtstage in den nächsten 7 Tagen.")
# 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">
<tr>
<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>
</td>
</tr>
<% end %>
<% unless @birthday_contacts_2days.blank? %>
<h2>Übermorgen, <%= (Date.today + 2).to_s %>:
<ul>
<% @birthday_contacts_2days.each do |c| %>
<li><%= c.firstname %> <%= c.lastname %></li>
<table width="95%" border="0" cellspacing="0" cellpadding="25">
<tr>
<th bgcolor="#ed8200" width="100%" align="left">
<span style="color: #fff">Contact</span><span style="color: #fddfbf">-o-Rama:</span> <span style="color: #fff">anstehende Geburtstage</span>
</th>
</tr>
<tr>
<td>
<% if @num_days == 2 %>
<h2>Übermorgen (<%= (Date.today + @num_days).strftime("%-d.%m.") %>):</h2>
<% else %>
<h2>In einer Woche (am <%= (Date.today + @num_days).strftime("%-d.%m.") %>):</h2>
<% end %>
</ul>
<% end %>
<% unless @birthday_contacts_7days.blank? %>
<h2>In einer Woche, also am <%= (Date.today + 7).to_s %>:
<ul>
<% @birthday_contacts_7days.each do |c| %>
<li><%= c.firstname %> <%= c.lastname %></li>
<% end %>
</ul>
<% end %>
<% unless @birthday_contacts_2days.blank? && @birthday_contacts_7days.blank? %>
<hr>
<p>Passende Kontaktdaten gibt's vielleicht bei <a href="http://ocontact-o-rama.de">Contact-o-Rama</a>.</p>
</table>
<% end %>
<ul>
<% @birthday_contacts.each do |c| %>
<li><%= c.firstname %> <%= c.lastname %></li>
<% end %>
</ul>
<p>Passende Kontaktdaten gibt's vielleicht bei <a href="http://ocontact-o-rama.de">Contact-o-Rama</a>.</p>
</td>
</tr>
</table>