[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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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'):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
@@ -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']
|
||||
),
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user