[IMP] website_mail, website_event
bzr revid: chm@openerp.com-20130805102110-5kupl0xdb8tw3x5m
This commit is contained in:
parent
04458109a2
commit
b1f0bc68c6
|
@ -8,18 +8,15 @@ from openerp.tools.translate import _
|
|||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from openerp import tools
|
||||
import urllib
|
||||
|
||||
|
||||
class website_hr(http.Controller):
|
||||
|
||||
@http.route(['/event', '/event/search/<path:searches>'], type='http', auth="public")
|
||||
def events(self, searches=None, **post):
|
||||
@http.route(['/event'], type='http', auth="public")
|
||||
def events(self, **searches):
|
||||
data_obj = request.registry['event.event']
|
||||
|
||||
_search = {}
|
||||
for search in searches.split("/"):
|
||||
search = search.split("-")
|
||||
if len(search) == 2:
|
||||
_search[search[0]] = [search[1], []]
|
||||
searches.setdefault('date', 'all')
|
||||
|
||||
def sd(date):
|
||||
return date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
@ -48,32 +45,36 @@ class website_hr(http.Controller):
|
|||
0],
|
||||
]
|
||||
|
||||
domain_search = {
|
||||
'date': 'all'
|
||||
}
|
||||
|
||||
# search domains
|
||||
for date in dates:
|
||||
if _search.get("date") and _search["date"][0] == date[0]:
|
||||
_search["date"].append(date[2])
|
||||
if searches.get("date") == date[0]:
|
||||
domain_search["date"] = date[2]
|
||||
|
||||
# count by domains without self search
|
||||
domain = [(1, "=", 1)]
|
||||
for key, search in domain_search.items():
|
||||
if key != 'date':
|
||||
domain += search
|
||||
for date in dates:
|
||||
domain = [(1, "=", 1)]
|
||||
for key, search in _search.items():
|
||||
if key != 'date':
|
||||
domain += search[1]
|
||||
date[3] = data_obj.search(request.cr, request.uid, domain + date[2], count=True)
|
||||
|
||||
|
||||
|
||||
# domain and search_path
|
||||
domain = [(1, "=", 1)]
|
||||
search_path = '/search'
|
||||
for key, search in _search.items():
|
||||
search_path = "%s/%s-%s" % (search_path, key, search[0])
|
||||
domain += search[1]
|
||||
for key, search in domain_search.items():
|
||||
domain += search
|
||||
|
||||
obj_ids = data_obj.search(request.cr, request.uid, domain)
|
||||
values = {
|
||||
'event_ids': data_obj.browse(request.cr, request.uid, obj_ids),
|
||||
'dates': dates,
|
||||
'search': _search,
|
||||
'search_path': search_path,
|
||||
'searches': searches,
|
||||
'search_path': "?%s" % urllib.urlencode(searches),
|
||||
}
|
||||
|
||||
html = website.render("website_event.index", values)
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Date</li>
|
||||
<t t-foreach="dates" t-as="date">
|
||||
<li t-att-class="search.get('date')[0] == date[0] and 'active' or ''">
|
||||
<a t-att-href="'/event%%s/date-%%s' %% (search_path, date[0])"><t t-esc="date[1]"/> <small t-if="date[3]">(<t t-esc="date[3]"/>)</small></a>
|
||||
<li t-att-class="searches.get('date') == date[0] and 'active' or ''">
|
||||
<a t-att-href="'/event/%%s&date=%%s' %% (search_path, date[0])"><t t-esc="date[1]"/> <small t-if="date[3]">(<t t-esc="date[3]"/>)</small></a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
|
@ -98,7 +98,7 @@
|
|||
available.
|
||||
</span>
|
||||
</t>
|
||||
<h4 class="media-heading"><a t-att-href="'event/%%s' %% event_id.id"><span t-record="event_id" t-field="name"> </span></a></h4>
|
||||
<h4 class="media-heading"><a t-att-href="'event/%%s' %% event_id.id"><span t-field="event_id.name"> </span></a></h4>
|
||||
<t t-if="editable">
|
||||
<a href="#" t-att-data-id="event_id.id" class="pull-right">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not event_id.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
|
@ -106,18 +106,18 @@
|
|||
</a>
|
||||
</t>
|
||||
<div>
|
||||
<span t-record="event_id" t-field="type">: </span>
|
||||
<span t-field="event_id.type">: </span>
|
||||
<t t-if="event_id.user_id">
|
||||
Organized by: <span t-record="event_id" t-field="user_id"> </span>
|
||||
Organized by: <span t-field="event_id.user_id"> </span>
|
||||
</t>
|
||||
</div>
|
||||
<div>
|
||||
<i class="icon-time"></i> <span t-record="event_id" t-field="date_begin"> </span> <i>to</i> <span t-record="event_id" t-field="date_end"> </span>
|
||||
<i class="icon-time"></i> <span t-field="event_id.date_begin"> </span> <i>to</i> <span t-field="event_id.date_end"> </span>
|
||||
</div>
|
||||
<div t-if="event_id.country_id">
|
||||
<i class="icon-map-marker"></i> <span t-record="event_id" t-field="city"> </span> <span t-record="event_id" t-field="zip"> </span>, <span t-record="event_id" t-field="country_id"> </span>
|
||||
<i class="icon-map-marker"></i> <span t-field="event_id.city"> </span> <span t-field="event_id.zip"> </span>, <span t-field="event_id.country_id"> </span>
|
||||
</div>
|
||||
<div t-record="event_id" t-field="note"> </div>
|
||||
<div t-field="event_id.note"> </div>
|
||||
</div>
|
||||
</li>
|
||||
</t>
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</div>
|
||||
<div class="span8" t-if="blog_id">
|
||||
<div class="media">
|
||||
<div t-att-class="media-body well">
|
||||
<div class="media-body well">
|
||||
<a href="#" t-att-data-id="blog_id.id" class="pull-right" t-if="editable">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not blog_id.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (blog_id.website_published and 'hidden' or '')">Click to Publish</span>
|
||||
|
@ -76,23 +76,23 @@
|
|||
<h3 t-field="blog_id.subject"></h3>
|
||||
<div t-field="blog_id.body"></div>
|
||||
<small class="pull-right muted text-right">
|
||||
<div><t t-esc="blog_id.read(['author_id'])[0]['author_id'][1]"/></div>
|
||||
<div><t t-esc="blog_id.date"/></div>
|
||||
<div><t t-field="blog_id.author_id"/></div>
|
||||
<div><t t-field="blog_id.date"/></div>
|
||||
</small>
|
||||
</div>
|
||||
<ul class="media-list">
|
||||
<t t-foreach="comments">
|
||||
<t t-foreach="blog_id.child_ids" t-as="comment">
|
||||
<!-- TODO: check qweb iteration -->
|
||||
<li class="media">
|
||||
<div class="media-body">
|
||||
<a href="#" t-att-data-id="blog_id.id" class="pull-right" t-if="editable">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (website_published and 'hidden' or '')">Click to Publish</span>
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not comment.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (comment.website_published and 'hidden' or '')">Click to Publish</span>
|
||||
</a>
|
||||
<t t-raw="body"/>
|
||||
<t t-raw="comment.body"/>
|
||||
<small class="pull-right muted text-right">
|
||||
<div><t t-esc="author_id[1]"/></div>
|
||||
<div><t t-esc="date"/></div>
|
||||
<div><t t-esc="comment.author_id"/></div>
|
||||
<div><t t-esc="comment.date"/></div>
|
||||
</small>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -116,10 +116,13 @@
|
|||
<h4 class="media-heading" ><a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)" t-field="blog.subject"></a></h4>
|
||||
<div class="media">
|
||||
<div t-field="blog.body"></div>
|
||||
<small class="pull-left muted text-right" t-if="len(blog.child_ids)">
|
||||
<a t-if="len(blog.child_ids) <= 1" t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)"><t t-esc="len(blog.child_ids)"/> Message</a>
|
||||
<a t-if="len(blog.child_ids) > 1" t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)"><t t-esc="len(blog.child_ids)"/> Messages</a>
|
||||
</small>
|
||||
<small class="pull-right muted text-right">
|
||||
<a t-att-href="'/blog/%%s/%%s' %% (blog.res_id, blog.id)">Read more </a>
|
||||
<div><t t-esc="blog.read(['author_id'])[0]['author_id'][1]"/></div>
|
||||
<div><t t-esc="blog.date"/></div>
|
||||
<div><t t-field="blog.author_id"/></div>
|
||||
<div><t t-field="blog.date"/></div>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue