summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-01-23 17:00:13 +0000
committerDavid Beguin <dbe@odoo.com>2019-02-14 09:24:10 +0000
commita4a0436ddd51a84e35fa68a13833886ffbb63174 (patch)
treed040fc8617a0be444832b56f87ad82bec04ee8c9 /addons
parentd8f156ae7333e9e7ce712ee50d4898443c61a610 (diff)
[ADD] website_slides_forum : Allow to create forum on a course
Adds the mega power to make Super Saiyan fusion between website_slides and website_forum A slide.channel can now be linked to a forum to allow users to discuss about their courses. Overrides the slides profile routes to include the potiential linked forum. The profile page will display now all the information of a specific channel with, also, all the information of the linked forum. If no channel is specified, the profile page shows everything (information about all channel and information about all forum). Task ID : 1922159 PR #30988
Diffstat (limited to 'addons')
-rw-r--r--addons/website_slides_forum/__init__.py5
-rw-r--r--addons/website_slides_forum/__manifest__.py15
-rw-r--r--addons/website_slides_forum/controllers/__init__.py3
-rw-r--r--addons/website_slides_forum/controllers/main.py22
-rw-r--r--addons/website_slides_forum/models/__init__.py4
-rw-r--r--addons/website_slides_forum/models/forum.py10
-rw-r--r--addons/website_slides_forum/models/slide_channel.py14
-rw-r--r--addons/website_slides_forum/views/slide_channel_views.xml17
8 files changed, 90 insertions, 0 deletions
diff --git a/addons/website_slides_forum/__init__.py b/addons/website_slides_forum/__init__.py
new file mode 100644
index 00000000000..8c67f893b37
--- /dev/null
+++ b/addons/website_slides_forum/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
+from . import controllers
diff --git a/addons/website_slides_forum/__manifest__.py b/addons/website_slides_forum/__manifest__.py
new file mode 100644
index 00000000000..a272af7858c
--- /dev/null
+++ b/addons/website_slides_forum/__manifest__.py
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+{
+ 'name': 'Forum on course',
+ 'category': 'Hidden',
+ 'version': '1.0',
+ 'summary': 'Allows to link forum on a course',
+ 'description': """A Slide channel can be linked to forum. Also, profiles from slide and forum are regrouped together""",
+ 'depends': ['website_slides', 'website_forum'],
+ 'data': [
+ 'views/slide_channel_views.xml'
+ ],
+ 'auto_install': True,
+}
diff --git a/addons/website_slides_forum/controllers/__init__.py b/addons/website_slides_forum/controllers/__init__.py
new file mode 100644
index 00000000000..65a8c12013d
--- /dev/null
+++ b/addons/website_slides_forum/controllers/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import main
diff --git a/addons/website_slides_forum/controllers/main.py b/addons/website_slides_forum/controllers/main.py
new file mode 100644
index 00000000000..e86a4d70bf0
--- /dev/null
+++ b/addons/website_slides_forum/controllers/main.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.http import request
+from odoo.addons.website_slides.controllers.main import WebsiteSlides
+
+
+class WebsiteSlidesForum(WebsiteSlides):
+ # Profile
+ # ---------------------------------------------------
+ def _prepare_user_profile_parameters(self, **post):
+ post = super(WebsiteSlidesForum, self)._prepare_user_profile_parameters(**post)
+ if post.get('channel_id'):
+ channel = request.env['slide.channel'].browse(int(post.get('channel_id')))
+ if channel.forum_id:
+ post.update({
+ 'forum_id': channel.forum_id.id,
+ 'no_forum': False
+ })
+ else:
+ post.update({'no_forum': True})
+ return post
diff --git a/addons/website_slides_forum/models/__init__.py b/addons/website_slides_forum/models/__init__.py
new file mode 100644
index 00000000000..68c2a5669da
--- /dev/null
+++ b/addons/website_slides_forum/models/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+
+from . import forum
+from . import slide_channel
diff --git a/addons/website_slides_forum/models/forum.py b/addons/website_slides_forum/models/forum.py
new file mode 100644
index 00000000000..907ae5c586e
--- /dev/null
+++ b/addons/website_slides_forum/models/forum.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class Forum(models.Model):
+ _inherit = 'forum.forum'
+
+ slide_channel_id = fields.Many2one('slide.channel', 'Course')
diff --git a/addons/website_slides_forum/models/slide_channel.py b/addons/website_slides_forum/models/slide_channel.py
new file mode 100644
index 00000000000..9b8018a1af5
--- /dev/null
+++ b/addons/website_slides_forum/models/slide_channel.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class Channel(models.Model):
+ _inherit = 'slide.channel'
+
+ forum_id = fields.Many2one('forum.forum', 'Course Forum')
+
+ _sql_constraints = [
+ ('forum_uniq', 'unique (forum_id)', "Only one forum per slide channel!"),
+ ]
diff --git a/addons/website_slides_forum/views/slide_channel_views.xml b/addons/website_slides_forum/views/slide_channel_views.xml
new file mode 100644
index 00000000000..ddff2b256b4
--- /dev/null
+++ b/addons/website_slides_forum/views/slide_channel_views.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <record id="website_slides_forum_channel_inherit_view_form" model="ir.ui.view">
+ <field name="name">website.slides_forum.view.form.inherit.slide.channel</field>
+ <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>
+ </field>
+ </record>
+</odoo>