allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [28/50] git commit: [#5656] ticket:301 Send summary to monitoring email, if set
Date Tue, 28 May 2013 16:01:20 GMT
[#5656] ticket:301 Send summary 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/a770cdfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a770cdfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a770cdfa

Branch: refs/heads/cj/5913
Commit: a770cdfa77269140656088d9161882b2b1461fa5
Parents: 3dd4318
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed May 1 11:54:31 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri May 24 18:35:51 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |   37 +++++++++++++++
 ForgeTracker/forgetracker/tracker_main.py          |   13 +++++
 2 files changed, 50 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a770cdfa/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 e346482..da6544b 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -2352,6 +2352,43 @@ class TestBulkMove(TrackerTestController):
         assert_in(second_ticket_changes, admin_email.kwargs.text)
         assert_in(third_ticket_changes, admin_email.kwargs.text)
 
+    @td.with_tool('test2', 'Tickets', 'bugs2')
+    def test_monitoring_email(self):
+        self.app.post('/admin/bugs/set_options', params={
+            'TicketMonitoringEmail': 'monitoring@email.com',
+            'TicketMonitoringType': 'AllTicketChanges',
+        })
+        tickets = [
+            tm.Ticket.query.find({'summary': 'A New Hope'}).first(),
+            tm.Ticket.query.find({'summary': 'The Empire Strikes Back'}).first(),
+            tm.Ticket.query.find({'summary': 'Return Of The Jedi'}).first()]
+        p = M.Project.query.get(shortname='test2')
+        tracker = p.app_instance('bugs2')
+        M.MonQTask.query.remove()
+        r = self.app.post('/p/test/bugs/move_tickets', {
+                    'tracker': str(tracker.config._id),
+                    '__ticket_ids': [t._id for t in tickets],
+                    '__search': '',
+                })
+        M.MonQTask.run_ready()
+        emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+        assert_equal(len(emails), 2)
+        for email in emails:
+            assert_equal(email.kwargs.subject, '[test:bugs] Mass ticket moving by Test Admin')
+        admin_email = M.MonQTask.query.find({
+            'task_name': 'allura.tasks.mail_tasks.sendmail',
+            'kwargs.destinations': str(M.User.by_username('test-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 sidebar_contains(response, text):
     sidebar_menu = response.html.find('div', attrs={'id': 'sidebar'})

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a770cdfa/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index c41db5e..845d380 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -861,6 +861,19 @@ class RootController(BaseController, FeedController):
                 destinations = [str(user._id)]))
             mail_tasks.sendmail.post(**mail)
 
+        if c.app.config.options.get('TicketMonitoringType') == 'AllTicketChanges':
+            monitoring_email = c.app.config.options.get('TicketMonitoringEmail')
+            tmpl_context['tickets'] = ({
+                    'original_num': original_ticket_nums[_id],
+                    'destination_num': moved_tickets[_id].ticket_num,
+                    'summary': moved_tickets[_id].summary
+                } for _id in moved_tickets.keys())
+            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