incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [4/5] git commit: [#4659] ticket:381 refactored multiple attachments
Date Thu, 11 Jul 2013 20:20:08 GMT
[#4659]  ticket:381 refactored multiple attachments


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

Branch: refs/heads/master
Commit: 779e7947e8a34d26e404ee93fd5a9eb0ff8f3074
Parents: 94026f2
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Tue Jul 9 18:28:30 2013 +0400
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Jul 11 14:35:13 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py         | 8 ++++----
 Allura/allura/model/artifact.py              | 2 +-
 Allura/allura/model/discuss.py               | 2 +-
 Allura/allura/tests/model/test_discussion.py | 4 ++--
 ForgeTracker/forgetracker/model/ticket.py    | 8 +-------
 ForgeTracker/forgetracker/tracker_main.py    | 2 +-
 ForgeWiki/forgewiki/wiki_main.py             | 2 +-
 7 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 45b0124..9f745a3 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -202,7 +202,7 @@ class ThreadController(BaseController, FeedController):
 
         file_info = kw.get('file_info', None)
         p = self.thread.add_post(**kw)
-        p.add_multiple_attach(file_info)
+        p.add_multiple_attachments(file_info)
         if self.thread.artifact:
             self.thread.artifact.mod_date = datetime.utcnow()
         flash('Message posted')
@@ -275,7 +275,7 @@ class PostController(BaseController):
             require_access(self.post, 'moderate')
             post_fields = self.W.edit_post.to_python(kw, None)
             file_info = post_fields.pop('file_info', None)
-            self.post.add_multiple_attach(file_info)
+            self.post.add_multiple_attachments(file_info)
             for k,v in post_fields.iteritems():
                 try:
                     setattr(self.post, k, v)
@@ -320,7 +320,7 @@ class PostController(BaseController):
         require_access(self.thread, 'post')
         kw = self.W.edit_post.to_python(kw, None)
         p = self.thread.add_post(parent_id=self.post._id, **kw)
-        p.add_multiple_attach(file_info)
+        p.add_multiple_attachments(file_info)
         redirect(request.referer)
 
     @h.vardec
@@ -355,7 +355,7 @@ class PostController(BaseController):
     @require_post()
     def attach(self, file_info=None):
         require_access(self.post, 'moderate')
-        self.post.add_multiple_attach(file_info)
+        self.post.add_multiple_attachments(file_info)
         redirect(request.referer)
 
     @expose()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 6fbe0f5..b41b103 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -386,7 +386,7 @@ class Artifact(MappedClass):
         """
         return self.get_discussion_thread()[0]
 
-    def add_multiple_attach(self, file_info):
+    def add_multiple_attachments(self, file_info):
         if not isinstance(file_info, list):
             file_info = [file_info]
         for attach in file_info:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index b15d03d..76cf615 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -527,7 +527,7 @@ class Post(Message, VersionedArtifact, ActivityObject):
         return self.attachment_class().query.find(dict(
             post_id=self._id, type='attachment'))
 
-    def add_multiple_attach(self, file_info):
+    def add_multiple_attachments(self, file_info):
         if isinstance(file_info, list):
             map(self.add_attachment, file_info)
         else:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/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 4ac1e37..34e550a 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -207,7 +207,7 @@ def test_attachment_methods():
     assert '\nAttachment: fake.txt (37 Bytes; text/plain)' in n.text
 
 @with_setup(setUp, tearDown())
-def test_multiple_attach():
+def test_multiple_attachments():
     test_file1 = FieldStorage()
     test_file1.name = 'file_info'
     test_file1.filename = 'test1.txt'
@@ -221,7 +221,7 @@ def test_multiple_attach():
     d = M.Discussion(shortname='test', name='test')
     t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
     test_post = t.post('test post')
-    test_post.add_multiple_attach([test_file1, test_file2])
+    test_post.add_multiple_attachments([test_file1, test_file2])
     ThreadLocalORMSession.flush_all()
     assert test_post.attachments.count() == 2, test_post.attachments.count()
     attaches = test_post.attachments.all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 6679e2a..80ce102 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -833,13 +833,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                     self.custom_fields[k] = v
         self.commit()
         if attachment is not None:
-            if isinstance(attachment, list):
-                for attach in attachment:
-                    self.attach(attach.filename, attach.file, content_type=attach.type)
-            else:
-                self.attach(
-                    attachment.filename, attachment.file,
-                    content_type=attachment.type)
+            self.add_multiple_attachments(attachment)
 
     def _move_attach(self, attachments, attach_metadata, app_config):
         for attach in attachments:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 9037c4d..b6af2ee 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1293,7 +1293,7 @@ class TicketController(BaseController, FeedController):
 
         if 'attachment' in post_data:
             attachment = post_data['attachment']
-            self.ticket.add_multiple_attach(attachment)
+            self.ticket.add_multiple_attachments(attachment)
         for cf in c.app.globals.custom_fields or []:
             if 'custom_fields.' + cf.name in post_data:
                 value = post_data['custom_fields.' + cf.name]

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/779e7947/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 76f66f6..57e2bff 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -649,7 +649,7 @@ class PageController(BaseController, FeedController):
         if not self.page:
             raise exc.HTTPNotFound
         require_access(self.page, 'edit')
-        self.page.add_multiple_attach(file_info)
+        self.page.add_multiple_attachments(file_info)
         redirect(request.referer)
 
     @expose()


Mime
View raw message