incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [12/12] git commit: [#2502] ticket:300 Add userfield to test
Date Mon, 22 Apr 2013 19:41:28 GMT
[#2502] ticket:300 Add userfield to test


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

Branch: refs/heads/master
Commit: ff0d78a81770e9f7d6db51e3a4dee8798c37e110
Parents: 1f298f1
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Apr 16 13:28:23 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Apr 22 19:40:27 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ff0d78a8/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 1321e6f..ca51a10 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1113,7 +1113,8 @@ class TestFunctionalController(TrackerTestController):
                           second_ticket._id,
                           third_ticket._id),
                       'status': 'accepted',
-                      '_milestone': '2.0'})
+                      '_milestone': '2.0',
+                      'assigned_to': 'test-admin'})
         M.MonQTask.run_ready()
 
         emails = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
@@ -1142,20 +1143,24 @@ class TestFunctionalController(TrackerTestController):
         # Expected data
         email_header = '''Mass edit changing:
 
+- **Owner**: Test Admin
 - **Status**: accepted
 - **Milestone**: 2.0
 
 '''
         first_ticket_changes = '''ticket: [bugs:#1]
 
+- **Owner**: Anonymous --> Test Admin
 - **Status**: open --> accepted
 '''
         second_ticket_changes = '''ticket: [bugs:#2]
 
+- **Owner**: Anonymous --> Test Admin
 - **Milestone**: 1.0 --> 2.0
 '''
         third_ticket_changes = '''ticket: [bugs:#3]
 
+- **Owner**: Anonymous --> Test Admin
 - **Status**: unread --> accepted
 - **Milestone**: 1.0 --> 2.0
 '''

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ff0d78a8/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 01b9f45..6a5a1f3 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -814,22 +814,22 @@ class RootController(BaseController):
         changed_tickets = {}
         for ticket in tickets:
             message = ''
-            for k, v in values.iteritems():
+            for k, v in sorted(values.iteritems()):
                 if k == 'assigned_to_id':
                     new_user = M.User.query.get(_id=v)
                     old_user = M.User.query.get(_id=getattr(ticket, k))
                     if new_user:
                         message += get_change_text(
                             get_label(k),
-                            new_user.username,
-                            old_user.username)
+                            new_user.display_name,
+                            old_user.display_name)
                 else:
                     message += get_change_text(
                         get_label(k),
                         v,
                         getattr(ticket, k))
                 setattr(ticket, k, v)
-            for k, v in custom_values.iteritems():
+            for k, v in sorted(custom_values.iteritems()):
                 def cf_val(cf):
                     return ticket.get_custom_user(cf.name) \
                            if cf.type == 'user' \
@@ -847,6 +847,7 @@ class RootController(BaseController):
                 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()
         def changes_iter(user):
@@ -863,8 +864,18 @@ class RootController(BaseController):
                 loader=jinja2.PackageLoader('forgetracker', 'data'),
                 auto_reload=asbool(config.get('auto_reload_templates', True)),
         ).get_template('mass_report')
-        head = ['- **%s**: %s' % (get_label(f), v) for f, v in values.iteritems()]
-        head += ['- **%s**: %s' % (get_label(f), v) for f, v in custom_values.iteritems()]
+        head = []
+        for f, v in sorted(values.iteritems()):
+            if f == 'assigned_to_id':
+                user = M.User.query.get(_id=v)
+                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]
+            if cf.type == 'user':
+                user = M.User.by_username(v)
+                v = user.display_name if user else v
+            head.append('- **%s**: %s' % (cf.label, v))
         tmpl_context = {'context': c, 'data': {'header': '\n'.join(['Mass edit changing:',
''] + head)}}
         for user in users:
             tmpl_context['data'].update({'changes': changes_iter(user)})


Mime
View raw message