allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [1/3] allura git commit: [#7540] ticket:816 Show attachments in tickets notifications
Date Thu, 09 Jul 2015 08:05:20 GMT
Repository: allura
Updated Branches:
  refs/heads/ib/7540 [created] 02c4cecb3


[#7540] ticket:816 Show attachments in tickets notifications


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

Branch: refs/heads/ib/7540
Commit: f26b057fde04922283afab1cc4d55df544805347
Parents: 93a1ecc
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Jul 8 13:11:23 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Jul 8 14:50:33 2015 +0000

----------------------------------------------------------------------
 Allura/allura/templates/mail/Ticket.txt         |  7 +++++++
 ForgeTracker/forgetracker/model/ticket.py       |  5 ++++-
 .../forgetracker/tests/functional/test_root.py  | 20 ++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f26b057f/Allura/allura/templates/mail/Ticket.txt
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/Ticket.txt b/Allura/allura/templates/mail/Ticket.txt
index 64b704c..abe38af 100644
--- a/Allura/allura/templates/mail/Ticket.txt
+++ b/Allura/allura/templates/mail/Ticket.txt
@@ -34,5 +34,12 @@
     **Last Updated:** {{data.mod_date.strftime('%a %b %d, %Y %I:%M %p UTC')}}
 {% endif -%}
 **Owner:** {{data.assigned_to_name()}}
+{% if data.attachments -%}
+    **Attachments:**
+
+{% for att in data.attachments -%}
+    - [{{att.filename}}]({{h.absurl(att.url())}}) ({{h.do_filesizeformat(att.length)}}; {{att.content_type}})
+{% endfor -%}
+{% endif %}
 
 {{data.description}}

http://git-wip-us.apache.org/repos/asf/allura/blob/f26b057f/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 925a067..20996ff 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -981,9 +981,12 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                 elif k in other_custom_fields:
                     # strings are good enough for any other custom fields
                     self.custom_fields[k] = v
-        self.commit()
         if attachment is not None:
             self.add_multiple_attachments(attachment)
+            # flush the session to make attachments available in the
+            # notification email
+            ThreadLocalORMSession.flush_all()
+        self.commit()
 
     def _move_attach(self, attachments, attach_metadata, app_config):
         for attach in attachments:

http://git-wip-us.apache.org/repos/asf/allura/blob/f26b057f/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 122d707..871f0fd 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1599,6 +1599,26 @@ class TestFunctionalController(TrackerTestController):
         assert_in('test second ticket', str(ticket_rows))
         assert_false('test third ticket' in str(ticket_rows))
 
+    def test_new_ticket_notification_contains_attachments(self):
+        file_name = u'tést_root.py'.encode('utf-8')
+        file_data = file(__file__).read()
+        upload = ('ticket_form.attachment', file_name, file_data)
+        r = self.app.post('/bugs/save_ticket', {
+            'ticket_form.summary': 'new ticket with attachment'
+        }, upload_files=[upload]).follow()
+        assert_in(file_name, r)
+        ThreadLocalORMSession.flush_all()
+        M.MonQTask.run_ready()
+        ThreadLocalORMSession.flush_all()
+        email = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendmail')
+        ).first()
+        expected_text = (
+            u'**Attachments:**\n\n'
+            u'- [tést_root.py]'
+            u'(http://localhost/p/test/bugs/1/attachment/t%C3%A9st_root.py)')
+        assert_in(expected_text, email.kwargs['text'])
+
     def test_ticket_notification_contains_milestones(self):
         params = dict(
             custom_fields=[


Mime
View raw message