incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [30/50] [abbrv] git commit: [#2502] ticket:300 Send mass edit reports
Date Wed, 24 Apr 2013 04:54:35 GMT
[#2502] ticket:300 Send mass edit reports


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

Branch: refs/heads/tv/docs
Commit: be383197f85a2bfa4e5e2560d91d33733c993a7f
Parents: e843f9f
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Apr 12 13:59:12 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Apr 22 19:40:27 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |    8 ++--
 ForgeTracker/forgetracker/tracker_main.py          |   30 +++++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/be383197/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 566f534..fe58a00 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1119,22 +1119,22 @@ class TestFunctionalController(TrackerTestController):
         emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
         assert_equal(len(emails), 3)
         for email in emails:
-            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes')
+            assert_equal(email.kwargs.subject, '[test:bugs] Mass edit changes by Test Admin')
         first_user_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
-            'kwargs.destinations': first_user._id
+            'kwargs.destinations': str(first_user._id)
         }).all()
         assert_equal(len(first_user_email), 1)
         first_user_email = first_user_email[0]
         second_user_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
-            'kwargs.destinations': second_user._id
+            'kwargs.destinations': str(second_user._id)
         }).all()
         assert_equal(len(second_user_email), 1)
         second_user_email = second_user_email[0]
         admin_email = M.MonQTask.query.find({
             'task_name': 'allura.tasks.mail_tasks.sendmail',
-            'kwargs.destinations': admin._id
+            'kwargs.destinations': str(admin._id)
         }).all()
         assert_equal(len(admin_email), 1)
         admin_email = admin_email[0]

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/be383197/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 7ea8693..dc2df43 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -59,6 +59,7 @@ from allura.lib.zarkov_helpers import zero_fill_zarkov_result
 from allura.controllers import AppDiscussionController, AppDiscussionRestController
 from allura.controllers import attachments as ac
 from allura.controllers import BaseController
+from allura.tasks import mail_tasks
 
 # Local imports
 from forgetracker import model as TM
@@ -807,6 +808,8 @@ class RootController(BaseController):
                 custom_values[cf.name] = v
                 custom_fields[cf.name] = cf
 
+        changes = {}
+        changed_tickets = {}
         for ticket in tickets:
             message = ''
             for k, v in values.iteritems():
@@ -838,8 +841,35 @@ class RootController(BaseController):
                     new_value,
                     old_value)
             if message != '':
+                changes[ticket._id] = message
+                changed_tickets[ticket._id] = ticket
                 ticket.discussion_thread.post(message, notify=False)
                 ticket.commit()
+        filtered_changes = filtered_by_subscription(changed_tickets)
+        users = M.User.query.find({'_id': {'$in': filtered_changes.keys()}}).all()
+        mail = dict(
+            fromaddr = str(c.user._id),
+            reply_to = str(c.user._id),
+            message_id = h.gen_message_id(),
+            subject = '[%s:%s] Mass edit changes by %s' % (c.project.shortname,
+                                                           c.app.config.options.mount_point,
+                                                           c.user.display_name),
+        )
+        head = ['Mass edit changing:']
+        # TODO: add list with new values here
+        head = '\n'.join(head)
+        for user in users:
+            text = []
+            for t_id in filtered_changes.get(user._id, []):
+                text.append('ticket: [%s:#%d]' % (c.app.config.options.mount_point,
+                                                  changed_tickets[t_id].ticket_num))
+                text.append(changes[t_id])
+                text.append('')
+            mail.update(dict(
+                text = head + '\n\n' +  '\n'.join(text),
+                destinations = [str(user._id)]))
+            mail_tasks.sendmail.post(**mail)
+            # TODO: send summary on ticket's monitoring email
         c.app.globals.invalidate_bin_counts()
         ThreadLocalORMSession.flush_all()
         count = len(tickets)


Mime
View raw message