You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/04/16 18:28:46 UTC

[1/6] allura git commit: [#6017] ticket:751 Fixed test

Repository: allura
Updated Branches:
  refs/heads/master a3f7d44ab -> ad7c5f9cc


[#6017] ticket:751 Fixed test


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

Branch: refs/heads/master
Commit: da94700afcfd4b69cf38adf8835bc16ac599a12b
Parents: 677fd67
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Apr 8 14:51:39 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Apr 16 10:43:47 2015 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tests/functional/test_root.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/da94700a/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 0e92b1f..666fbc1 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -807,7 +807,7 @@ class TestFunctionalController(TrackerTestController):
             'delete': 'True'
         })
         deleted_form = self.app.get('/bugs/1/')
-        assert file_name not in deleted_form
+        assert file_link not in deleted_form
 
     def test_delete_attachment_from_comments(self):
         ticket_view = self.new_ticket(summary='test ticket').follow()


[2/6] allura git commit: [#6017] ticket:751 Add attachment information to ticket changelog entries

Posted by he...@apache.org.
[#6017] ticket:751 Add attachment information to ticket changelog entries


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

Branch: refs/heads/master
Commit: 130cceccd0c4ce69e0b37cb1977df5bb2b33c20b
Parents: a3f7d44
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Apr 7 17:22:16 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Apr 16 10:43:47 2015 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tracker_main.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/130ccecc/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 4f20d88..2b4e807 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1389,6 +1389,14 @@ class TicketController(BaseController, FeedController):
 
     @require_post()
     def _update_ticket(self, post_data):
+        def attachments_info(attachments):
+            text = ''
+            for attach in attachments:
+                text = "%s %s (%s; %s) " % (
+                    text, attach.filename,
+                    h.do_filesizeformat(attach.length), attach.content_type)
+            return text
+
         require_access(self.ticket, 'update')
         changes = changelog()
         comment = post_data.pop('comment', None)
@@ -1424,7 +1432,9 @@ class TicketController(BaseController, FeedController):
 
         if 'attachment' in post_data:
             attachment = post_data['attachment']
+            changes['attachments'] = attachments_info(self.ticket.attachments)
             self.ticket.add_multiple_attachments(attachment)
+            changes['attachments'] = attachments_info(self.ticket.attachments)
         for cf in c.app.globals.custom_fields or []:
             if 'custom_fields.' + cf.name in post_data:
                 value = post_data['custom_fields.' + cf.name]


[4/6] allura git commit: [#6017] ticket:756 Show attachments list as a diff, so it's easy to see what was added or removed

Posted by he...@apache.org.
[#6017] ticket:756 Show attachments list as a diff, so it's easy to see what was added or removed


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

Branch: refs/heads/master
Commit: 9546f5ae425c02cd21266a047a2b34ebb50bbf5e
Parents: da94700
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 16 11:04:23 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Apr 16 11:04:23 2015 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/data/ticket_changed_tmpl |  4 ++--
 ForgeTracker/forgetracker/tracker_main.py          | 11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/9546f5ae/ForgeTracker/forgetracker/data/ticket_changed_tmpl
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/data/ticket_changed_tmpl b/ForgeTracker/forgetracker/data/ticket_changed_tmpl
index 899b353..c04d92d 100644
--- a/ForgeTracker/forgetracker/data/ticket_changed_tmpl
+++ b/ForgeTracker/forgetracker/data/ticket_changed_tmpl
@@ -20,8 +20,8 @@
 {% python from allura.model import User %}\
 {% for key, values in changelist %}\
 {% choose %}\
-{% when key == 'description' %}\
-- Description has changed:
+{% when key in ['description', 'attachments'] %}\
+- ${key.capitalize()} has changed:
 
 Diff:
 

http://git-wip-us.apache.org/repos/asf/allura/blob/9546f5ae/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 7558eab..f8a5680 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1391,12 +1391,13 @@ class TicketController(BaseController, FeedController):
     @require_post()
     def _update_ticket(self, post_data):
         def attachments_info(attachments):
-            text = ''
+            text = []
             for attach in attachments:
-                text = "%s %s (%s; %s) " % (
-                    text, attach.filename,
-                    h.do_filesizeformat(attach.length), attach.content_type)
-            return text
+                text.append("{} ({}; {})".format(
+                    attach.filename,
+                    h.do_filesizeformat(attach.length),
+                    attach.content_type))
+            return "\n".join(text)
 
         require_access(self.ticket, 'update')
         changes = changelog()


[3/6] allura git commit: [#6017] ticket:751 Clear Ming's cache for attachments to generate a changelog

Posted by he...@apache.org.
[#6017] ticket:751 Clear Ming's cache for attachments to generate a changelog


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

Branch: refs/heads/master
Commit: 677fd677338c3a2c62c4674273f68ca2cc1186ad
Parents: 130ccec
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 8 10:10:02 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Apr 16 10:43:47 2015 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tracker_main.py | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/677fd677/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 2b4e807..7558eab 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -38,6 +38,7 @@ from bson.errors import InvalidId
 from webhelpers import feedgenerator as FG
 
 from ming import schema
+from ming.odm import session
 from ming.orm.ormsession import ThreadLocalORMSession
 from ming.utils import LazyProperty
 
@@ -1434,6 +1435,11 @@ class TicketController(BaseController, FeedController):
             attachment = post_data['attachment']
             changes['attachments'] = attachments_info(self.ticket.attachments)
             self.ticket.add_multiple_attachments(attachment)
+            # flush new attachments to db
+            session(self.ticket.attachment_class()).flush()
+            # self.ticket.attachments is ming's LazyProperty, we need to reset
+            # it's cache to fetch updated attachments here:
+            self.ticket.__dict__.pop('attachments')
             changes['attachments'] = attachments_info(self.ticket.attachments)
         for cf in c.app.globals.custom_fields or []:
             if 'custom_fields.' + cf.name in post_data:


[6/6] allura git commit: [#6017] ticket:756 Test attachments changelog better

Posted by he...@apache.org.
[#6017] ticket:756 Test attachments changelog better


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

Branch: refs/heads/master
Commit: ad7c5f9cc4ea231dc896a7fbb14be6956125cd4a
Parents: b5a084f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 16 15:10:13 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Apr 16 15:10:13 2015 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tests/functional/test_root.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ad7c5f9c/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 666fbc1..21a3564 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -790,6 +790,10 @@ class TestFunctionalController(TrackerTestController):
         }, upload_files=[upload]).follow()
         assert_true(file_name in ticket_editor)
         assert '<span>py</span>' not in ticket_editor
+        ticket_page = self.app.get('/bugs/1/')
+        diff = ticket_page.html.findAll('div', attrs={'class': 'codehilite'})
+        added = diff[-1].findAll('span', attrs={'class': 'gi'})[-1]
+        assert_in('+test_root.py', added.getText())
 
     def test_delete_attachment(self):
         file_name = 'test_root.py'
@@ -806,8 +810,11 @@ class TestFunctionalController(TrackerTestController):
         self.app.post(str(file_link['href']), {
             'delete': 'True'
         })
-        deleted_form = self.app.get('/bugs/1/')
-        assert file_link not in deleted_form
+        ticket_page = self.app.get('/bugs/1/')
+        assert file_link not in ticket_page
+        diff = ticket_page.html.findAll('div', attrs={'class': 'codehilite'})
+        removed = diff[-1].findAll('span', attrs={'class': 'gd'})[-1]
+        assert_in('-test_root.py', removed.getText())
 
     def test_delete_attachment_from_comments(self):
         ticket_view = self.new_ticket(summary='test ticket').follow()


[5/6] allura git commit: [#6017] ticket:756 Send notification when attachment is deleted

Posted by he...@apache.org.
[#6017] ticket:756 Send notification when attachment is deleted


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

Branch: refs/heads/master
Commit: b5a084fd7832afe989e5722340c44477f088285a
Parents: 9546f5a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 16 14:51:43 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Apr 16 14:51:43 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/attachments.py  | 19 ++++----
 ForgeTracker/forgetracker/tracker_main.py | 60 ++++++++++++++++++++------
 2 files changed, 57 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b5a084fd/Allura/allura/controllers/attachments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/attachments.py b/Allura/allura/controllers/attachments.py
index 4ab3b92..a648873 100644
--- a/Allura/allura/controllers/attachments.py
+++ b/Allura/allura/controllers/attachments.py
@@ -73,17 +73,20 @@ class AttachmentController(BaseController):
             raise exc.HTTPNotFound
         return attachment
 
+    def handle_post(self, delete, **kw):
+        require_access(self.artifact, self.edit_perm)
+        if delete:
+            self.attachment.delete()
+            try:
+                if self.thumbnail:
+                    self.thumbnail.delete()
+            except exc.HTTPNotFound:
+                pass
+
     @expose()
     def index(self, delete=False, **kw):
         if request.method == 'POST':
-            require_access(self.artifact, self.edit_perm)
-            if delete:
-                self.attachment.delete()
-                try:
-                    if self.thumbnail:
-                        self.thumbnail.delete()
-                except exc.HTTPNotFound:
-                    pass
+            self.handle_post(delete, **kw)
             redirect(request.referer)
         embed = False
         if self.attachment.content_type and self.attachment.content_type.startswith('image/'):

http://git-wip-us.apache.org/repos/asf/allura/blob/b5a084fd/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index f8a5680..9fc39d8 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -148,6 +148,33 @@ def get_change_text(name, new_value, old_value):
         comment=None)
 
 
+def attachments_info(attachments):
+    text = []
+    for attach in attachments:
+        text.append("{} ({}; {})".format(
+            attach.filename,
+            h.do_filesizeformat(attach.length),
+            attach.content_type))
+    return "\n".join(text)
+
+
+def render_changes(changes, comment=None):
+    """
+    Render ticket changes given instanse of :class changelog:
+
+    Returns tuple (post_text, notification_text)
+    """
+    template = pkg_resources.resource_filename(
+        'forgetracker', 'data/ticket_changed_tmpl')
+    render = partial(
+        h.render_genshi_plaintext,
+        template,
+        changelist=changes.get_changed())
+    post_text = render(comment=None)
+    notification_text = render(comment=comment) if comment else None
+    return post_text, notification_text
+
+
 def _my_trackers(user, current_tracker_app_config):
     '''Collect all 'Tickets' instances in all user's projects
     for which user has admin permissions.
@@ -1390,15 +1417,6 @@ class TicketController(BaseController, FeedController):
 
     @require_post()
     def _update_ticket(self, post_data):
-        def attachments_info(attachments):
-            text = []
-            for attach in attachments:
-                text.append("{} ({}; {})".format(
-                    attach.filename,
-                    h.do_filesizeformat(attach.length),
-                    attach.content_type))
-            return "\n".join(text)
-
         require_access(self.ticket, 'update')
         changes = changelog()
         comment = post_data.pop('comment', None)
@@ -1469,11 +1487,7 @@ class TicketController(BaseController, FeedController):
                 self.ticket.custom_fields[cf.name] = value
                 changes[cf.label] = cf_val(cf)
 
-        tpl = pkg_resources.resource_filename(
-            'forgetracker', 'data/ticket_changed_tmpl')
-        render = partial(h.render_genshi_plaintext, tpl, changelist=changes.get_changed())
-        post_text = render(comment=None)
-        notification_text = render(comment=comment) if comment else None
+        post_text, notification_text = render_changes(changes, comment)
         thread = self.ticket.discussion_thread
         thread.add_post(text=post_text, is_meta=True,
                         notification_text=notification_text)
@@ -1552,6 +1566,24 @@ class AttachmentController(att.AttachmentController):
     AttachmentClass = TM.TicketAttachment
     edit_perm = 'update'
 
+    def handle_post(self, delete, **kw):
+        old_attachments = attachments_info(self.artifact.attachments)
+        super(AttachmentController, self).handle_post(delete, **kw)
+        if delete:
+            session(self.artifact.attachment_class()).flush()
+            # self.artifact.attachments is ming's LazyProperty, we need to reset
+            # it's cache to fetch updated attachments here:
+            self.artifact.__dict__.pop('attachments')
+            new_attachments = attachments_info(self.artifact.attachments)
+            changes = changelog()
+            changes['attachments'] = old_attachments
+            changes['attachments'] = new_attachments
+            post_text, notification = render_changes(changes)
+            self.artifact.discussion_thread.add_post(
+                text=post_text,
+                is_meta=True,
+                notification_text=notification)
+
 
 class AttachmentsController(att.AttachmentsController):
     AttachmentControllerClass = AttachmentController