incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [40/50] [abbrv] git commit: [#2502] ticket:300 Send report to monitoring email, if set
Date Tue, 23 Apr 2013 16:42:44 GMT
[#2502] ticket:300 Send report to monitoring email, if set


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/24e8e46a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/24e8e46a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/24e8e46a

Branch: refs/heads/cj/5120
Commit: 24e8e46aaf860e1650afe00ff2e2ee373befc4e7
Parents: ff0d78a
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Apr 16 13:52:05 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Apr 22 19:40:27 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |   35 +++++++++++++++
 ForgeTracker/forgetracker/tracker_main.py          |   16 ++++++-
 2 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/24e8e46a/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index ca51a10..91b718c 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1173,6 +1173,41 @@ class TestFunctionalController(TrackerTestController):
         assert_in(second_ticket_changes, admin_email.kwargs.text)
         assert_in(third_ticket_changes, admin_email.kwargs.text)
 
+    def test_bulk_edit_notifications_monitoring_email(self):
+        self.app.post('/admin/bugs/set_options', params={
+            'TicketMonitoringEmail': 'monitoring@email.com',
+            'TicketMonitoringType': 'AllTicketChanges',
+        })
+        self.new_ticket(summary='test first ticket', status='open', _milestone='2.0')
+        ThreadLocalORMSession.flush_all()
+        M.MonQTask.run_ready()
+        ThreadLocalORMSession.flush_all()
+        ticket = tm.Ticket.query.get(summary='test first ticket')
+        M.MonQTask.query.remove()
+        self.app.post('/p/test/bugs/update_tickets', {
+                      '__search': '',
+                      '__ticket_ids': [ticket._id],
+                      'status': 'accepted'})
+        M.MonQTask.run_ready()
+        emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+        assert_equal(len(emails), 2)  # one for admin and one for monitoring email
+        for email in emails:
+            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes by Test Admin')
+        admin = M.User.by_username('test-admin')
+        admin_email = M.MonQTask.query.find({
+            'task_name': 'allura.tasks.mail_tasks.sendmail',
+            'kwargs.destinations': str(admin._id)
+        }).all()
+        monitoring_email = M.MonQTask.query.find({
+            'task_name': 'allura.tasks.mail_tasks.sendmail',
+            'kwargs.destinations': 'monitoring@email.com'
+        }).all()
+        assert_equal(len(admin_email), 1)
+        assert_equal(len(monitoring_email), 1)
+        admin_email_text = admin_email[0].kwargs.text
+        monitoring_email_text = monitoring_email[0].kwargs.text
+        assert_equal(admin_email_text, monitoring_email_text)
+
     def test_filtered_by_subscription(self):
         self.new_ticket(summary='test first ticket', status='open')
         self.new_ticket(summary='test second ticket', status='open')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/24e8e46a/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 6a5a1f3..34ee011 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -871,7 +871,7 @@ class RootController(BaseController):
                 v = user.display_name if user else v
             head.append('- **%s**: %s' % (get_label(f), v))
         for f, v in sorted(custom_values.iteritems()):
-            cf = custom_fields[k]
+            cf = custom_fields[f]
             if cf.type == 'user':
                 user = M.User.by_username(v)
                 v = user.display_name if user else v
@@ -884,7 +884,19 @@ class RootController(BaseController):
                 text = tmpl.render(tmpl_context),
                 destinations = [str(user._id)]))
             mail_tasks.sendmail.post(**mail)
-            # TODO: send summary on ticket's monitoring email
+
+        if c.app.config.options.get('TicketMonitoringType') == 'AllTicketChanges':
+            monitoring_email = c.app.config.options.get('TicketMonitoringEmail')
+            def all_changes():
+                for t_id in changed_tickets.keys():
+                    yield (changed_tickets[t_id].ticket_num, changes[t_id])
+            tmpl_context['data'].update({'changes': all_changes()})
+            mail.update(dict(
+                message_id = h.gen_message_id(),
+                text = tmpl.render(tmpl_context),
+                destinations = [monitoring_email]))
+            mail_tasks.sendmail.post(**mail)
+
         c.app.globals.invalidate_bin_counts()
         ThreadLocalORMSession.flush_all()
         count = len(tickets)


Mime
View raw message