incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [08/50] git commit: [#4902] ticket:330 set current forum as default
Date Fri, 24 May 2013 18:17:44 GMT
[#4902]  ticket:330  set current forum as default


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

Branch: refs/heads/db/6007
Commit: 4ee67b6f2989b685ba810581785d2600ccef9be2
Parents: d786c63
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Thu May 2 23:19:27 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed May 22 14:56:16 2013 +0000

----------------------------------------------------------------------
 .../allura/templates/widgets/new_topic_post.html   |    2 +-
 .../forgediscussion/controllers/root.py            |   10 +++++++++-
 .../templates/discussionforums/create_topic.html   |    2 +-
 .../forgediscussion/tests/functional/test_forum.py |    4 ++++
 4 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ee67b6f/Allura/allura/templates/widgets/new_topic_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/new_topic_post.html b/Allura/allura/templates/widgets/new_topic_post.html
index bc1450a..d6f63a0 100644
--- a/Allura/allura/templates/widgets/new_topic_post.html
+++ b/Allura/allura/templates/widgets/new_topic_post.html
@@ -30,7 +30,7 @@
       <label for="{{ widget.context_for(widget.fields.forum)['id'] }}" class="cr">Forum:</label>
       <select id="{{ widget.context_for(widget.fields.forum)['id'] }}" name="{{ widget.context_for(widget.fields.forum)['rendered_name']
}}">
         {% for forum in forums %}
-          <option value="{{forum.shortname}}">{{forum.name}}</option>
+          <option value="{{forum.shortname}}"{% if forum.shortname==current_forum %}selected{%
endif %}>{{forum.name}}</option>
         {% endfor %}
       </select>
     </div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ee67b6f/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 8e074aa..f64dcf4 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -96,11 +96,19 @@ class RootController(BaseController, DispatchIndex, FeedController):
     @with_trailing_slash
     @expose('jinja:forgediscussion:templates/discussionforums/create_topic.html')
     def create_topic(self, new_forum=False, **kw):
+        forums = model.Forum.query.find(dict(app_config_id=c.app.config._id,
+                                             parent_id=None,
+                                             deleted=False))
+        current_forum = None
+        for f in forums:
+                if request.referer and (f.url() in request.referer):
+                    current_forum = f.shortname
+
         c.new_topic = self.W.new_topic
         forums = [f for f in model.Forum.query.find(dict(
                              app_config_id=c.app.config._id,
                              parent_id=None)).all() if has_access(f, 'post')() and not f.deleted]
-        return dict(forums=forums)
+        return dict(forums=forums, current_forum=current_forum)
 
     @h.vardec
     @expose()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ee67b6f/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
b/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
index 79afdbe..b5e560f 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
@@ -27,7 +27,7 @@
   <p>You do not have permission to post in any forums.</p>
 {% else %}
   <div class="editbox">
-    {{c.new_topic.display(action=c.app.url + 'save_new_topic',show_subject=True,forums=forums)}}
+    {{c.new_topic.display(action=c.app.url + 'save_new_topic',show_subject=True,forums=forums,
current_forum=current_forum)}}
     <div class="clear"></div>
   </div>
 {% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4ee67b6f/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 73b6682..f7cfd1c 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -733,3 +733,7 @@ class TestForum(TestController):
         for ext in ['', '.rss', '.atom']:
             self.app.get('/discussion/feed%s' % ext, status=200)
             self.app.get('/discussion/general/feed%s' % ext, status=200)
+
+    def test_create_topic(self):
+        r = self.app.get('/p/test/discussion/create_topic/', headers={'Referer':'/p/test/discussion/testforum/'})
+        assert '<option value="testforum"selected>Test Forum</option>' in r
\ No newline at end of file


Mime
View raw message