Added a new column to the notifications table to toggle sending
the notifications.
Updated the user's profile page to include an option to toggle this
on and off. Also changed the notifications view to be more intuitive.
When daily updates are collected, then all affected products are CC'd
with the user's daily update. CC'ing product lists requires the user
to have daily updates enabled.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/models/user_mailer.rb | 3 +-
app/views/users/_notifications.html.erb | 27 ++++++++++++---
config/initializers/schedules.rb | 33 +++++++++++++------
.../022_add_send_notifications_to_product_list.rb | 26 +++++++++++++++
db/schema.rb | 3 +-
5 files changed, 73 insertions(+), 19 deletions(-)
create mode 100644 db/migrate/022_add_send_notifications_to_product_list.rb
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index e830463..5609dc8 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -58,8 +58,9 @@ class UserMailer < ActionMailer::Base
end
# Sends an email to a user letting him know his daily activities.
- def daily_updates(user, open_items, completed_items, task_performed)
+ def daily_updates(user, cc_list, open_items, completed_items, task_performed)
recipients user.email
+ cc cc_list
from MAIL_CONFIG[:from]
subject "Daily updates for #{user.display_name}"
body :user => user, :open_items => open_items,
diff --git a/app/views/users/_notifications.html.erb
b/app/views/users/_notifications.html.erb
index 06b34fb..79e9518 100644
--- a/app/views/users/_notifications.html.erb
+++ b/app/views/users/_notifications.html.erb
@@ -1,25 +1,40 @@
<% form_for(:notifications, @this_user.notifications, :url =>
notifications_user_path(@this_user)) do |form| %>
<table class="edit">
+ <colgroup>
+ <col class="value" />
+ </colgroup>
+
<thead>
<tr>
- <th class="title" colspan="2">Email
Notifications</th>
+ <th class="title">Email Notifications</th>
</tr>
</thead>
<tbody>
<tr>
- <td class="label">Daily scrum email</td>
- <td class="value"><%= form.check_box :daily_updates
%></td>
+ <td class="value">
+ <%= form.check_box :daily_updates %>
+ <%= form.label :daily_updates, "Send a daily updates." %>
+ </td>
</tr>
<tr>
- <td class="label">Task reminders</td>
- <td class="value"><%= form.check_box :task_reminders %>
+ <td class="value">
+ <%= form.check_box :updates_to_product_list %>
+ <%= form.label :updates_to_product_list, "Send updates to product list
(requires daily updates be enabled)." %>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="value">
+ <%= form.check_box :task_reminders %>
+ <%= form.label :task_reminders, "Send daily task update
reminders." %>
+ </td>
</tr>
<tr>
- <td class="buttons" colspan="2">
+ <td class="buttons">
<%= submit_tag "Update" %>
</td>
</tr>
diff --git a/config/initializers/schedules.rb b/config/initializers/schedules.rb
index 07b9618..83be588 100644
--- a/config/initializers/schedules.rb
+++ b/config/initializers/schedules.rb
@@ -1,18 +1,18 @@
# schedules.rb
# Copyright (C) 2008, Darryl L. Pierce <mcpierce(a)gmail.com>
#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <
http://www.gnu.org/licenses/>.
require 'fastthread'
require 'openwfe/util/scheduler'
@@ -64,7 +64,18 @@ threads["daily updates"] = Thread.new do
User.find(:all).each do |user|
if user.notifications.daily_updates
- UserMailer.deliver_daily_updates(user, open_items[user],
+ cc_list = []
+
+ if user.notifications.updates_to_product_list
+ tasks_performed[user].each do |task|
+ product = task.backlog_item.sprint.product
+ if product.has_mailing_list? &&
!cc_list.include?(product.mailing_list)
+ cc_list << product.mailing_list
+ end
+ end
+ end
+
+ UserMailer.deliver_daily_updates(user, cc_list, open_items[user],
completed_items[user], tasks_performed[user])
end
end
diff --git a/db/migrate/022_add_send_notifications_to_product_list.rb
b/db/migrate/022_add_send_notifications_to_product_list.rb
new file mode 100644
index 0000000..2c48cc7
--- /dev/null
+++ b/db/migrate/022_add_send_notifications_to_product_list.rb
@@ -0,0 +1,26 @@
+# 022_add_send_notifications_to_product_list.rb
+# Copyright (C) 2008, Darryl L. Pierce <mcpierce(a)gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <
http://www.gnu.org/licenses/>.
+#
+
+class AddSendNotificationsToProductList < ActiveRecord::Migration
+ def self.up
+ add_column :notifications, :updates_to_product_list, :boolean, :default => false
+ end
+
+ def self.down
+ remove_column :notifications, :updates_to_product_list
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6c86037..90c8c4a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 21) do
+ActiveRecord::Schema.define(:version => 22) do
create_table "backlog_items", :force => true do |t|
t.integer "sprint_id",
:null => false
@@ -31,6 +31,7 @@ ActiveRecord::Schema.define(:version => 21) do
t.boolean "daily_updates"
t.datetime "created_at"
t.datetime "updated_at"
+ t.boolean "updates_to_product_list", :default => false
end
create_table "product_roles", :force => true do |t|
--
1.6.0.2