[IMP] website_event_track_online: add a (void) community menu and page

RATIONALE

Events are sometimes held online, gathering a community. In this merge we
improve Event application to better support full-online events with improved
tracks, wishlists, chat rooms, ...

PURPOSE

Prepare community addition (both quiz-based and room-based) by adding
a community link and page management.

SPECIFICATIONS

In order to show the leaderboard and the meeting rooms on the same page we
have to put a page and a route at the base of two upcoming modules: meet and
quiz. The only common ancestor of those two will be website_event_track_online
who gains a field for the community menu.

It currently does nothing and leads to a void page. Both meet and quiz modules
will add their own logic: meeting rooms or leaderboard. Having bothi installed
displays rooms with a small leaderboard.

See next commits for more details on those modules.

LINKS

Task ID-2252655 (Main Online Event task)
Task ID-2283771 (Quizzes on Talks, Leaderboard)
Task ID-2283742 (Community gathering on chat rooms)

Co-Authored-By: Aurélien Warnon <awa@odoo.com>
Co-Authored-By: David Beguin <dbe@odoo.com>
Co-Authored-By: Quentin Mourier <qmo@odoo.com>
Co-Authored-By: Stéphane Debauche <std@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
This commit is contained in:
qmo-odoo
2020-08-04 14:28:29 +00:00
committed by Thibault Delavallée
co-authored by Aurélien Warnon David Beguin Stéphane Debauche Thibault Delavallée
parent 57da236657
commit 21e429daae
9 changed files with 111 additions and 2 deletions
@@ -32,6 +32,7 @@
'views/event_track_views.xml',
'views/event_track_tag_views.xml',
'views/event_track_visitor_views.xml',
'views/event_type_views.xml',
'views/website_visitor_views.xml',
'views/event_menus.xml',
],
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import event_track
from . import community
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.website_event.controllers.main import WebsiteEventController
from odoo import fields, http, modules, tools
from odoo.http import request
class WebsiteEventCommunityController(http.Controller):
@http.route('/event/<model("event.event"):event>/community', type="http", auth="public", website=True)
def community(self, event, lang=None, **kwargs):
""" This skeleton route will be overriden in website_event_track_quiz, website_event_meet and website_event_meet_quiz. """
return request.render('website.page_404')
@@ -8,4 +8,6 @@ from . import event_track_visitor
from . import event_track
from . import event_track_stage
from . import event_track_tag
from . import event_type
from . import website_event_menu
from . import website_visitor
@@ -1,24 +1,64 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, _
from odoo import models, fields, api, _
from odoo.addons.http_routing.models.ir_http import slug
class EventEvent(models.Model):
_inherit = "event.event"
community_menu = fields.Boolean(
"Community Menu", compute="_compute_community_menu",
readonly=False, store=True,
help="Display community tab on website")
community_menu_ids = fields.One2many(
"website.event.menu", "event_id", string="Event Community Menus",
domain=[("menu_type", "=", "community")])
@api.depends("event_type_id", "website_menu", "community_menu")
def _compute_community_menu(self):
""" At type onchange: synchronize. At website_menu update: synchronize. """
for event in self:
if event.event_type_id and event.event_type_id != event._origin.event_type_id:
event.community_menu = event.event_type_id.community_menu
elif event.website_menu and event.website_menu != event._origin.website_menu or not event.community_menu:
event.community_menu = True
elif not event.website_menu:
event.community_menu = False
# ------------------------------------------------------------
# WEBSITE MENU MANAGEMENT
# ------------------------------------------------------------
# OVERRIDES: ADD SEQUENCE
def _get_menu_update_fields(self):
update_fields = super(EventEvent, self)._get_menu_update_fields()
update_fields += ['community_menu']
return update_fields
def _update_website_menus(self, menus_update_by_field=None):
super(EventEvent, self)._update_website_menus(menus_update_by_field=menus_update_by_field)
for event in self:
if not menus_update_by_field or event in menus_update_by_field.get('community_menu'):
event._update_website_menu_entry('community_menu', 'community_menu_ids', '_get_community_menu_entries')
def _get_menu_type_field_matching(self):
res = super(EventEvent, self)._get_menu_type_field_matching()
res['community'] = 'community_menu'
return res
def _get_community_menu_entries(self):
self.ensure_one()
return [(_('Community'), '/event/%s/community' % slug(self), False, 80, 'community')]
def _get_track_menu_entries(self):
""" Remove agenda as this is now managed separately """
self.ensure_one()
return [
(_('Talks'), '/event/%s/track' % slug(self), False, 10, 'track'),
(_('Agenda'), '/event/%s/agenda' % slug(self), False, 70, 'track')
(_('Agenda'), '/event/%s/agenda' % slug(self), False, 70, False)
]
def _get_track_proposal_menu_entries(self):
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class EventType(models.Model):
_inherit = "event.type"
community_menu = fields.Boolean(
"Community Menu", compute="_compute_community_menu",
readonly=False, store=True,
help="Display community tab on website")
@api.depends('website_menu')
def _compute_community_menu(self):
for event_type in self:
event_type.community_menu = event_type.website_menu
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class EventMenu(models.Model):
_inherit = "website.event.menu"
menu_type = fields.Selection(selection_add=[
('community', 'Community Menu')
])
@@ -12,7 +12,13 @@
<label for="website_track_proposal" string="Allow Track Proposals"/>
<field name="website_track_proposal"/>
</xpath>
<xpath expr="//div[@name='event_menu_configuration']" position='inside'>
<label for="community_menu" string="Community"/>
<field name="community_menu"/>
</xpath>
</field>
</record>
</data></odoo>
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<odoo><data>
<record id="event_type_view_form" model="ir.ui.view">
<field name="name">event.type.view.form.inherit.meet</field>
<field name="model">event.type</field>
<field name="inherit_id" ref="website_event.event_type_view_form_inherit_website"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='website_menu']" position='after'>
<div id="community-menu" class="row mt16" groups="base.group_no_one" attrs="{'invisible': [('website_menu', '=', False)]}">
<label class="col-lg-4" for="community_menu"/> <field name="community_menu"/>
</div>
</xpath>
</field>
</record>
</data></odoo>