Skip to content

Commit

Permalink
Adding urgent tasks to daily reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Villalba committed Sep 7, 2011
1 parent 9d0a092 commit 3a84784
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/helpers/emailer_helper.rb
Expand Up @@ -107,7 +107,7 @@ def task_status_style(task)
styles.join(";")
end

def task_due_on_style(task, options)
def task_due_on_style(task, options={})
styles = []
styles << "font-size: 12px"
styles << "display: table-cell"
Expand Down
3 changes: 2 additions & 1 deletion app/models/task/scopes.rb
Expand Up @@ -10,6 +10,7 @@ class Task
joins(:assigned => :project).where(:people => {:user_id => user.id}).where(:projects => {:archived => false})
}

scope :urgent, :conditions => { :urgent => true }, :include => [:project, :task_list, :assigned]
scope :due_sooner_than_two_weeks, lambda {
{ :conditions => ['tasks.due_on < ?', 2.weeks.from_now] }
}
Expand All @@ -32,4 +33,4 @@ class Task
scope :from_pivotal_tracker, lambda { |story_id|
{ :conditions => ['name LIKE ?', "%[PT#{story_id}]%"] }
}
end
end
10 changes: 6 additions & 4 deletions app/models/user/task_reminders.rb
Expand Up @@ -26,8 +26,8 @@ def assigned_tasks(max_date = nil)
def tasks_for_daily_reminder_email
tasks = assigned_tasks.due_sooner_than_two_weeks.all(:order => 'tasks.due_on')
tasks_by_dueness = Hash.new { |h, k| h[k] = Array.new }
tasks.each_with_object(tasks_by_dueness) do |task, all|

tasks_with_date = tasks.each_with_object(tasks_by_dueness) do |task, all|
due_identifier = if Date.today == task.due_on
:today
elsif Date.today + 1 == task.due_on
Expand All @@ -37,8 +37,10 @@ def tasks_for_daily_reminder_email
else
:for_next_two_weeks
end

all[due_identifier] << task
end
tasks_with_date[:urgent] = assigned_tasks.urgent
tasks_with_date
end
end
end
3 changes: 3 additions & 0 deletions app/views/emailer/_tasks_for_daily_reminder.html.haml
Expand Up @@ -8,6 +8,9 @@
- if task.due_on
%span{ :style => task_due_on_style(task, :late => task.overdue?) }
= due_on(task)
- elsif task.urgent?
%span{ :style => task_due_on_style(task) }
= t('emailer.daily_task_reminder_email.urgent')
%td{ :style => "width:530px; font-size: 12px;" }
%table{ :style => "border-spacing: 5px 0", :border => 0 }
%tr
Expand Down
1 change: 1 addition & 0 deletions app/views/emailer/daily_task_reminder.html.haml
@@ -1,6 +1,7 @@
.email{ :style => email_global }
%p= t('users.daily_task_reminder_email.daily_task_reminder_from_teambox')

= tasks_for_daily_reminder(@tasks[:urgent], @user, t('users.daily_task_reminder_email.urgent_tasks'))
= tasks_for_daily_reminder(@tasks[:late], @user, t('users.daily_task_reminder_email.late_tasks'))
= tasks_for_daily_reminder(@tasks[:today], @user, t('users.daily_task_reminder_email.tasks_for_today'))
= tasks_for_daily_reminder(@tasks[:tomorrow], @user, t('users.daily_task_reminder_email.tasks_for_tomorrow'))
Expand Down
3 changes: 2 additions & 1 deletion app/views/emailer/daily_task_reminder.text.erb
@@ -1,10 +1,11 @@
<%= t('users.daily_task_reminder_email.daily_task_reminder_from_teambox') %>
<%= tasks_for_daily_reminder(@tasks[:urgent], @user, t('users.daily_task_reminder_email.urgent_tasks')) %>
<%= tasks_for_daily_reminder(@tasks[:late], @user, t('users.daily_task_reminder_email.late_tasks')) %>
<%= tasks_for_daily_reminder(@tasks[:today], @user, t('users.daily_task_reminder_email.tasks_for_today')) %>
<%= tasks_for_daily_reminder(@tasks[:tomorrow], @user, t('users.daily_task_reminder_email.tasks_for_tomorrow')) %>
<%= tasks_for_daily_reminder(@tasks[:for_next_two_weeks], @user, t('users.daily_task_reminder_email.tasks_for_next_two_weeks')) %>
<%= tasks_for_daily_reminder(@tasks[:no_due_date], @user, t('users.daily_task_reminder_email.tasks_without_a_due_date')) %>
<%= t('users.daily_task_reminder_email.you_receive_this_message_html', :link => t('users.daily_task_reminder_email.settings_page')) %>
<%= account_notifications_url %>
<%= account_notifications_url %>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Expand Up @@ -434,8 +434,10 @@ en:
wrong_email_html: "Wrong address? If you mistyped your email address, <a href='%{link}'>you can change it now</a>."
problems_html: "If you're still having problems, please contact us at %{support}"
daily_task_reminder_email:
urgent: Urgent
daily_task_reminder: "Daily task reminder"
daily_task_reminder_from_teambox: "This is the daily task reminder email from Teambox"
urgent_tasks: "Urgent tasks"
late_tasks: "Late tasks"
tasks_for_today: "Tasks for today"
tasks_for_tomorrow: "Tasks for tomorrow"
Expand Down

0 comments on commit 3a84784

Please sign in to comment.