incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [05/24] git commit: [#7065] remove dead code for promoting post to its own thread
Date Wed, 22 Jan 2014 21:39:23 GMT
[#7065] remove dead code for promoting post to its own thread

We haven't exposed this code to promote a post into its own thread
for a long time.  And it called ForumPost.move() which did an unindexed
query by slug, which is the reason to clean it up now.


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

Branch: refs/heads/cj/7002
Commit: 4b4c1476f65e8632b8604c2e379cca39108361af
Parents: 8facd54
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Thu Jan 16 17:24:42 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Thu Jan 16 18:02:47 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/discuss.py            |  9 +---
 .../allura/templates/widgets/post_thread.html   |  2 +-
 .../allura/templates/widgets/post_widget.html   |  6 ---
 .../allura/templates/widgets/thread_widget.html |  2 +-
 .../forgediscussion/controllers/forum.py        |  6 ---
 ForgeDiscussion/forgediscussion/model/forum.py  | 46 --------------------
 .../tests/functional/test_forum.py              | 14 +-----
 .../forgediscussion/widgets/__init__.py         |  2 +-
 .../forgediscussion/widgets/forum_widgets.py    | 18 --------
 9 files changed, 6 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 70a1d15..7ca7d81 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -298,7 +298,7 @@ class Post(HierWidget):
         page=0,
         limit=25,
         show_subject=False,
-        suppress_promote=False)
+        )
     widgets = dict(
         moderate_post=ModeratePost(),
         edit_post=EditPost(submit_text='Post'),
@@ -373,12 +373,6 @@ class Post(HierWidget):
                         return false;
                     });
                 }
-                if($('.promote_to_thread', post)){
-                    $('.promote_to_thread', post).click(function (ele) {
-                        $('.promote_to_thread_form', post).show();
-                        return false;
-                    });
-                }
                 if($('.shortlink', post)){
                     var popup = $('.shortlink_popup', post);
                     $('.shortlink', post).click(function(evt){
@@ -407,7 +401,6 @@ class PostThread(ew_core.Widget):
         page=0,
         limit=25,
         show_subject=False,
-        suppress_promote=False,
         parent=None,
         children=None)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/Allura/allura/templates/widgets/post_thread.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_thread.html b/Allura/allura/templates/widgets/post_thread.html
index 3877500..5930122 100644
--- a/Allura/allura/templates/widgets/post_thread.html
+++ b/Allura/allura/templates/widgets/post_thread.html
@@ -20,7 +20,7 @@
 <li>
 {{widget.parent_widget.widgets.post.display(
     value=value, show_subject=show_subject, indent=indent,
-    supress_promote=supress_promote, page=page, limit=limit)}}
+    page=page, limit=limit)}}
     <!-- post_thread replies -->
     <ul>
       {%- if children %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/Allura/allura/templates/widgets/post_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html
index f85fc4b..193161b 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -148,12 +148,6 @@
       </li>
     </ul>
   </div>
-
-  {% if h.has_access(value.thread, 'moderate')() and 'promote_to_thread' in widgets and not
supress_promote %}
-  <div class="promote_to_thread_form push-{{3+indent}} span-{{16-indent}} last clear"
style="display:none">
-    {{widgets.promote_to_thread.display(value=value, action=value.url()+'moderate')}}
-  </div>
-  {% endif %}
 </div>
 
 {% block extra_css %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/Allura/allura/templates/widgets/thread_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/thread_widget.html b/Allura/allura/templates/widgets/thread_widget.html
index 863fd8f..256ad00 100644
--- a/Allura/allura/templates/widgets/thread_widget.html
+++ b/Allura/allura/templates/widgets/thread_widget.html
@@ -31,7 +31,7 @@
             <ul>
               {{widgets.post_thread.display(value=t['post'], children=t['children'],
                   indent=0, show_subject=show_subject,
-                  supress_promote=True, page=page, limit=limit)}}
+                  page=page, limit=limit)}}
             </ul>
             {% endfor %}
           {% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/ForgeDiscussion/forgediscussion/controllers/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/forum.py b/ForgeDiscussion/forgediscussion/controllers/forum.py
index fd2b816..c83adaf 100644
--- a/ForgeDiscussion/forgediscussion/controllers/forum.py
+++ b/ForgeDiscussion/forgediscussion/controllers/forum.py
@@ -59,7 +59,6 @@ class WidgetConfig(object):
     subscription_form = DW.SubscriptionForm()
     subscribe_form = SubscribeForm()
     edit_post = DW.EditPost(show_subject=True)
-    moderate_post = FW.ModeratePost()
     moderate_thread = FW.ModerateThread()
     flag_post = DW.FlagPost()
     post_filter = DW.PostFilter()
@@ -183,13 +182,8 @@ class ForumPostController(PostController):
         require_access(self.post.thread, 'moderate')
         if self.thread.discussion.deleted and not has_access(c.app, 'configure')():
             redirect(self.thread.discussion.url() + 'deleted')
-        args = self.W.moderate_post.validate(kw, None)
         tasks.calc_thread_stats.post(self.post.thread._id)
         tasks.calc_forum_stats(self.post.discussion.shortname)
-        if args.pop('promote', None):
-            new_thread = self.post.promote()
-            tasks.calc_thread_stats.post(new_thread._id)
-            redirect(request.referer)
         super(ForumPostController, self).moderate(**kw)
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index 1d74375..5545cf0 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -239,52 +239,6 @@ class ForumPost(M.Post):
     def primary(self):
         return self
 
-    def promote(self):
-        '''Make the post its own thread head'''
-        thd = self.thread_class()(
-            discussion_id=self.discussion_id,
-            subject=self.subject,
-            first_post_id=self._id)
-        self.move(thd, None)
-        return thd
-
-    def move(self, thread, new_parent_id):
-        # Add a placeholder to note the move
-        placeholder = self.thread.post(
-            subject='Discussion moved',
-            text='',
-            parent_id=self.parent_id)
-        placeholder.slug = self.slug
-        placeholder.full_slug = self.full_slug
-        placeholder.approve()
-        if new_parent_id:
-            parent = self.post_class().query.get(_id=new_parent_id)
-        else:
-            parent = None
-        # Set the thread ID on my replies and attachments
-        old_slug = self.slug + '/', self.full_slug + '/'
-        reply_re = re.compile(self.slug + '/.*')
-        self.slug, self.full_slug = self.make_slugs(
-            parent=parent, timestamp=self.timestamp)
-        placeholder.text = 'Discussion moved to [here](%s#post-%s)' % (
-            thread.url(), self.slug)
-        new_slug = self.slug + '/', self.full_slug + '/'
-        self.discussion_id = thread.discussion_id
-        self.thread_id = thread._id
-        self.parent_id = new_parent_id
-        self.text = 'Discussion moved from [here](%s#post-%s)\n\n%s' % (
-            placeholder.thread.url(), placeholder.slug, self.text)
-        reply_tree = self.query.find(dict(slug=reply_re)).all()
-        for post in reply_tree:
-            post.slug = new_slug[0] + post.slug[len(old_slug[0]):]
-            post.full_slug = new_slug[1] + post.slug[len(old_slug[1]):]
-            post.discussion_id = self.discussion_id
-            post.thread_id = self.thread_id
-        for post in [self] + reply_tree:
-            for att in post.attachments:
-                att.discussion_id = self.discussion_id
-                att.thread_id = self.thread_id
-
 
 class ForumAttachment(M.DiscussionAttachment):
     DiscussionClass = Forum

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index e23f38a..a42a025 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -246,18 +246,10 @@ class TestForumAsync(TestController):
             if 'attachment' in link.get('href', ''):
                 self.app.get(str(link['href']))
                 self.app.post(str(link['href']), params=dict(delete='on'))
-        # Moderate
-        r = self.app.post(url + 'moderate',
-                          params=dict(subject='New Thread', delete='', promote='on'))
-        # Find new location
-        r = self.app.get(url)
-        link = [a for a in r.html.findAll('a')
-                if a.renderContents() == 'here']
-        url, slug = str(link[0]['href']).split('#')
-        slug = slug.split('-')[-1]
-        reply_slug = slug + str(reply.slug[4:])
+        reply_slug = str(reply.slug)
         r = self.app.post(url + reply_slug + '/moderate',
                           params=dict(subject='', delete='on'))
+        slug = reply_slug[:4]
         r = self.app.post(url + slug + '/moderate',
                           params=dict(subject='', delete='on'))
 
@@ -532,8 +524,6 @@ class TestForum(TestController):
         assert thread.html.findAll(
             'div', {'class': 'display_post'})[1].find('p').string == 'bbb'
         assert thread.response.body.count(
-            '<div class="promote_to_thread_form') == 1
-        assert thread.response.body.count(
             '<div class="row reply_post_form') == 2
         assert thread.response.body.count('<div class="edit_post_form') == 2
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/ForgeDiscussion/forgediscussion/widgets/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/widgets/__init__.py b/ForgeDiscussion/forgediscussion/widgets/__init__.py
index e1f6dd5..f733ddb 100644
--- a/ForgeDiscussion/forgediscussion/widgets/__init__.py
+++ b/ForgeDiscussion/forgediscussion/widgets/__init__.py
@@ -16,5 +16,5 @@
 #       under the License.
 
 from forum_widgets import ForumSubscriptionForm, ThreadSubscriptionForm, AnnouncementsTable
-from forum_widgets import ModerateThread, ModeratePost, PromoteToThread, ForumHeader, ThreadHeader
+from forum_widgets import ModerateThread, ForumHeader, ThreadHeader
 from forum_widgets import Post, Thread, Forum

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b4c1476/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py b/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
index 7e9debb..f11d240 100644
--- a/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
+++ b/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
@@ -127,21 +127,6 @@ class ModerateThread(CsrfForm):
         delete = ew.SubmitButton(label='Delete Thread')
 
 
-class ModeratePost(CsrfForm):
-    submit_text = None
-    fields = [
-        ew.FieldSet(legend='Promote post to its own thread', fields=[
-            ew.TextField(name='subject', label='Thread title'),
-            ew.SubmitButton(name='promote', label='Promote to thread')])]
-
-
-class PromoteToThread(CsrfForm):
-    submit_text = None
-    fields = [
-        ew.TextField(name='subject', label='Thread title'),
-        ew.SubmitButton(name='promote', label='Promote to thread')]
-
-
 class ForumHeader(DW.DiscussionHeader):
     template = 'jinja:forgediscussion:templates/discussion_widgets/forum_header.html'
     widgets = dict(DW.DiscussionHeader.widgets,
@@ -161,9 +146,6 @@ class ThreadHeader(DW.ThreadHeader):
 
 class Post(DW.Post):
     show_subject = False
-    widgets = dict(DW.Post.widgets,
-                   promote_to_thread=PromoteToThread())
-
 
 class Thread(DW.Thread):
     defaults = dict(


Mime
View raw message