diff options
| author | David Beguin <dbe@odoo.com> | 2019-02-14 10:45:26 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2019-02-18 15:15:02 +0000 |
| commit | 3ab9f1d8abeec6fcbe2fd0aedcf3712c3e3f583b (patch) | |
| tree | 4bf4d50910b9e0e339861a5eaa0bf48e8097d712 | |
| parent | 705376a982d64fb41800f148a167ef0fc28ce4c6 (diff) | |
[IMP] website_slides_forum : set communication on slide.channel at creation - frontend side
Since 556b6454dab07cdf716d404ec0db9aa51a09b165, channel can be linked to a dedicated forum.
But the link could only be done in backend, in the slide.channel configuration
For now on, website_publishers can create a new dedicated forum when they create
a new slide.channel.
Link buttons have been added in both forum and slide.channel headers to navigate easily
between them.
Fix the relation between course and forum in a model point of view.
Task ID : 1922159
PR #31109
13 files changed, 145 insertions, 35 deletions
diff --git a/addons/website_profile/static/src/scss/website_profile.scss b/addons/website_profile/static/src/scss/website_profile.scss index b45b58a587c..cd590c9bb19 100644 --- a/addons/website_profile/static/src/scss/website_profile.scss +++ b/addons/website_profile/static/src/scss/website_profile.scss @@ -31,37 +31,38 @@ $bronze: #eea91e; } } +.o_wprofile_navtabs_container { + .o_wprofile_nav_tabs { + border-bottom: 0px; + } + .o_wprofile_navlink { + color: white; + border-radius: 0px; + height: 48px; + font-weight: bold; + padding-top: 12px; + border-left: 2px solid #875A7B; + text-align: center; + width: 120px; + &:hover { + border: 0px; + border-radius: 0px; + background-color: #875A7B; + } + } + .o_wprofile_navlink.active { + color: #212529; + background-color: #f2f2f2; + border: 0px; + } +} + .o_wprofile_content { margin: auto; background-color: #f2f2f2 !important; .o_wprofile_content_container{ position: relative; top: -80px; - .o_wprofile_navtabs_container { - .o_wprofile_nav_tabs { - border-bottom: 0px; - } - .o_wprofile_navlink { - color: white; - border-radius: 0px; - height: 48px; - font-weight: bold; - padding-top: 12px; - border-left: 2px solid #875A7B; - text-align: center; - width: 120px; - &:hover { - border: 0px; - border-radius: 0px; - background-color: #875A7B; - } - } - .o_wprofile_navlink.active { - color: #212529; - background-color: #f2f2f2; - border: 0px; - } - } .o_wprofile_detail { .o_wprofile_content_abstract { top: 1px; diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index ef4265055f6..e8ebae00b7b 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -96,6 +96,9 @@ class WebsiteSlides(WebsiteProfile): domain = expression.AND([domain, [('nbr_%ss' % slide_type, '>', 0)]]) return domain + def _prepare_channel_values(self, **kwargs): + return dict(**kwargs) + # -------------------------------------------------- # MAIN / SEARCH # -------------------------------------------------- diff --git a/addons/website_slides/static/src/xml/website_slides_channel.xml b/addons/website_slides/static/src/xml/website_slides_channel.xml index 5334a01ad53..0147f56eac5 100644 --- a/addons/website_slides/static/src/xml/website_slides_channel.xml +++ b/addons/website_slides/static/src/xml/website_slides_channel.xml @@ -37,7 +37,7 @@ <textarea name="description" id="description" style="height:8em" class="form-control" placeholder="Write here a short description of your first course"/> </div> </div> - <div class="form-group row"> + <div class="form-group row o_wslide_channel_communication_type"> <div class="col-sm-2">Review</div> <div class="col-sm-10"> <div class="form-check"> diff --git a/addons/website_slides/views/slide_channel_views.xml b/addons/website_slides/views/slide_channel_views.xml index 7602d9c188a..91607fbace5 100644 --- a/addons/website_slides/views/slide_channel_views.xml +++ b/addons/website_slides/views/slide_channel_views.xml @@ -90,7 +90,6 @@ <group> <group> <field name="channel_type" widget="radio"/> - <field name="allow_comment"/> <field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/> <field name="promote_strategy" widget="radio"/> </group> @@ -105,6 +104,11 @@ <field name="enroll_msg" colspan="4" nolabel="1"/> </group> </page> + <page string="Communication"> + <group> + <field name="allow_comment"/> + </group> + </page> <page string="Statistics" groups="base.group_no_one"> <group> <group> diff --git a/addons/website_slides_forum/__manifest__.py b/addons/website_slides_forum/__manifest__.py index c6f8a4cf6d9..793665230e1 100644 --- a/addons/website_slides_forum/__manifest__.py +++ b/addons/website_slides_forum/__manifest__.py @@ -15,6 +15,8 @@ 'views/slide_channel_views.xml', 'views/website_slides_templates.xml', 'data/slide_channel_demo.xml', + 'views/assets.xml', + 'views/website_slides_forum_templates.xml' ], 'auto_install': True, } diff --git a/addons/website_slides_forum/controllers/main.py b/addons/website_slides_forum/controllers/main.py index e86a4d70bf0..6f898b90fc4 100644 --- a/addons/website_slides_forum/controllers/main.py +++ b/addons/website_slides_forum/controllers/main.py @@ -6,8 +6,21 @@ from odoo.addons.website_slides.controllers.main import WebsiteSlides class WebsiteSlidesForum(WebsiteSlides): + + def _slide_channel_prepare_values(self, **kwargs): + communication_type = kwargs.get('communication_type') + if communication_type: + if communication_type == 'forum': + forum = request.env['forum.forum'].create({ + 'name': kwargs.get('name') + }) + kwargs['forum_id'] = forum.id + kwargs['allow_comment'] = communication_type == 'comment' + return super(WebsiteSlidesForum, self)._slide_channel_prepare_values(**kwargs) + # Profile # --------------------------------------------------- + def _prepare_user_profile_parameters(self, **post): post = super(WebsiteSlidesForum, self)._prepare_user_profile_parameters(**post) if post.get('channel_id'): diff --git a/addons/website_slides_forum/models/forum.py b/addons/website_slides_forum/models/forum.py index 907ae5c586e..a08d744ee49 100644 --- a/addons/website_slides_forum/models/forum.py +++ b/addons/website_slides_forum/models/forum.py @@ -1,10 +1,19 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class Forum(models.Model): _inherit = 'forum.forum' - slide_channel_id = fields.Many2one('slide.channel', 'Course') + slide_channel_ids = fields.One2many('slide.channel', 'forum_id', 'Courses') + slide_channel_id = fields.Many2one('slide.channel', 'Course', compute='_compute_slide_channel_id') + + @api.depends('slide_channel_ids') + def _compute_slide_channel_id(self): + for forum in self: + if forum.slide_channel_ids: + forum.slide_channel_id = forum.slide_channel_ids[0] + else: + forum.slide_channel_id = None diff --git a/addons/website_slides_forum/security/ir.model.access.csv b/addons/website_slides_forum/security/ir.model.access.csv new file mode 100644 index 00000000000..82ac84d07ba --- /dev/null +++ b/addons/website_slides_forum/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_forum_forum_website_publisher,access.forum.forum.website.publisher,model_forum_forum,base.group_website_publisher,1,1,1,0 diff --git a/addons/website_slides_forum/static/src/js/website_slides_forum.editor.js b/addons/website_slides_forum/static/src/js/website_slides_forum.editor.js new file mode 100644 index 00000000000..324d70c8ea6 --- /dev/null +++ b/addons/website_slides_forum/static/src/js/website_slides_forum.editor.js @@ -0,0 +1,13 @@ +odoo.define('website_slides_forum.editor', function (require) { +"use strict"; + +var core = require('web.core'); +var QWeb = core.qweb; +var WebsiteNewMenu = require('website.newMenu'); + + WebsiteNewMenu.include({ + xmlDependencies: WebsiteNewMenu.prototype.xmlDependencies.concat( + ['/website_slides_forum/static/src/xml/website_slides_forum_channel.xml'] + ), +}); +}); diff --git a/addons/website_slides_forum/static/src/xml/website_slides_forum_channel.xml b/addons/website_slides_forum/static/src/xml/website_slides_forum_channel.xml new file mode 100644 index 00000000000..03389f2a12d --- /dev/null +++ b/addons/website_slides_forum/static/src/xml/website_slides_forum_channel.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates xml:space="preserve"> + <t t-extend="website.slide.channel.create"> + <t t-jquery=".o_wslide_channel_communication_type" t-operation="replace"> + <fieldset id="channel_create_forum" class="form-group"> + <div class="row"> + <legend class="col-form-label col-sm-2">Communication</legend> + <div class="col-sm-10"> + <div class="form-check"> + <input class="form-check-input" type="radio" name="communication_type" id="communication_type1" value="nothing" checked="checked"/> + <label class="form-check-label" for="communication_type1"> + No communication + </label> + </div> + <div class="form-check"> + <input class="form-check-input" type="radio" name="communication_type" id="communication_type2" value="forum"/> + <label class="form-check-label" for="communication_type2"> + Create a Forum + </label> + </div> + <div class="form-check"> + <input class="form-check-input" type="radio" name="communication_type" id="communication_type3" value="comment"/> + <label class="form-check-label" for="communication_type3"> + Allow comments + </label> + </div> + </div> + </div> + </fieldset> + </t> + </t> +</templates> diff --git a/addons/website_slides_forum/views/assets.xml b/addons/website_slides_forum/views/assets.xml new file mode 100644 index 00000000000..9c36aa33ab2 --- /dev/null +++ b/addons/website_slides_forum/views/assets.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <template id="assets_frontend" inherit_id="website.assets_frontend" name="Website slide forum frontend assets"> + <xpath expr="//script[last()]" position="after"> + <script type="text/javascript" src="/website_slides_forum/static/src/js/website_slides_forum.editor.js"></script> + </xpath> + </template> +</odoo> diff --git a/addons/website_slides_forum/views/slide_channel_views.xml b/addons/website_slides_forum/views/slide_channel_views.xml index ddff2b256b4..0dab8d637f9 100644 --- a/addons/website_slides_forum/views/slide_channel_views.xml +++ b/addons/website_slides_forum/views/slide_channel_views.xml @@ -5,12 +5,8 @@ <field name="model">slide.channel</field> <field name="inherit_id" ref="website_slides.view_slide_channel_form"/> <field name="arch" type="xml"> - <xpath expr="//notebook" position="inside"> - <page string="Forum"> - <group> - <field name="forum_id"/> - </group> - </page> + <xpath expr="//field[@name='allow_comment']" position="after"> + <field name="forum_id"/> </xpath> </field> </record> diff --git a/addons/website_slides_forum/views/website_slides_forum_templates.xml b/addons/website_slides_forum/views/website_slides_forum_templates.xml new file mode 100644 index 00000000000..2c47c9e759c --- /dev/null +++ b/addons/website_slides_forum/views/website_slides_forum_templates.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo><data> + <template id="website_slides_forum_header" inherit_id="website_forum.header"> + <xpath expr="//div[hasclass('container')]" position="before"> + <t t-if="forum.slide_channel_id"> + <div class="row" style="background-color: #66445e; height: 48px;"> + <div class="container o_wprofile_navtabs_container"> + <ul class="nav nav-tabs o_wprofile_nav_tabs" role="tablist" id="profile_extra_info_tablist"> + <li class="nav-item"> + <a t-att-href="'/slides/%s%s?%s' % (slug(forum.slide_channel_id), '/%s' % slug(category) if category else '', keep_query('debug'))" + t-att-class="'nav-link o_wprofile_navlink'" style="border-left: 0px"> + <i class="fa fa-home"/> Home</a> + </li> + <li class="nav-item"> + <a href="#" t-att-class="'nav-link active o_wprofile_navlink'" style="border-left: 0px">Forum</a> + </li> + <li class="nav-item"> + <a t-att-href="'/slides/%s' % (slug(forum.slide_channel_id))" + t-att-class="'nav-link o_wprofile_navlink'" style="border-left: 0px">Review</a> + </li> + </ul> + </div> + </div> + </t> + </xpath> + </template> +</data></odoo> |
