incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [41/50] git commit: [#6534] ticket:449 Factor out wiki deletion to model method
Date Fri, 04 Oct 2013 23:23:47 GMT
[#6534] ticket:449 Factor out wiki deletion to model method


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

Branch: refs/heads/tv/6670
Commit: ba9791e55ae64429f6fa8e5480708724a66f16c3
Parents: 122a7de
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Sep 30 17:00:08 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:24 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py |  4 +---
 ForgeWiki/forgewiki/model/wiki.py            | 21 +++++++++++++++++++--
 ForgeWiki/forgewiki/wiki_main.py             |  5 +----
 3 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ba9791e5/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 980bb64..9b024c6 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -198,9 +198,7 @@ class GitHubWikiImporter(ToolImporter):
             wiki_page.timestamp = wiki_page.mod_date = mod_date
             wiki_page.viewable_by = ['all']
         else:
-            wiki_page.deleted = True
-            suffix = " {dt.hour}:{dt.minute}:{dt.second} {dt.day}-{dt.month}-{dt.year}".format(dt=mod_date)
-            wiki_page.title += suffix
+            wiki_page.delete()
         wiki_page.commit()
         return wiki_page
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ba9791e5/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index e4da9dc..40e7c63 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -15,6 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from datetime import datetime
 import difflib
 from pylons import app_globals as g #g is a namespace for globally accessable app helpers
 from pylons import tmpl_context as context
@@ -23,8 +24,18 @@ from ming import schema
 from ming.orm import FieldProperty, ForeignIdProperty, Mapper, session
 from ming.orm.declarative import MappedClass
 
-from allura.model import VersionedArtifact, Snapshot, Feed, Thread, Post, User, BaseAttachment
-from allura.model import Notification, project_orm_session
+from allura.model import (
+        VersionedArtifact,
+        Snapshot,
+        Feed,
+        Thread,
+        Post,
+        User,
+        BaseAttachment,
+        Notification,
+        project_orm_session,
+        Shortlink,
+)
 from allura.model.timeline import ActivityObject
 from allura.lib import helpers as h
 from allura.lib import utils
@@ -207,6 +218,12 @@ class Page(VersionedArtifact, ActivityObject):
         user_ids = uniq([r.author for r in self.history().all()])
         return User.query.find({'_id':{'$in':user_ids}}).all()
 
+    def delete(self):
+        Shortlink.query.remove(dict(ref_id=self.page.index_id()))
+        self.deleted = True
+        suffix = " {dt.hour}:{dt.minute}:{dt.second} {dt.day}-{dt.month}-{dt.year}".format(dt=datetime.utcnow())
+        self.title += suffix
+
 class WikiAttachment(BaseAttachment):
     ArtifactType=Page
     class __mongometa__:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ba9791e5/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 5fecbb2..108c14c 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -526,10 +526,7 @@ class PageController(BaseController, FeedController):
     @require_post()
     def delete(self):
         require_access(self.page, 'delete')
-        M.Shortlink.query.remove(dict(ref_id=self.page.index_id()))
-        self.page.deleted = True
-        suffix = " {dt.hour}:{dt.minute}:{dt.second} {dt.day}-{dt.month}-{dt.year}".format(dt=datetime.utcnow())
-        self.page.title += suffix
+        self.page.delete()
         return dict(location='../'+self.page.title+'/?deleted=True')
 
     @without_trailing_slash


Mime
View raw message