You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/07/13 22:46:50 UTC

[1/3] allura git commit: [#7540] ticket:816 Fix tests

Repository: allura
Updated Branches:
  refs/heads/master f245736af -> b49a20bcf


[#7540] ticket:816 Fix tests


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

Branch: refs/heads/master
Commit: b49a20bcfded19fd5b4859322ad250ae0c0837c8
Parents: fb7adce
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 8 15:37:43 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Jul 13 20:01:44 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_discussion.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b49a20bc/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 1768777..c94f2a6 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -29,7 +29,7 @@ from pylons import tmpl_context as c
 from nose.tools import assert_equals, with_setup
 import mock
 from mock import patch
-from nose.tools import assert_equal
+from nose.tools import assert_equal, assert_in
 
 from ming.orm import session, ThreadLocalORMSession
 from webob import exc
@@ -208,7 +208,11 @@ def test_attachment_methods():
     ThreadLocalORMSession.flush_all()
     n = M.Notification.query.get(
         subject=u'[test:wiki] Test comment notification')
-    assert '\nAttachment: fake.txt (37 Bytes; text/plain)' in n.text
+    url = h.absurl('{}attachment/{}'.format(p.url(), fs.filename))
+    assert_in(
+        '\nAttachments:\n\n'
+        '- [fake.txt]({}) (37 Bytes; text/plain)'.format(url),
+        n.text)
 
 
 @with_setup(setUp, tearDown())
@@ -265,11 +269,16 @@ def test_notification_two_attaches():
     fs2.filename = 'fake2.txt'
     fs2.type = 'text/plain'
     fs2.file = StringIO('this is the content of the fake file\n')
-    t.post(text=u'test message', forum=None, subject='', file_info=[fs1, fs2])
+    p = t.post(text=u'test message', forum=None, subject='', file_info=[fs1, fs2])
     ThreadLocalORMSession.flush_all()
     n = M.Notification.query.get(
         subject=u'[test:wiki] Test comment notification')
-    assert '\nAttachment: fake.txt (37 Bytes; text/plain)  fake2.txt (37 Bytes; text/plain)' in n.text
+    base_url = h.absurl('{}attachment/'.format(p.url()))
+    assert_in(
+        '\nAttachments:\n\n'
+        '- [fake.txt]({0}fake.txt) (37 Bytes; text/plain)\n'
+        '- [fake2.txt]({0}fake2.txt) (37 Bytes; text/plain)'.format(base_url),
+        n.text)
 
 
 @with_setup(setUp, tearDown)


[3/3] allura git commit: [#7540] ticket:816 Show attachments in tickets notifications

Posted by br...@apache.org.
[#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/master
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=[


[2/3] allura git commit: [#7540] ticket:816 Show attachment links for comment

Posted by br...@apache.org.
[#7540] ticket:816 Show attachment links for comment


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

Branch: refs/heads/master
Commit: fb7adce380ce6a600203ff0fc1abe7bbef120f9f
Parents: 9d7b26e
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 8 15:00:45 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Jul 13 20:01:44 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/notification.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fb7adce3/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index ca1a850..01482f0 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -157,15 +157,18 @@ class Notification(MappedClass):
             text = kwargs.get('text') or post.text
             file_info = kwargs.pop('file_info', None)
             if file_info is not None:
-                text = "%s\n\n\nAttachment:" % text
+                text = "%s\n\n\nAttachments:\n" % text
                 if not isinstance(file_info, list):
                     file_info = [file_info]
                 for attach in file_info:
                     attach.file.seek(0, 2)
                     bytecount = attach.file.tell()
                     attach.file.seek(0)
-                    text = "%s %s (%s; %s) " % (
-                        text, attach.filename, h.do_filesizeformat(bytecount), attach.type)
+                    url = h.absurl('{}attachment/{}'.format(
+                        post.url(), h.urlquote(attach.filename)))
+                    text = "%s\n- [%s](%s) (%s; %s)" % (
+                        text, attach.filename, url,
+                        h.do_filesizeformat(bytecount), attach.type)
 
             subject = post.subject or ''
             if post.parent_id and not subject.lower().startswith('re:'):