[FIX] website_mail_group: avoid displaying directly partner info in templates

but use the contact template that display partner-related data fetched
as superuser, to avoid access right issues.
Improved display: author or email-from.
Fixed issues in the pager.

bzr revid: tde@openerp.com-20140326103515-uzv6smwh9q6vyni9
This commit is contained in:
Thibault Delavallée 2014-03-26 11:35:15 +01:00
parent cafaf60552
commit f9b18d51ad
2 changed files with 20 additions and 7 deletions

View File

@ -9,7 +9,7 @@ from openerp.addons.web.http import request
class MailGroup(http.Controller):
_thread_per_page = 2
_thread_per_page = 10
def _get_archives(self, group_id):
MailMessage = request.registry['mail.message']
@ -43,7 +43,7 @@ class MailGroup(http.Controller):
@http.route([
"/groups/<model('mail.group'):group>",
"/groups/<model('mail.group'):group>/page/<int:page>/"
"/groups/<model('mail.group'):group>/page/<int:page>"
], type='http', auth="public", website=True)
def thread_headers(self, group, page=1, mode='thread', date_begin=None, date_end=None, **post):
cr, uid, context = request.cr, request.uid, request.context
@ -57,7 +57,7 @@ class MailGroup(http.Controller):
thread_count = thread_obj.search_count(cr, uid, domain, context=context)
pager = request.website.pager(
url='/groups/%s/' % slug(group),
url='/groups/%s' % slug(group),
total=thread_count,
page=page,
step=self._thread_per_page,

View File

@ -93,7 +93,13 @@
<h1 t-field="message.subject"/>
<img class="img-rounded pull-left" t-att-src="'/website/image?model=mail.message&amp;field=author_avatar&amp;id='+str(message.id)" style="width : 30px"/>
<h4 class="mt0 mb32">
<span t-field="message.author_id.name"/>
<t t-if="message.author_id">
<span t-field="message.author_id" style="display: inline-block;" t-field-options='{
"widget": "contact",
"fields": ["name"]
}'/>
</t>
<t t-if="not message.author_id"><t t-esc="message.email_from"/></t>
on <span t-field="message.date"/>
</h4>
<div t-raw="message.body"/>
@ -146,12 +152,19 @@
<h4 class="media-heading">
<a t-attf-href="/groups/#{slug(group)}/#{slug(thread)}?mode=#{mode}&amp;date_begin=#{date_begin}&amp;date_end=#{date_end}" t-esc="thread.description"/>
</h4>
<p><small>
by <t t-esc="thread.author_id.name and thread.author_id.name or thread.email_from"/> on <t t-esc="thread.date"/><br />
<small>
by
<t t-if="thread.author_id">
<span t-field="thread.author_id" style="display: inline-block;" t-field-options='{
"widget": "contact",
"fields": ["name"]
}'/>
</t>
<t t-if="not thread.author_id"><t t-esc="thread.email_from"/></t>
<span class="fa fa-comment-o">
<t t-raw="len(thread.child_ids)"/> replies
</span>
</small></p>
</small>
</div>
</li>
</ul>