[IMP] improved code to add link at footer to show all forums, improved serch and...
authorTurkesh Patel (Open ERP) <tpa@tinyerp.com>
Wed, 9 Apr 2014 12:09:56 +0000 (17:39 +0530)
committerTurkesh Patel (Open ERP) <tpa@tinyerp.com>
Wed, 9 Apr 2014 12:09:56 +0000 (17:39 +0530)
bzr revid: tpa@tinyerp.com-20140409120956-9yf4z2x1cxclk0f8

addons/website_forum/controllers/main.py
addons/website_forum/static/src/js/website_forum.editor.js
addons/website_forum/static/src/xml/website_forum.xml
addons/website_forum/views/website_forum.xml

index 403d54d..d2d44f9 100644 (file)
@@ -60,14 +60,13 @@ class website_forum(http.Controller):
                  '/forum/<model("website.forum"):forum>/tag/<model("website.forum.tag"):tag>/questions'
         ], type='http', auth="public", website=True, multilang=True)
 
-    def questions(self, forum, tag='', page=1, filters='', sorting='', **searches):
+    def questions(self, forum, tag='', page=1, filters='', sorting='', search='', **searches):
         cr, uid, context = request.cr, request.uid, request.context
         Forum = request.registry['website.forum.post']
         user = request.registry['res.users'].browse(cr, uid, uid, context=context)
         domain = [('forum_id', '=', forum.id), ('parent_id', '=', False)]
         order = "id desc"
 
-        search = searches.get('search',False)
         if search:
             domain += ['|',
                 ('name', 'ilike', search),
@@ -112,6 +111,7 @@ class website_forum(http.Controller):
             'tag': tag,
             'filters': filters,
             'sorting': sorting,
+            'search': search,
             'searches': searches,
         }
 
index 4c4887f..11b22d5 100644 (file)
@@ -14,7 +14,7 @@
             return res;
         },
         events: _.extend({}, website.EditorBar.prototype.events, {
-            'click a[data-action=new_question]': function (ev) {
+            'click a[data-action=new_forum]': function (ev) {
                 ev.preventDefault();
                 website.prompt({
                     id: "editor_new_forum",
index 220f394..f2298b8 100644 (file)
@@ -1,7 +1,7 @@
 <templates id="template" xml:space="preserve">
     <t t-extend="website.editorbar">
         <t t-jquery="ul.oe_content_menu" t-operation="append">
-            <li><a href="#" data-action="new_question">New Forum</a></li>
+            <li><a href="#" data-action="new_forum">New Forum</a></li>
         </t>
     </t>
 </templates>
\ No newline at end of file
index ce0bd92..3d8bad7 100644 (file)
             name="Footer Questions Link">
             <xpath expr="//footer//ul[@name='products']" position="inside">
                 <li>
-                    <a t-attf-href="/forum/%(website_forum.forum_help)d/">Q&amp;A</a>
+                    <a t-attf-href="/forum/%(website_forum.forum_help)d">Q&amp;A</a>
+                </li>
+                <li>
+                    <a href="/forum">Forums</a>
                 </li>
             </xpath>
         </template>
                                 <div class="form-group">
                                     <input type="search" class="form-control"
                                         name="search" placeholder="Search a question..."
-                                        t-att-value="searches.get('search') or ''"/>
+                                        t-att-value="search or ''"/>
                                     <button type="submit" class="btn btn-default">Search</button>
                                 </div>
                             </form>
             </t>
         </template>
 
-        <template id="index">
+        <template id="index" name="Forum">
             <t t-call="website_forum.header">
                 <h1 class="page-header mt0">
                     <t t-esc="total_questions"/>
                     <span>Questions</span>
+                    <t t-esc="search"/>
                     <small class="dropdown" t-if="filters in ('all', 'unanswered','followed', 'tag')">
                       <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                           <t t-if="filters == 'all'">All</t>
                       <ul class="dropdown-menu">
                           <li class="dropdown-header">Filter on</li>
                           <li t-att-class="filters == 'all' and 'active' or '' ">
-                              <a t-att-href="url_for('') + '?' + keep_query( 'sorting', filters='all')">All</a>
+                              <a t-att-href="url_for('') + '?' + keep_query( 'search', 'sorting', filters='all')">All</a>
                           </li>
                           <li t-att-class="filters == 'unanswered' and 'active' or '' ">
-                              <a t-att-href="url_for('') + '?' + keep_query( 'sorting', filters='unanswered')">Unanswered</a>
+                              <a t-att-href="url_for('') + '?' + keep_query( 'search', 'sorting', filters='unanswered')">Unanswered</a>
                           </li>
                           <li t-if="uid" t-att-class="filters == 'followed' and 'active' or '' ">
-                              <a t-att-href="url_for('') + '?' + keep_query( 'sorting', filters='followed')">Followed</a>
+                              <a t-att-href="url_for('') + '?' + keep_query( 'search', 'sorting', filters='followed')">Followed</a>
                           </li>
                           <li t-if="tag" t-att-class="tag and 'active' or '' ">
                               <a href=""><t t-esc="tag.name"/> Tag</a>
                           </li>
                           <li class="dropdown-header">Sort by</li>
                           <li t-att-class="sorting == 'date' and 'active' or '' ">
-                              <a t-att-href="url_for('') + '?' + keep_query( 'filters', sorting='date')">Last activity date</a>
+                              <a t-att-href="url_for('') + '?' + keep_query( 'search', 'filters', sorting='date')">Last activity date</a>
                           </li>
                           <li t-att-class="sorting == 'answered' and 'active' or '' ">
-                              <a t-att-href="url_for('') + '?' + keep_query( 'filters', sorting='answered')">Most answered</a>
+                              <a t-att-href="url_for('') + '?' + keep_query( 'search', 'filters', sorting='answered')">Most answered</a>
                           </li>
                           <li t-att-class="sorting == 'vote' and 'active' or '' ">
-                              <a t-att-href="url_for('') + '?' + keep_query( 'filters', sorting='vote')">Most voted</a>
+                              <a t-att-href="url_for('') + '?' + keep_query( 'search', 'filters', sorting='vote')">Most voted</a>
                           </li>
                       </ul>
                     </small>
                     </t>
                     <b><t t-esc="user.karma"/></b>
                     <t t-raw="separator"/>
-                        <div>
-                            <b> badges:</b>
-                            <span class="fa fa-circle badge-gold"/>
-                            <t t-esc="user.gold_badge"/>
-                            <span class="fa fa-circle badge-silver"/>
-                            <t t-esc="user.silver_badge"/>
-                            <span class="fa fa-circle badge-bronze"/>
-                            <t t-esc="user.bronze_badge"/>
-                        </div>
-                        <t t-raw="0"/>
+                    <div>
+                        <b> badges:</b>
+                        <span class="fa fa-circle badge-gold"/>
+                        <t t-esc="user.gold_badge"/>
+                        <span class="fa fa-circle badge-silver"/>
+                        <t t-esc="user.silver_badge"/>
+                        <span class="fa fa-circle badge-bronze"/>
+                        <t t-esc="user.bronze_badge"/>
+                    </div>
+                    <t t-raw="0"/>
                 </div>
             </div>
         </template>
                                     </t>
                                 </div>
                                 <ul class="list-inline">
-                                    <li>
+                                    <li t-if="user.id == question.user_id.id or user.karma&gt;=50">
                                         <a style="cursor: pointer" data-toggle="collapse" class="text-muted fa fa-comment-o"
                                               t-attf-data-target="#comment#{ question._name.replace('.','') + '-' + str(question.id) }">
                                             comment
                             <t t-raw="answer.content"/>
                             <div class="mt16">
                                 <ul class="list-inline pull-right">
-                                    <li>
+                                    <li t-if="user.id == answer.user_id.id or user.karma&gt;=50">
                                         <a style="cursor: pointer" data-toggle="collapse" class="text-muted fa fa-comment-o"
                                               t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }">comment
                                         </a>
                                     <li t-if="user.id == answer.user_id.id or user.karma&gt;=1000">
                                         <a class="text-muted delete fa fa-trash-o" href="" t-attf-id="#{answer.id}">delete</a>
                                     </li>
-                                    <li t-if="uid">
+                                    <li t-if="user.id == answer.user_id.id">
                                         <a class="text-muted fa fa-magic" t-attf-href="/forum/#{ slug(forum) }/post/#{ answer.id }/converttocomment">Convert as a comment</a>
                                     </li>
                                     <li><a class="text-muted fa fa-share" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/#answer-#{ answer.id }">share</a></li>
                     <li>
                         <a href="#badges" data-toggle="tab">Badges</a>
                     </li>
-                    <li>
+                    <li t-if="uid == user.id">
                         <a href="#votes" data-toggle="tab">Votes</a>
                     </li>
                 </ul>