[IMP] "website_event" compatible with Multi-Website

This commit is contained in:
Kaushal Prajapati 2017-12-25 12:13:49 +05:30 committed by Siddharth Bhalgami
parent 277a2e8f96
commit 02881b6e5b
5 changed files with 61 additions and 4 deletions

View File

@ -83,6 +83,8 @@ class WebsiteEventController(http.Controller):
def dom_without(without):
domain = [('state', "in", ['draft', 'confirm', 'done'])]
domain += [('website_ids', 'in', request.website.id)] if \
not request.env.user.has_group('website.group_website_publisher') else []
for key, search in domain_search.items():
if key != without:
domain += search
@ -255,6 +257,7 @@ class WebsiteEventController(http.Controller):
for registration in registrations:
registration['event_id'] = event
registration['website_id'] = request.website.id
Attendees += Attendees.sudo().create(
Attendees._prepare_attendee_values(registration))

View File

@ -3,10 +3,12 @@
<record id="base.res_partner_1" model="res.partner">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record>
<record id="event.event_0" model="event.event">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="twitter_hashtag">flectra</field>
<field name="description"><![CDATA[
<section class="s_text_block_image_fw oe_img_bg" style="background-position: 50% 100%; background-image: url(/web/image/website.s_background_image_02);">
@ -163,9 +165,11 @@
<record id="base.res_partner_3" model="res.partner">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record>
<record id="event.event_1" model="event.event">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="twitter_hashtag">flectra</field>
<field name="description"><![CDATA[
<section class="s_text_block_image_fw oe_img_bg" style="background-position: 50% 100%; background-image: url(/web/image/website.s_background_image_01);">
@ -322,20 +326,25 @@
<record id="base.res_partner_4" model="res.partner">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record>
<record id="event.event_2" model="event.event">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="twitter_hashtag">flectra</field>
</record>
<record id="base.res_partner_2" model="res.partner">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record>
<record id="base.res_partner_address_4" model="res.partner">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record>
<record id="event.event_3" model="event.event">
<field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="twitter_hashtag">flectra</field>
<field name="description"><![CDATA[
<section class="s_text_block_image_fw oe_img_bg oe_custom_bg" style="background-image: url(/web/image/website.s_cover_default_image); background-position: 50% 100%">

View File

@ -17,6 +17,11 @@ class Event(models.Model):
_inherit = ['event.event', 'website.seo.metadata', 'website.published.mixin']
website_published = fields.Boolean(track_visibility='onchange')
website_ids = fields.Many2many('website', 'website_event_pub_rel',
'website_id', 'event_id',
string='Websites', copy=False,
help='List of websites in which '
'Event is published.')
is_participating = fields.Boolean("Is Participating", compute="_compute_is_participating")
@ -131,3 +136,29 @@ class Event(models.Model):
'target': 'new',
'url': '/report/html/%s/%s?enable_editor' % ('event.event_event_report_template_badge', self.id),
}
class EventRegistration(models.Model):
_inherit = 'event.registration'
website_id = fields.Many2one('website', string="Website")
@api.model
def _prepare_attendee_values(self, registration):
""" Method preparing the values to create new attendees based on a
sale order line. It takes some registration data (dict-based) that are
optional values coming from an external input like a web page. This method
is meant to be inherited in various addons that sell events. """
partner_id = registration.pop('partner_id', self.env.user.partner_id)
event_id = registration.pop('event_id', False)
data = {
'name': registration.get('name', partner_id.name),
'phone': registration.get('phone', partner_id.phone),
'email': registration.get('email', partner_id.email),
'partner_id': partner_id.id,
'website_id': registration.get('website_id', partner_id.email),
'event_id': event_id and event_id.id or False,
}
data.update({key: registration[key] for key in registration.keys() if key in self._fields})
return data

View File

@ -53,12 +53,12 @@
</div>
<ul class="media-list">
<li t-foreach="event_ids" t-as="event" class="media">
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body">
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body" t-att-data-publish="website in event.website_ids and 'on' or 'off'">
<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="event.is_online" class="label label-info">Online</small>
<small t-if="not event.website_published" class="label label-danger">unpublished</small>
<small t-if="not event.is_online" class="label label-info">Online</small>
<small t-if="not event.website_published and website not in event.website_ids" class="label label-danger">unpublished</small>
</h4>
<div>
<t t-if="event.organizer_id">
@ -680,7 +680,7 @@
<h4><b>Upcoming Events</b></h4>
</t>
<div t-foreach="events[:5]" t-as="event_dict" class="oe_website_overflow_ellipsis mb8">
<t t-if="not event_dict['event'].website_published">
<t t-if="not event_dict['event'].website_published and website not in event_dict['event'].wesite_ids">
<span class="label label-danger"><i class="fa fa-ban"></i></span>
</t>
<t t-if="event_dict['event'].address_id">

View File

@ -54,6 +54,20 @@
states="done"
string="Edit Badges"/>
</xpath>
<xpath expr="//field[@name='auto_confirm']" position="before">
<field name="website_ids" widget="many2many_tags"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_event_registration_form_inherit">
<field name="name">view.event.registration.form.inherit</field>
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_event_registration_form"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="website_id"/>
</field>
</field>
</record>