[IMP] improved code for filter as new changes landedn in trunk
bzr revid: tpa@tinyerp.com-20140312070735-2np27bur8d7cd3nv
This commit is contained in:
parent
f00a9f484d
commit
c30ab24004
|
@ -54,7 +54,7 @@ class website_forum(http.Controller):
|
|||
return request.redirect("/forum/%s" % forum_id)
|
||||
|
||||
@http.route(['/forum/<model("website.forum"):forum>', '/forum/<model("website.forum"):forum>/page/<int:page>'], type='http', auth="public", website=True, multilang=True)
|
||||
def questions(self, forum, page=1, **searches):
|
||||
def questions(self, forum, page=1, filters='', **searches):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Forum = request.registry['website.forum.post']
|
||||
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False)]
|
||||
|
@ -65,13 +65,12 @@ class website_forum(http.Controller):
|
|||
('name', 'ilike', search),
|
||||
('content', 'ilike', search)]
|
||||
|
||||
type = searches.get('type',False)
|
||||
if not type:
|
||||
searches['type'] = 'all'
|
||||
if type == 'unanswered':
|
||||
if not filters:
|
||||
filters = 'all'
|
||||
if filters == 'unanswered':
|
||||
domain += [ ('child_ids', '=', False) ]
|
||||
#TODO: update domain to show followed questions of user
|
||||
if type == 'followed':
|
||||
if filters == 'followed':
|
||||
domain += [ ('create_uid', '=', uid) ]
|
||||
|
||||
step = 10
|
||||
|
@ -86,6 +85,7 @@ class website_forum(http.Controller):
|
|||
'question_ids': question_ids,
|
||||
'forum': forum,
|
||||
'pager': pager,
|
||||
'filters': filters,
|
||||
'searches': searches,
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
</div>
|
||||
<div class="collapse navbar-collapse" id="oe-help-navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li t-att-class="searches.get('type') in ('all', 'unanswered','followed','question') and 'active' or '' ">
|
||||
<li t-att-class="filters in ('all', 'unanswered','followed','question') and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }">Questions</a>
|
||||
</li>
|
||||
<li t-att-class="searches.get('users') and 'active' or '' ">
|
||||
|
@ -154,23 +154,23 @@
|
|||
<h1 class="page-header mt0">
|
||||
<t t-esc="total_questions"/>
|
||||
<span>Questions</span>
|
||||
<small class="dropdown" t-if="searches.get('type') in ('all', 'unanswered','followed')">
|
||||
<small class="dropdown" t-if="filters in ('all', 'unanswered','followed')">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<t t-if="searches.get('type') == 'all'">No filter</t>
|
||||
<t t-if="searches.get('type') == 'unanswered'">Filter: Unanswered</t>
|
||||
<t t-if="searches.get('type') == 'followed'">Filter: Followed</t>
|
||||
<t t-if="filters == 'all'">No filter</t>
|
||||
<t t-if="filters == 'unanswered'">filter: Unanswered</t>
|
||||
<t t-if="filters == 'followed'">filter: Followed</t>
|
||||
<b class="caret"/>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Filter on</li>
|
||||
<li t-att-class="searches.get('type') == 'all' and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/?{{ keep_query( type='all') }}">All</a>
|
||||
<li t-att-class="filters == 'all' and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( filters='all') }}">All</a>
|
||||
</li>
|
||||
<li t-att-class="searches.get('type') == 'unanswered' and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/?{{ keep_query( type='unanswered') }}">Unanswered</a>
|
||||
<li t-att-class="filters == 'unanswered' and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( filters='unanswered') }}">Unanswered</a>
|
||||
</li>
|
||||
<li t-att-class="searches.get('type') == 'followed' and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/?{{ keep_query( type='followed') }}">Followed</a>
|
||||
<li t-att-class="filters == 'followed' and 'active' or '' ">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }?{{ keep_query( filters='followed') }}">Followed</a>
|
||||
</li>
|
||||
<li class="dropdown-header">Sort by</li>
|
||||
<li>
|
||||
|
|
Loading…
Reference in New Issue