[ADD] website_forum: adding the 'Newest' filter on the forum to sort by create date
authorMartin Trigaux <mat@openerp.com>
Thu, 15 May 2014 09:23:11 +0000 (11:23 +0200)
committerMartin Trigaux <mat@openerp.com>
Thu, 15 May 2014 09:23:11 +0000 (11:23 +0200)
addons/website_forum/controllers/main.py
addons/website_forum/views/website_forum.xml

index 78c4760..69a420b 100644 (file)
@@ -112,9 +112,11 @@ class WebsiteForum(http.Controller):
             order = 'child_count desc'
         elif sorting == 'vote':
             order = 'vote_count desc'
-        else:
-            sorting = 'date'
+        elif sorting == 'date':
             order = 'write_date desc'
+        else:
+            sorting = 'creation'
+            order = 'create_date desc'
 
         question_count = Post.search(cr, uid, domain, count=True, context=context)
         if tag:
index 7cefe20..66b1302 100644 (file)
                   <t t-if="filters == 'followed'">Followed</t>
                   <t t-if="tag"><span t-field="tag.name"/></t>
                   <t t-if="sorting == 'date'"> by activity date</t>
+                  <t t-if="sorting == 'creation'"> by creation date</t>
                   <t t-if="sorting == 'answered'"> by most answered</t>
                   <t t-if="sorting == 'vote'"> by most voted</t>
                   <b class="caret"/>
                   <li t-att-class="sorting == 'date' and 'active' or '' ">
                       <a t-att-href="url_for('') + '?' + keep_query( 'search', 'filters', sorting='date')">Last activity date</a>
                   </li>
+                  <li t-att-class="sorting == 'creation' and 'active' or '' ">
+                      <a t-att-href="url_for('') + '?' + keep_query( 'search', 'filters', sorting='creation')">Newest</a>
+                  </li>
                   <li t-att-class="sorting == 'answered' and 'active' or '' ">
                       <a t-att-href="url_for('') + '?' + keep_query( 'search', 'filters', sorting='answered')">Most answered</a>
                   </li>