You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/07/14 17:02:59 UTC
[18/50] [abbrv] allura git commit: [#7540] ticket:816 Show
attachments in tickets notifications
[#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/9d7b26ed
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9d7b26ed
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9d7b26ed
Branch: refs/heads/ib/7897
Commit: 9d7b26eda21824d356ecd31b017c84671c14f3aa
Parents: f245736
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 8 13:11:23 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Jul 13 20:01:44 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/9d7b26ed/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/9d7b26ed/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/9d7b26ed/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=[