[IMP] website_event: Label 'Participating' on frontend

On the event page and on the event list page on a website, add a
label "participating" for the logged users that are participating
to the event to avoid mistakenly double-subscribing. But we don't
hard-prevent it, because it should still be possible to subscribe someone else.

Small improvement: The portal group in general settings was hidden. We set it
visible because it contains some useful options like 'Allow external users to
sign up'
This commit is contained in:
Yannick Tivisse
2016-03-09 12:13:23 +01:00
parent 85bcd6fdd8
commit a82413fb7a
3 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -25,7 +25,7 @@
</div>
</div>
</group>
<group groups="base.group_no_one">
<group>
<label for="id" string="Portal access"/>
<div>
<div>
+9
View File
@@ -22,6 +22,15 @@ class event(models.Model):
string='Website Messages',
help="Website communication history",
)
is_participating = fields.Boolean("Is Participating", compute="_compute_is_participating")
def _compute_is_participating(self):
# we don't allow public user to see participating label
if self.env.user != self.env.ref('base.public_user'):
email = self.env.user.partner_id.email
for event in self:
domain = ['&', '|', ('email', '=', email), ('partner_id.email', '=', email), ('event_id', '=', event.id)]
event.is_participating = self.env['event.registration'].search_count(domain)
@api.multi
@api.depends('name')
@@ -58,6 +58,7 @@
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body">
<h4 class="media-heading">
<a itemprop="url" t-att-class="event.state == 'done' and 'text-success'" t-attf-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register' or ''}"><span itemprop="name" t-field="event.name"> </span></a>
<small t-if="event.is_participating" class="label label-info">Participating</small>
<small t-if="not event.address_id" class="label label-info">Online</small>
<small t-if="not event.website_published" class="label label-danger">not published</small>
</h4>
@@ -268,6 +269,9 @@
<t t-call="website_event.layout">
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="container">
<h1 itemprop="name" class="text-center" t-field="event.name"></h1>
<div class="text-center">
<small t-if="event.is_participating" class="label label-info">Participating</small>
</div>
<h4 class="text-center text-muted">
<i class="fa fa-clock-o"></i>
<span itemprop="startDate"><t t-esc="event.date_begin_located[:-3]"/></span> to