[IMP] website_event

bzr revid: chm@openerp.com-20130805124428-9pnqbdb68lruqnxq
This commit is contained in:
Christophe Matthieu 2013-08-05 14:44:28 +02:00
parent b1f0bc68c6
commit 9cd3d8132b
3 changed files with 25 additions and 22 deletions

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from openerp import SUPERUSER_ID
from openerp.addons.web import http
from openerp.addons.web.http import request
from openerp.addons.website import website
@ -15,8 +16,11 @@ class website_hr(http.Controller):
@http.route(['/event'], type='http', auth="public")
def events(self, **searches):
data_obj = request.registry['event.event']
event_obj = request.registry['event.event']
searches.setdefault('date', 'all')
searches.setdefault('type', 'all')
domain_search = {}
def sd(date):
return date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
@ -45,14 +49,21 @@ class website_hr(http.Controller):
0],
]
domain_search = {
'date': 'all'
}
# search domains
for date in dates:
if searches.get("date") == date[0]:
domain_search["date"] = date[2]
if searches.get("type") and searches.get("type") != 'all':
domain_search["type"] = [("type", "=", searches.get("type"))]
domain = [(1, "=", 1)]
for key, search in domain_search.items():
if key != 'type':
domain += search
types = event_obj.read_group(request.cr, request.uid, domain, ["id", "type"], groupby="type", orderby="type")
types.insert(0, {'type_count': event_obj.search(request.cr, request.uid, domain, count=True), 'type': ("all", _("All Categories"))})
# count by domains without self search
domain = [(1, "=", 1)]
@ -60,7 +71,7 @@ class website_hr(http.Controller):
if key != 'date':
domain += search
for date in dates:
date[3] = data_obj.search(request.cr, request.uid, domain + date[2], count=True)
date[3] = event_obj.search(request.cr, request.uid, domain + date[2], count=True)
@ -69,10 +80,11 @@ class website_hr(http.Controller):
for key, search in domain_search.items():
domain += search
obj_ids = data_obj.search(request.cr, request.uid, domain)
obj_ids = event_obj.search(request.cr, request.uid, domain)
values = {
'event_ids': data_obj.browse(request.cr, request.uid, obj_ids),
'event_ids': event_obj.browse(request.cr, request.uid, obj_ids),
'dates': dates,
'types': types,
'searches': searches,
'search_path': "?%s" % urllib.urlencode(searches),
}

View File

@ -49,18 +49,11 @@
</ul>
<ul class="nav nav-list">
<li class="nav-header">Category</li>
<li class="active">
<a >All Categories <span>(27)</span></a>
</li>
<li>
<a >Conferences <span>(18)</span></a>
</li>
<li>
<a >Business <span>(18)</span></a>
</li>
<li>
<a>Classes <span>(9)</span></a>
</li>
<t t-foreach="types">
<li t-att-class="searches.get('type') == type[0] and 'active' or ''">
<a t-att-href="'/event/%%s&amp;type=%%s' %% (search_path, type[0])"><t t-esc="type[1]"/> <small>(<t t-esc="type_count"/>)</small></a>
</li>
</t>
</ul>
<ul class="nav nav-list">
<li class="nav-header">Location</li>

View File

@ -49,8 +49,6 @@ class website_mail(http.Controller):
if blog_id:
values['blog_id'] = message_obj.browse(request.cr, request.uid, blog_id)
comment_ids = [child_id.id for child_id in values['blog_id'].child_ids]
values['comments'] = message_obj.read(request.cr, request.uid, comment_ids, ['website_published', 'author_id', 'date', 'body'])
html = website.render("website_mail.index", values)
return html