allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [5/9] allura git commit: [#7981] frontend bugfix, cleanup, and consolidation
Date Mon, 05 Dec 2016 16:39:38 GMT
[#7981] frontend bugfix, cleanup, and consolidation


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

Branch: refs/heads/master
Commit: a02c9137d4965eb59637b2325a44fd56c7be2f2f
Parents: a7ef457
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Nov 18 17:08:24 2016 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon Dec 5 11:39:20 2016 -0500

----------------------------------------------------------------------
 Allura/allura/lib/widgets/__init__.py           |  4 +-
 Allura/allura/lib/widgets/discuss.py            | 26 ---------
 Allura/allura/model/discuss.py                  |  2 +
 Allura/allura/templates/widgets/discussion.html | 26 ---------
 .../templates/widgets/discussion_header.html    | 19 ------
 .../allura/templates/widgets/threads_table.html |  7 +--
 Allura/allura/tests/model/test_discussion.py    |  7 ---
 Allura/allura/tests/model/test_notification.py  |  2 +-
 .../forgediscussion/controllers/root.py         | 30 ----------
 .../discussion_widgets/forum_summary.html       | 28 ---------
 .../forgediscussion/widgets/__init__.py         |  4 +-
 .../forgediscussion/widgets/forum_widgets.py    | 61 +++++++-------------
 12 files changed, 30 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/lib/widgets/__init__.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/__init__.py b/Allura/allura/lib/widgets/__init__.py
index 9d21e37..3e8e798 100644
--- a/Allura/allura/lib/widgets/__init__.py
+++ b/Allura/allura/lib/widgets/__init__.py
@@ -15,12 +15,12 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-from .discuss import Post, Thread, Discussion
+from .discuss import Post, Thread
 from .subscriptions import SubscriptionForm
 from .oauth_widgets import OAuthApplicationForm, OAuthRevocationForm
 from .auth_widgets import LoginForm, ForgottenPasswordForm, DisableAccountForm
 from .vote import VoteForm
 
 __all__ = [
-    'Post', 'Thread', 'Discussion', 'SubscriptionForm', 'OAuthApplicationForm', 'OAuthRevocationForm',
'LoginForm',
+    'Post', 'Thread', 'SubscriptionForm', 'OAuthApplicationForm', 'OAuthRevocationForm',
'LoginForm',
     'ForgottenPasswordForm', 'DisableAccountForm', 'VoteForm']

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 98f60ca..2d1fb1d 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -254,14 +254,6 @@ class Attachment(ew_core.Widget):
     post = None
 
 
-class DiscussionHeader(HierWidget):
-    template = 'jinja:allura:templates/widgets/discussion_header.html'
-    params = ['value']
-    value = None
-    widgets = dict(
-        edit_post=EditPost(submit_text='New Thread'))
-
-
 class ThreadHeader(HierWidget):
     template = 'jinja:allura:templates/widgets/thread_header.html'
     defaults = dict(
@@ -516,21 +508,3 @@ class Thread(HierWidget):
             }
         });
         ''')
-
-
-class Discussion(HierWidget):
-    template = 'jinja:allura:templates/widgets/discussion.html'
-    defaults = dict(
-        HierWidget.defaults,
-        value=None,
-        threads=None,
-        show_subject=False,
-        allow_create_thread=False)
-    widgets = dict(
-        discussion_header=DiscussionHeader(),
-        edit_post=EditPost(submit_text='New Topic'),
-        subscription_form=SubscriptionForm())
-
-    def resources(self):
-        for r in super(Discussion, self).resources():
-            yield r

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 2af6146..257ac38 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -242,6 +242,8 @@ class Thread(Artifact, ActivityObject):
 
     @property
     def artifact(self):
+        # Threads attached to a wiki page, ticket, etc will have a .ref.artifact pointing
to that WikiPage etc
+        # Threads that are part of a forum will not have that
         if self.ref is None:
             return self.discussion
         return self.ref.artifact

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/templates/widgets/discussion.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/discussion.html b/Allura/allura/templates/widgets/discussion.html
deleted file mode 100644
index 82ee24c..0000000
--- a/Allura/allura/templates/widgets/discussion.html
+++ /dev/null
@@ -1,26 +0,0 @@
-{#-
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--#}
-{{widgets.subscription_form.display(value=value,
-                                    threads=threads,
-                                    action=value.url() + 'subscribe',
-                                    allow_create_thread=allow_create_thread,
-                                    show_subject=show_subject,
-                                    limit=limit,
-                                    page=page,
-                                    count=count)}}

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/templates/widgets/discussion_header.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/discussion_header.html b/Allura/allura/templates/widgets/discussion_header.html
deleted file mode 100644
index b464bfa..0000000
--- a/Allura/allura/templates/widgets/discussion_header.html
+++ /dev/null
@@ -1,19 +0,0 @@
-{#-
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--#}
-<div>{{g.markdown.cached_convert(value, 'description')|safe}}</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/templates/widgets/threads_table.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/threads_table.html b/Allura/allura/templates/widgets/threads_table.html
index bc20d29..873b537 100644
--- a/Allura/allura/templates/widgets/threads_table.html
+++ b/Allura/allura/templates/widgets/threads_table.html
@@ -22,7 +22,7 @@
   <table class="forum-list clear">
     <thead>
       <tr>
-        {% if not c.user.is_anonymous() %}
+        {% if not c.user.is_anonymous() and allow_subscriptions %}
           <th>{{ g.icons['mail'].render(tag='span', title='Subscriptions') }}</th>
         {% endif %}
         <th class="topic">Topic</th>
@@ -34,10 +34,9 @@
     <tbody class="forum-list">
       {% for thread in value %}
       <tr>
-        {% if not c.user.is_anonymous() %}
+        {% if not c.user.is_anonymous() and allow_subscriptions %}
           <td>
-            <input type="checkbox" name="threads-{{loop.index0}}.subscription"
-                 {% if thread.subscribed() %}checked="checked"{% endif %}/>
+            <input type="checkbox" name="threads-{{loop.index0}}.subscription" {% if thread.subscribed()
%}checked="checked"{% endif %} />
             <input type="hidden" name="threads-{{loop.index0}}._id" value="{{thread._id}}"/>
           </td>
         {% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/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 b579d18..0258f38 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -67,7 +67,6 @@ def test_discussion_methods():
     assert d.last_post == None
     assert d.url().endswith('wiki/_discuss/')
     assert d.index()['name_s'] == 'test'
-    assert d.subscription() == None
     assert d.find_posts().count() == 0
     jsn = d.__json__()
     assert jsn['name'] == d.name
@@ -104,12 +103,6 @@ def test_thread_methods():
 
     assert 'wiki/_discuss/' in t.url()
     assert t.index()['views_i'] == 0
-    # FIXME
-    assert not t.subscription
-    t.subscription = True
-    assert t.subscription
-    t.subscription = False
-    assert not t.subscription
     assert t.post_count == 3
     jsn = t.__json__()
     assert '_id' in jsn

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/Allura/allura/tests/model/test_notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_notification.py b/Allura/allura/tests/model/test_notification.py
index 820e22c..f4ba56e 100644
--- a/Allura/allura/tests/model/test_notification.py
+++ b/Allura/allura/tests/model/test_notification.py
@@ -188,7 +188,7 @@ class TestPostNotifications(unittest.TestCase):
         ThreadLocalORMSession.flush_all()
         M.MonQTask.list()
         t = M.MonQTask.get()
-        assert t.args[1] == self.pg.index_id()
+        assert_equal(t.args[1], [self.pg.index_id()])
 
     def test_post_user_notification(self):
         u = M.User.query.get(username='test-admin')

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 8ade51f..24c2ea1 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -56,7 +56,6 @@ log = logging.getLogger(__name__)
 class RootController(BaseController, DispatchIndex, FeedController):
 
     class W(object):
-        forum_subscription_form = FW.ForumSubscriptionForm()
         new_topic = DW.NewTopicPost(submit_text='Post')
 
         announcements_table = FW.AnnouncementsTable()
@@ -186,30 +185,6 @@ class RootController(BaseController, DispatchIndex, FeedController):
         else:
             raise exc.HTTPNotFound()
 
-    @h.vardec
-    @expose()
-    @validate(W.forum_subscription_form)
-    def subscribe(self, **kw):
-        require_authenticated()
-        forum = kw.pop('forum', [])
-        thread = kw.pop('thread', [])
-        objs = []
-        for data in forum:
-            objs.append(
-                dict(obj=model.Forum.query.get(shortname=data['shortname'],
-                                               app_config_id=c.app.config._id),
-                     subscribed=bool(data.get('subscribed'))))
-        for data in thread:
-            objs.append(dict(obj=model.Thread.query.get(_id=data['id']),
-                             subscribed=bool(data.get('subscribed'))))
-        for obj in objs:
-            # TODO where is this called from?
-            if obj['subscribed']:
-                obj['obj'].subscriptions[str(c.user._id)] = True
-            else:
-                obj['obj'].subscriptions.pop(str(c.user._id), None)
-        redirect(request.referer)
-
     def get_feed(self, project, app, user):
         """Return a :class:`allura.controllers.feed.FeedArgs` object describing
         the xml feed for this controller.
@@ -252,11 +227,6 @@ class RootController(BaseController, DispatchIndex, FeedController):
         grouping['year'] = {'$year': '$timestamp'}
         grouping['month'] = {'$month': '$timestamp'}
         grouping['day'] = {'$dayOfMonth': '$timestamp'}
-        {
-            'year': {'$year': '$timestamp'},
-            'month': {'$month': '$timestamp'},
-            'day': {'$dayOfMonth': '$timestamp'},
-        }
         mongo_data = model.ForumPost.query.aggregate([
             {'$match': {
                 'discussion_id': discussion_id_q,

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_summary.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_summary.html
b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_summary.html
deleted file mode 100644
index a795858..0000000
--- a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_summary.html
+++ /dev/null
@@ -1,28 +0,0 @@
-{#-
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--#}
-<a href="{{value.url()}}">{{value.name}}</a>({{value.shortname}})<br/>
-{% if value.subforums %}
-  <b>Subforums:</b>
-  {% for sf in value.subforums %}
-    <span>
-      {% if loop.index0 != 0 %}, {% endif %}
-      <a href="{{sf.url()}}">{{sf.name}}</a>
-    </span>
-  {% endfor %}
-{% endif %}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/ForgeDiscussion/forgediscussion/widgets/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/widgets/__init__.py b/ForgeDiscussion/forgediscussion/widgets/__init__.py
index 53322a7..02bbb9e 100644
--- a/ForgeDiscussion/forgediscussion/widgets/__init__.py
+++ b/ForgeDiscussion/forgediscussion/widgets/__init__.py
@@ -15,10 +15,10 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-from forum_widgets import ForumSubscriptionForm, ThreadSubscriptionForm, AnnouncementsTable
+from forum_widgets import ThreadSubscriptionForm, AnnouncementsTable
 from forum_widgets import ModerateThread, ForumHeader, ThreadHeader
 from forum_widgets import Post, Thread, Forum
 
 __all__ = [
-    'ForumSubscriptionForm', 'ThreadSubscriptionForm', 'AnnouncementsTable', 'ModerateThread',
'ForumHeader',
+    'ThreadSubscriptionForm', 'AnnouncementsTable', 'ModerateThread', 'ForumHeader',
     'ThreadHeader', 'Post', 'Thread', 'Forum']

http://git-wip-us.apache.org/repos/asf/allura/blob/a02c9137/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py b/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
index 8c0c07f..fb063d9 100644
--- a/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
+++ b/ForgeDiscussion/forgediscussion/widgets/forum_widgets.py
@@ -30,35 +30,6 @@ from allura.lib.widgets.subscriptions import SubscribeForm
 from forgediscussion import model as M
 
 
-class _ForumSummary(ew_core.Widget):
-    template = 'jinja:forgediscussion:templates/discussion_widgets/forum_summary.html'
-    defaults = dict(
-        ew_core.Widget.defaults,
-        name=None,
-        value=None,
-        show_label=True,
-        label=None)
-
-
-class _ForumsTable(ew.TableField):
-
-    class fields(ew_core.NameList):
-        _id = ew.HiddenField(validator=V.Ming(M.ForumThread))
-        num_topics = ffw.DisplayOnlyField(show_label=True, label='Topics')
-        num_posts = ffw.DisplayOnlyField(show_label=True, label='Posts')
-        last_post = ffw.DisplayOnlyField(show_label=True)
-        subscribed = ew.Checkbox(suppress_label=True, show_label=True)
-    fields.insert(0, _ForumSummary())
-
-
-class ForumSubscriptionForm(CsrfForm):
-
-    class fields(ew_core.NameList):
-        forums = _ForumsTable()
-        page_list = ffw.PageList()
-    submit_text = 'Update Subscriptions'
-
-
 class _ThreadsTable(DW._ThreadsTable):
 
     class fields(ew_core.NameList):
@@ -71,7 +42,7 @@ class _ThreadsTable(DW._ThreadsTable):
         flags = ffw.DisplayOnlyField(show_label=True)
         last_post = ffw.DisplayOnlyField(show_label=True)
         subscription = ew.Checkbox(suppress_label=True, show_label=True)
-    defaults = dict(DW._ThreadsTable.defaults, div_id='forum_threads')
+    defaults = dict(DW._ThreadsTable.defaults, div_id='forum_threads', allow_subscriptions=True)
 
 
 class ThreadSubscriptionForm(DW.SubscriptionForm):
@@ -93,7 +64,7 @@ class AnnouncementsTable(DW._ThreadsTable):
         num_views = ffw.DisplayOnlyField(show_label=True)
         flags = ffw.DisplayOnlyField(show_label=True)
         last_post = ffw.DisplayOnlyField(show_label=True)
-    defaults = dict(DW._ThreadsTable.defaults, div_id='announcements')
+    defaults = dict(DW._ThreadsTable.defaults, div_id='announcements', allow_subscriptions=False)
     name = 'announcements'
 
 
@@ -127,11 +98,13 @@ class ModerateThread(CsrfForm):
         delete = ew.SubmitButton(label='Delete Thread')
 
 
-class ForumHeader(DW.DiscussionHeader):
+class ForumHeader(DW.HierWidget):
     template = 'jinja:forgediscussion:templates/discussion_widgets/forum_header.html'
-    widgets = dict(DW.DiscussionHeader.widgets,
+    params = ['value']
+    value = None
+    widgets = dict(DW.HierWidget.widgets,
                    announcements_table=AnnouncementsTable(),
-                   forum_subscription_form=ForumSubscriptionForm())
+                   )
 
 
 class ThreadHeader(DW.ThreadHeader):
@@ -157,13 +130,19 @@ class Thread(DW.Thread):
                    post=Post())
 
 
-class Forum(DW.Discussion):
+class Forum(DW.HierWidget):
     template = 'jinja:forgediscussion:templates/discussion_widgets/discussion.html'
-    allow_create_thread = True
-    show_subject = True
-    widgets = dict(DW.Discussion.widgets,
-                   discussion_header=ForumHeader(),
-                   forum_subscription_form=ForumSubscriptionForm(),
-                   whole_forum_subscription_form=SubscribeForm(),
+    defaults = dict(
+        DW.HierWidget.defaults,
+        value=None,
+        threads=None,
+        show_subject=True,
+        allow_create_thread=True
+    )
+    widgets = dict(DW.HierWidget.widgets,
                    subscription_form=ThreadSubscriptionForm()
                    )
+
+    def resources(self):
+        for r in super(Forum, self).resources():
+            yield r


Mime
View raw message