+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import controllers
-import models
+++ /dev/null
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2014-Today OpenERP SA (<http://www.openerp.com>).
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-{
- 'name': 'Documentation',
- 'category': 'Website',
- 'summary': 'Forum, Documentation',
- 'version': '1.0',
- 'description': """
-Documentation based on question and pertinent answers of Forum
- """,
- 'author': 'OpenERP SA',
- 'depends': [
- 'website_forum'
- ],
- 'data': [
- 'data/doc_data.xml',
- 'data/cron.xml',
- 'security/ir.model.access.csv',
- 'security/doc_security.xml',
- 'views/doc.xml',
- 'views/website_doc.xml',
- ],
- 'qweb': [
- 'static/src/xml/*.xml'
- ],
- 'demo': [
- 'data/doc_demo.xml',
- ],
- 'installable': True,
- 'application': True,
-}
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import main
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from datetime import datetime
-import werkzeug.urls
-import simplejson
-
-from openerp import tools
-from openerp import SUPERUSER_ID
-from openerp.addons.web import http
-from openerp.addons.web.controllers.main import login_redirect
-from openerp.addons.web.http import request
-from openerp.addons.website.controllers.main import Website as controllers
-from openerp.addons.website.models.website import slug
-from openerp.addons.website_forum.controllers.main import WebsiteForum
-
-controllers = controllers()
-
-class WebsiteDoc(http.Controller):
-
- @http.route(['/doc', '/doc/<model("documentation.toc"):toc>'], type='http', auth="public", website=True, multilang=True)
- def documentation(self, toc='', **kwargs):
- cr, uid, context, toc_id = request.cr, request.uid, request.context, False
- TOC = request.registry['documentation.toc']
- obj_ids = TOC.search(cr, uid, [('parent_id', '=', False)], context=context)
- toc_ids = TOC.browse(cr, uid, obj_ids, context=context)
- value = {
- 'documentaion_toc': toc_ids,
- 'topic': toc or toc_ids[0],
- }
- return request.website.render("website_doc.documentation", value)
-
- @http.route('/doc/new', type='http', auth="user", multilang=True, website=True)
- def create_table_of_content(self, toc_name="New Table Of Content", **kwargs):
- toc_id = request.registry['documentation.toc'].create(request.cr, request.uid, {
- 'name': toc_name,
- }, context=request.context)
- return request.redirect("/doc/%s" % toc_id)
-
- #---------------------
- # Forum Posts
- # --------------------
-
-class WebsiteForum(WebsiteForum):
-
- def prepare_question_values(self, forum, **kwargs):
- cr, uid, context = request.cr, request.uid, request.context
- TOC = request.registry['documentation.toc']
- obj_ids = TOC.search(cr, uid, [('child_ids', '=', False)], context=context)
- toc = TOC.browse(cr, uid, obj_ids, context=context)
- values = super(WebsiteForum, self).prepare_question_values(forum=forum, kwargs=kwargs)
- values.update({'documentaion_toc': toc})
- return values
-
- @http.route('/forum/<model("forum.forum"):forum>/question/<model("forum.post"):post>/toc', type='http', auth="user", multilang=True, website=True)
- def post_toc(self, forum, post, **kwargs):
- toc_id = int(kwargs.get('content')) if kwargs.get('content') else False
- request.registry['forum.post'].write(request.cr, request.uid, [post.id], {'toc_id': toc_id}, context=request.context)
- return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<openerp>
- <data>
- <record forcecreate="True" id="ir_cron_check_challenge" model="ir.cron">
- <field name="name">Run Moderator Checker</field>
- <field name="interval_number">1</field>
- <field name="interval_type">days</field>
- <field name="numbercall">-1</field>
- <field name="doall" eval="False" />
- <field name="model">res.users</field>
- <field name="function">_cron_moderator_access_update</field>
- <field name="args">()</field>
- </record>
- </data>
-</openerp>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
- <data>
-
- <record id="menu_questions" model="website.menu">
- <field name="name">Documentation</field>
- <field name="url" eval="'/doc'"/>
- <field name="parent_id" ref="website.main_menu"/>
- <field name="sequence" type="int">65</field>
- </record>
-
- <!-- JUMP TO DOCUMENTATION AT INSTALL -->
- <record id="action_open_documentation" model="ir.actions.act_url">
- <field name="name">Documentation</field>
- <field name="target">self</field>
- <field name="url" eval="'/doc'"/>
- </record>
- <record id="base.open_menu" model="ir.actions.todo">
- <field name="action_id" ref="action_open_documentation"/>
- <field name="state">open</field>
- </record>
-
- </data>
-</openerp>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
- <data>
-
- <!-- Table Of Content -->
- <record id="toc_functional_doc" model="documentation.toc">
- <field name="name">Functional Documentation</field>
- </record>
- <record id="toc_sale" model="documentation.toc">
- <field name="name">Sales Management</field>
- <field name="parent_id" ref="toc_functional_doc"/>
- </record>
- <record id="toc_sale_customer" model="documentation.toc">
- <field name="name">Customers</field>
- <field name="parent_id" ref="toc_sale"/>
- </record>
- <record id="toc_sale_so" model="documentation.toc">
- <field name="name">Sales orders</field>
- <field name="parent_id" ref="toc_sale"/>
- </record>
- <record id="toc_0" model="documentation.toc">
- <field name="name">Sales & Warehouse</field>
- <field name="parent_id" ref="toc_sale"/>
- </record>
- <record id="toc_crm" model="documentation.toc">
- <field name="name">Customer Relationship Management</field>
- <field name="parent_id" ref="toc_functional_doc"/>
- </record>
- <record id="toc_crm_lead" model="documentation.toc">
- <field name="name">Lead & Opportunity</field>
- <field name="parent_id" ref="toc_crm"/>
- </record>
- <record id="toc_crm_claim" model="documentation.toc">
- <field name="name">Claims</field>
- <field name="parent_id" ref="toc_crm"/>
- </record>
- <record id="toc_crm_after_sale" model="documentation.toc">
- <field name="name">After-sale communication</field>
- <field name="parent_id" ref="toc_crm"/>
- </record>
- <record id="toc_website" model="documentation.toc">
- <field name="name">Website</field>
- <field name="parent_id" ref="toc_functional_doc"/>
- </record>
- <record id="toc_cms_ecommerce" model="documentation.toc">
- <field name="name">CMS & eCommerce</field>
- <field name="parent_id" ref="toc_website"/>
- </record>
- <record id="toc_hrm" model="documentation.toc">
- <field name="name">Human Resources Management</field>
- <field name="parent_id" ref="toc_functional_doc"/>
- </record>
- <record id="toc_hrm_contract" model="documentation.toc">
- <field name="name">Employee Contract</field>
- <field name="parent_id" ref="toc_hrm"/>
- </record>
-
- <!-- Questions -->
- <record id="website_forum.question_0" model="forum.post">
- <field name="toc_id" ref="toc_hrm_contract"/>
- </record>
- <record id="website_forum.question_1" model="forum.post">
- <field name="toc_id" ref="toc_cms_ecommerce"/>
- </record>
-
- </data>
-</openerp>
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import doc
-import res_users
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import openerp
-from openerp.osv import osv, fields
-from openerp.tools.translate import _
-
-
-class Documentation(osv.Model):
- _name = 'documentation.toc'
- _description = 'Table Of Content For Documentation'
- _inherit = ['website.seo.metadata']
-
- _columns = {
- 'name': fields.char('Name', required=True, translate=True),
- 'parent_id': fields.many2one('documentation.toc', 'Parent Table Of Content'),
- 'child_ids': fields.one2many('documentation.toc', 'parent_id', 'Children Table Of Content'),
- 'post_ids': fields.one2many('forum.post', 'toc_id', 'Posts'),
- }
-
-class Post(osv.Model):
- _inherit = 'forum.post'
-
- def _get_pertinent_answer(self, cr, uid, ids, field_name=False, arg={}, context=None):
- '''Set answer which have been accepted or have maximum votes'''
- res = {}
- for post in self.browse(cr, uid, ids, context=context):
- pertinent_answer_ids = self.search(cr, uid, [('parent_id', '=', post.id)], order='is_correct, vote_count desc', context=context)
- res[post.id] = pertinent_answer_ids[0] if pertinent_answer_ids else False
- return res
-
- _columns = {
- 'name': fields.char('Title', size=128),
- 'toc_id': fields.many2one('documentation.toc', 'Table of Content'),
- 'pertinent_answer_id':fields.function(_get_pertinent_answer, string="Pertinent Answer", type='many2one', relation="forum.post",
- store={
- 'forum.post': (lambda self, cr, uid, ids, c={}: ids, [], 10),
- }
- ),
- }
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from openerp.osv import osv, fields
-
-
-class Users(osv.Model):
- _inherit = 'res.users'
-
- def _cron_moderator_access_update(self, cr, uid, context=None, ids=False):
- """Daily cron check.
-
- - apply Moderation group for users who have more than 1000 karma.
- """
- modrator_group = self.pool['ir.model.data'].get_object(cr, uid, "website_doc", "group_documentaion_moderator", context=context)
- applicable_user_ids = self.search(cr, uid, [ ('karma', '>=', 1000), ('groups_id', '!=', modrator_group.id)], context=context)
- users = [(4, user) for user in applicable_user_ids]
- self.pool['res.groups'].write(cr, uid, [modrator_group.id], {'users': users}, context=context)
- return True
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-<data noupdate="1">
-
- <record id="group_documentaion_moderator" model="res.groups">
- <field name="name">Documentaion Moderator</field>
- <field name="category_id" ref="base.module_category_website"/>
- <field name="comment">the user will have access to add Table of content on questions to manage documentation.</field>
- <field name="users" eval="[(4, ref('base.user_root'))]"/>
- </record>
-
- <record id="base.group_website_publisher" model="res.groups">
- <field name="implied_ids" eval="[(4, ref('group_documentaion_moderator'))]"/>
- </record>
-
-</data>
-</openerp>
+++ /dev/null
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_documentation_toc,documentation.toc,model_documentation_toc,,1,0,0,0
-
+++ /dev/null
-all: website_doc.css
-%.css: %.sass
- sass -t expanded --compass --unix-newlines $< $@
-watch:
- sass -t expanded --compass --unix-newlines --watch .:.
+++ /dev/null
-.document {
- background: whitesmoke;
- padding-bottom: 1px;
-}
-
-.document_page {
- min-height: 600px;
- background: white;
- overflow: hidden;
- -webkit-border-radius: 1px;
- -moz-border-radius: 1px;
- -ms-border-radius: 1px;
- -o-border-radius: 1px;
- border-radius: 1px;
- -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
- -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
-}
-.menu-tree li{
- padding: 0px 0px 0px 10px;
-}
+++ /dev/null
-.document
- background: whitesmoke
- padding-bottom: 1px
-
-.document_page
- min-height: 600px
- background: white
- overflow: hidden
- -webkit-border-radius: 1px
- -moz-border-radius: 1px
- -ms-border-radius: 1px
- -o-border-radius: 1px
- border-radius: 1px
- -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
- -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
-
-.menu-tree li
- padding: 0px 0px 0px 10px
\ No newline at end of file
+++ /dev/null
-(function() {
- "use strict";
-
- var website = openerp.website;
- var _t = openerp._t;
- website.add_template_file('/website_doc/static/src/xml/website_doc.xml');
-
- website.is_editable = true;
- website.EditorBar.include({
- start: function() {
- website.is_editable_button = website.is_editable_button || !!$("#wrap").size();
- var res = this._super();
- this.$(".dropdown:has(.oe_content_menu)").removeClass("hidden");
- return res;
- },
- events: _.extend({}, website.EditorBar.prototype.events, {
- 'click a[data-action=new_toc]': function (ev) {
- ev.preventDefault();
- website.prompt({
- id: "editor_new_toc",
- window_title: _t("New Table Of Content"),
- input: "Table Of Content Name",
- }).then(function (toc_name) {
- website.form('/doc/new', 'POST', {
- toc_name: toc_name
- });
- });
- }
- }),
- });
-})();
+++ /dev/null
-$(document).ready(function () {
-
- $(function () {
- $('.menu-tree li li').hide();
- $('.menu-tree li .active').parents().find(' > ul > li').show();
- $('.menu-tree li').on('click', function (e) {
- var children = $(this).find(' > ul > li');
- if (children.is(":visible")) {
- children.hide('fast');
- $(this).attr('title', 'Expand this branch');
- } else {
- children.show('fast');
- $(this).attr('title', 'Collapse this branch');
- }
- e.stopPropagation();
- });
- });
-
-});
+++ /dev/null
-<templates id="template" xml:space="preserve">
- <t t-extend="website.editorbar">
- <t t-jquery="ul.oe_content_menu" t-operation="append">
- <li><a href="#" data-action="new_toc">New Table Of Content</a></li>
- </t>
- </t>
-</templates>
+++ /dev/null
-<?xml version="1.0"?>
-<openerp>
- <data>
-
- <!-- DOCUMENTATION TOC VIEWS -->
-
- <record id="view_documentation_toc_hierarchy" model="ir.ui.view">
- <field name="name">documentation.toc.list</field>
- <field name="model">documentation.toc</field>
- <field name="field_parent">child_ids</field>
- <field name="arch" type="xml">
- <tree string="Documentation TOC">
- <field name="name"/>
- </tree>
- </field>
- </record>
-
- <record id="view_documentation_toc_list" model="ir.ui.view">
- <field name="name">documentation.toc.list</field>
- <field name="model">documentation.toc</field>
- <field name="arch" type="xml">
- <tree string="Documentation TOC">
- <field name="name"/>
- </tree>
- </field>
- </record>
-
- <record id="view_documentation_toc_form" model="ir.ui.view">
- <field name="name">documentation.toc.form</field>
- <field name="model">documentation.toc</field>
- <field name="arch" type="xml">
- <form string="Documentation TOC" version="7.0">
- <sheet>
- <group>
- <field name="name"/>
- <field name="parent_id"/>
- </group>
- </sheet>
- </form>
- </field>
- </record>
-
- <record id="action_documentation_toc" model="ir.actions.act_window">
- <field name="name">Documentation</field>
- <field name="res_model">documentation.toc</field>
- <field name="view_type">form</field>
- <field name="view_mode">tree,form</field>
- </record>
-
- <menuitem id="menu_documentation" parent="website_forum.menu_website_forum" groups="website_doc.group_documentaion_moderator" name="Documentation" action="action_documentation_toc" sequence="20"/>
-
- <record id="action_documentation_toc_hierarchy" model="ir.actions.act_window">
- <field name="name">Documentation Hierarchy</field>
- <field name="res_model">documentation.toc</field>
- <field name="view_type">tree</field>
- <field name="view_mode">tree</field>
- <field name="domain">[('parent_id','=',False)]</field>
- <field name="view_id" ref="view_documentation_toc_hierarchy"/>
- </record>
-
- <menuitem id="menu_documentation_hierarchy" parent="website_forum.menu_website_forum" groups="website_doc.group_documentaion_moderator" name="Documentation Hierarchy" action="action_documentation_toc_hierarchy" sequence="25"/>
-
- </data>
-</openerp>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
- <data>
-
-<!-- Editor custo -->
-<template id="editor_head" inherit_id="website.editor_head"
- name="Event Editor">
- <xpath expr="//script[@id='website_tour_js']" position="after">
- <script type="text/javascript" src="/website_doc/static/src/js/website_doc.editor.js"/>
- </xpath>
-</template>
-
-<!-- Layout add nav and footer -->
-<template id="header_footer_custom" inherit_id="website.layout"
- name="Footer Documentation Link">
- <xpath expr="//footer//ul[@name='products']" position="inside">
- <li><a href="/doc">Documentation</a></li>
- </xpath>
-</template>
-
-<!-- Page Index -->
-<template id="documentation" name="Documentation Index">
- <t t-call="website.layout">
- <t t-set="head">
- <link rel='stylesheet' href='/website_doc/static/src/css/website_doc.css'/>
- <script type="text/javascript" src="/website_doc/static/src/js/website_doc.js"/>
- </t>
- <div class="container mt16 document">
- <div class="col-md-3 mt32 css_noprint bs-sidebar menu-tree">
- <t t-call="website_doc.side_panel"><t t-set="documentation" t-value="documentaion_toc"/></t>
- </div>
- <div class="col-md-9 mt32 document_page">
- <strong><h2 t-esc="topic.name" class="text-center"/></strong>
- <div t-foreach="topic.post_ids" t-as="post">
- <h2><p class="faq-question" t-esc="post.name"/></h2>
- <div t-if="post.pertinent_answer_id">
- <p><t t-raw="post.pertinent_answer_id.content"/></p>
- </div>
- <div class="pull-right">
- <a t-attf-href="/forum/#{ slug(post.forum_id) }/question/#{ slug(post) }">Read More About This..</a>
- </div>
- </div>
- </div>
- <div class="oe_structure"/>
- </div>
- </t>
-</template>
-
-<!--MENU LIST-->
-<template id="side_panel">
- <ul class="nav nav-pills nav-stacked">
- <t t-foreach="documentation" t-as="toc">
- <li t-attf-class="tree_toggler #{ topic==toc and 'active' or ''}">
- <a t-attf-href="/doc/#{ slug(toc) }" t-if="not toc.child_ids">
- <t t-esc="toc.name"/>
- </a>
- <a t-attf-href="" t-if="toc.child_ids">
- <t t-esc="toc.name"/>
- </a>
- <t t-if="toc.child_ids">
- <t t-call="website_doc.side_panel"><t t-set="documentation" t-value="toc.child_ids"/></t>
- </t>
- </li>
- </t>
- </ul>
-</template>
-
-<!--TOC ON FORUM POST-->
-<template id="forum_question_right_column" inherit_id="website_forum.header" name="Table of Content">
- <xpath expr="//script[@src='/website_forum/static/src/js/website_forum.js']" position="after">
- <script type="text/javascript" src="/website_doc/static/src/js/website_doc.js"/>
- </xpath>
- <xpath expr="//div[@id='about_forum']" position="before">
- <div t-if="header.get('question_data')" groups="website_doc.group_documentaion_moderator">
- <div class="panel panel-default">
- <div class="panel-heading" id="about_forum">
- <h3 class="panel-title">Documentation</h3>
- </div>
- <div class="panel-body">
- <form t-attf-action="/forum/#{ slug(forum) }/question/#{ slug(question) }/toc" role="form" method="post">
- <div class="input-group navbar-right">
- <select class="form-control" name="content">
- <option value=""></option>
- <t t-foreach="documentaion_toc or []" t-as="toc">
- <option t-att-value="toc.id" t-att-selected="toc.id == question.toc_id.id"><t t-esc="toc.name"/></option>
- </t>
- </select>
- <span class="input-group-btn">
- <button class="btn btn-primary ">save</button>
- </span>
- </div>
- </form>
- </div>
- </div>
- </div>
- </xpath>
-</template>
-
- </data>
-</openerp>
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import controllers
+import models
--- /dev/null
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2014-Today OpenERP SA (<http://www.openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'Documentation',
+ 'category': 'Website',
+ 'summary': 'Forum, Documentation',
+ 'version': '1.0',
+ 'description': """
+Documentation based on question and pertinent answers of Forum
+ """,
+ 'author': 'OpenERP SA',
+ 'depends': [
+ 'website_forum'
+ ],
+ 'data': [
+ 'data/doc_data.xml',
+ 'data/cron.xml',
+ 'security/ir.model.access.csv',
+ 'security/doc_security.xml',
+ 'views/doc.xml',
+ 'views/website_doc.xml',
+ ],
+ 'demo': [
+ 'data/doc_demo.xml',
+ ],
+ 'installable': True,
+ 'application': True,
+}
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import main
--- /dev/null
+# -*- coding: utf-8 -*-
+
+
+from openerp.addons.web import http
+from openerp.addons.web.http import request
+from openerp.addons.website.models.website import slug
+
+
+# from openerp.addons.website.controllers.main import Website as controllers
+# import werkzeug.urls
+# from datetime import datetime
+# import simplejson
+# from openerp import tools
+# from openerp import SUPERUSER_ID
+# from openerp.addons.web.controllers.main import login_redirect
+# from openerp.addons.website_forum.controllers.main import WebsiteForum
+#
+# controllers = controllers()
+
+class WebsiteDoc(http.Controller):
+ @http.route(['/forum/how-to', '/forum/how-to/<model("documentation.toc"):toc>'], type='http', auth="public", website=True, multilang=True)
+ def toc(self, toc=None, **kwargs):
+ cr, uid, context, toc_id = request.cr, request.uid, request.context, False
+ if toc:
+ toc = [toc]
+ else:
+ toc_obj = request.registry['forum.documentation.toc']
+ obj_ids = toc_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
+ toc = toc_obj.browse(cr, uid, obj_ids, context=context)
+ value = {
+ 'sections': toc,
+ }
+ return request.website.render("website_forum_doc.documentation", value)
+
+ @http.route(['/forum/how-to/<model("documentation.toc"):toc>/<model("forum.post"):post>'], type='http', auth="public", website=True, multilang=True)
+ def how_to(self, toc, post, **kwargs):
+ assert post.documentation_toc_id.id == toc.id, "Wrong post, should implement a redirect here"
+ value = {
+ 'section': toc,
+ 'post': post
+ }
+ return request.website.render("website_forum_doc.documentation.post", value)
+
+
+#---------------------
+# Forum Posts
+# --------------------
+#
+# class WebsiteForum(WebsiteForum):
+#
+# def prepare_question_values(self, forum, **kwargs):
+# cr, uid, context = request.cr, request.uid, request.context
+# TOC = request.registry['documentation.toc']
+# obj_ids = TOC.search(cr, uid, [('child_ids', '=', False)], context=context)
+# toc = TOC.browse(cr, uid, obj_ids, context=context)
+# values = super(WebsiteForum, self).prepare_question_values(forum=forum, kwargs=kwargs)
+# values.update({'documentaion_toc': toc})
+# return values
+#
+# @http.route('/forum/<model("forum.forum"):forum>/question/<model("forum.post"):post>/toc', type='http', auth="user", multilang=True, website=True)
+# def post_toc(self, forum, post, **kwargs):
+# toc_id = int(kwargs.get('content')) if kwargs.get('content') else False
+# request.registry['forum.post'].write(request.cr, request.uid, [post.id], {'toc_id': toc_id}, context=request.context)
+# return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+ <record forcecreate="True" id="ir_cron_check_challenge" model="ir.cron">
+ <field name="name">Run Moderator Checker</field>
+ <field name="interval_number">1</field>
+ <field name="interval_type">days</field>
+ <field name="numbercall">-1</field>
+ <field name="doall" eval="False" />
+ <field name="model">res.users</field>
+ <field name="function">_cron_moderator_access_update</field>
+ <field name="args">()</field>
+ </record>
+ </data>
+</openerp>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="menu_questions" model="website.menu">
+ <field name="name">Documentation</field>
+ <field name="url" eval="'/doc'"/>
+ <field name="parent_id" ref="website.main_menu"/>
+ <field name="sequence" type="int">65</field>
+ </record>
+
+ <!-- JUMP TO DOCUMENTATION AT INSTALL -->
+ <record id="action_open_documentation" model="ir.actions.act_url">
+ <field name="name">Documentation</field>
+ <field name="target">self</field>
+ <field name="url" eval="'/doc'"/>
+ </record>
+ <record id="base.open_menu" model="ir.actions.todo">
+ <field name="action_id" ref="action_open_documentation"/>
+ <field name="state">open</field>
+ </record>
+
+ </data>
+</openerp>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!-- Table Of Content -->
+ <record id="toc_functional_doc" model="documentation.toc">
+ <field name="name">Functional Documentation</field>
+ </record>
+ <record id="toc_sale" model="documentation.toc">
+ <field name="name">Sales Management</field>
+ <field name="parent_id" ref="toc_functional_doc"/>
+ </record>
+ <record id="toc_sale_customer" model="documentation.toc">
+ <field name="name">Customers</field>
+ <field name="parent_id" ref="toc_sale"/>
+ </record>
+ <record id="toc_sale_so" model="documentation.toc">
+ <field name="name">Sales orders</field>
+ <field name="parent_id" ref="toc_sale"/>
+ </record>
+ <record id="toc_0" model="documentation.toc">
+ <field name="name">Sales & Warehouse</field>
+ <field name="parent_id" ref="toc_sale"/>
+ </record>
+ <record id="toc_crm" model="documentation.toc">
+ <field name="name">Customer Relationship Management</field>
+ <field name="parent_id" ref="toc_functional_doc"/>
+ </record>
+ <record id="toc_crm_lead" model="documentation.toc">
+ <field name="name">Lead & Opportunity</field>
+ <field name="parent_id" ref="toc_crm"/>
+ </record>
+ <record id="toc_crm_claim" model="documentation.toc">
+ <field name="name">Claims</field>
+ <field name="parent_id" ref="toc_crm"/>
+ </record>
+ <record id="toc_crm_after_sale" model="documentation.toc">
+ <field name="name">After-sale communication</field>
+ <field name="parent_id" ref="toc_crm"/>
+ </record>
+ <record id="toc_website" model="documentation.toc">
+ <field name="name">Website</field>
+ <field name="parent_id" ref="toc_functional_doc"/>
+ </record>
+ <record id="toc_cms_ecommerce" model="documentation.toc">
+ <field name="name">CMS & eCommerce</field>
+ <field name="parent_id" ref="toc_website"/>
+ </record>
+ <record id="toc_hrm" model="documentation.toc">
+ <field name="name">Human Resources Management</field>
+ <field name="parent_id" ref="toc_functional_doc"/>
+ </record>
+ <record id="toc_hrm_contract" model="documentation.toc">
+ <field name="name">Employee Contract</field>
+ <field name="parent_id" ref="toc_hrm"/>
+ </record>
+
+ <!-- Questions -->
+ <record id="website_forum.question_0" model="forum.post">
+ <field name="toc_id" ref="toc_hrm_contract"/>
+ </record>
+ <record id="website_forum.question_1" model="forum.post">
+ <field name="toc_id" ref="toc_cms_ecommerce"/>
+ </record>
+
+ </data>
+</openerp>
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import documentation
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import openerp
+from openerp.osv import osv, fields
+from openerp.tools.translate import _
+
+
+class Documentation(osv.Model):
+ _name = 'documentation.toc'
+ _description = 'Table Of Content For Documentation'
+ _inherit = ['website.seo.metadata']
+
+ _columns = {
+ 'name': fields.char('Name', required=True, translate=True),
+ 'parent_id': fields.many2one('documentation.toc', 'Parent Table Of Content'),
+ 'child_ids': fields.one2many('documentation.toc', 'parent_id', 'Children Table Of Content'),
+ 'post_ids': fields.one2many('forum.post', 'toc_id', 'Posts'),
+ }
+
+class Post(osv.Model):
+ _inherit = 'forum.post'
+
+ def _get_pertinent_answer(self, cr, uid, ids, field_name=False, arg={}, context=None):
+ '''Set answer which have been accepted or have maximum votes'''
+ res = {}
+ for post in self.browse(cr, uid, ids, context=context):
+ pertinent_answer_ids = self.search(cr, uid, [('parent_id', '=', post.id)], order='is_correct, vote_count desc', context=context)
+ res[post.id] = pertinent_answer_ids[0] if pertinent_answer_ids else False
+ return res
+
+ _columns = {
+ 'name': fields.char('Title', size=128),
+ 'toc_id': fields.many2one('documentation.toc', 'Table of Content'),
+ 'pertinent_answer_id':fields.function(_get_pertinent_answer, string="Pertinent Answer", type='many2one', relation="forum.post",
+ store={
+ 'forum.post': (lambda self, cr, uid, ids, c={}: ids, [], 10),
+ }
+ ),
+ }
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import openerp
+from openerp.osv import osv, fields
+
+class Documentation(osv.Model):
+ _name = 'forum.documentation.toc'
+ _description = 'Documentation ToC'
+ _inherit = ['website.seo.metadata']
+ _order = "parent_left"
+ _parent_order = "sequence, name"
+ _parent_store = True
+ _columns = {
+ 'sequence': fields.integer('Sequence'),
+ 'name': fields.char('Name', required=True, translate=True),
+ 'parent_id': fields.many2one('documentation.toc', 'Parent Table Of Content'),
+ 'child_ids': fields.one2many('documentation.toc', 'parent_id', 'Children Table Of Content'),
+ 'parent_left': fields.integer('Left Parent', select=True),
+ 'parent_right': fields.integer('Right Parent', select=True),
+ 'post_ids': fields.one2many('forum.post', 'documentation_toc_id', 'Posts'),
+ }
+ _constraints = [
+ (osv.osv._check_recursion, 'Error ! You cannot create recursive categories.', ['parent_id'])
+ ]
+
+
+class DocumentationStage(osv.Model):
+ _name = 'forum.documentation.stage'
+ _description = 'Post Stage'
+ _order = 'sequence'
+ _columns = {
+ 'sequence': fields.integer('Sequence'),
+ 'name': fields.char('Stage Name', required=True, translate=True),
+ }
+
+
+class Post(osv.Model):
+ _inherit = 'forum.post'
+ _columns = {
+ 'documentation_toc_id': fields.many2one('forum.documentation.toc', 'Documentation ToC'),
+ 'documentation_stage_id': fields.many2one('forum.documentation.stage', 'Documentation Stage')
+ }
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from openerp.osv import osv, fields
+
+
+class Users(osv.Model):
+ _inherit = 'res.users'
+
+ def _cron_moderator_access_update(self, cr, uid, context=None, ids=False):
+ """Daily cron check.
+
+ - apply Moderation group for users who have more than 1000 karma.
+ """
+ modrator_group = self.pool['ir.model.data'].get_object(cr, uid, "website_doc", "group_documentaion_moderator", context=context)
+ applicable_user_ids = self.search(cr, uid, [ ('karma', '>=', 1000), ('groups_id', '!=', modrator_group.id)], context=context)
+ users = [(4, user) for user in applicable_user_ids]
+ self.pool['res.groups'].write(cr, uid, [modrator_group.id], {'users': users}, context=context)
+ return True
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data noupdate="1">
+
+ <record id="group_documentaion_moderator" model="res.groups">
+ <field name="name">Documentaion Moderator</field>
+ <field name="category_id" ref="base.module_category_website"/>
+ <field name="comment">the user will have access to add Table of content on questions to manage documentation.</field>
+ <field name="users" eval="[(4, ref('base.user_root'))]"/>
+ </record>
+
+ <record id="base.group_website_publisher" model="res.groups">
+ <field name="implied_ids" eval="[(4, ref('group_documentaion_moderator'))]"/>
+ </record>
+
+</data>
+</openerp>
--- /dev/null
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_documentation_toc,documentation.toc,model_documentation_toc,,1,0,0,0
+
--- /dev/null
+all: website_doc.css
+%.css: %.sass
+ sass -t expanded --compass --unix-newlines $< $@
+watch:
+ sass -t expanded --compass --unix-newlines --watch .:.
--- /dev/null
+.document {
+ background: whitesmoke;
+ padding-bottom: 1px;
+}
+
+.document_page {
+ min-height: 600px;
+ background: white;
+ overflow: hidden;
+ -webkit-border-radius: 1px;
+ -moz-border-radius: 1px;
+ -ms-border-radius: 1px;
+ -o-border-radius: 1px;
+ border-radius: 1px;
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
+}
+.menu-tree li{
+ padding: 0px 0px 0px 10px;
+}
--- /dev/null
+.document
+ background: whitesmoke
+ padding-bottom: 1px
+
+.document_page
+ min-height: 600px
+ background: white
+ overflow: hidden
+ -webkit-border-radius: 1px
+ -moz-border-radius: 1px
+ -ms-border-radius: 1px
+ -o-border-radius: 1px
+ border-radius: 1px
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35)
+
+.menu-tree li
+ padding: 0px 0px 0px 10px
\ No newline at end of file
--- /dev/null
+(function() {
+ "use strict";
+
+ var website = openerp.website;
+ var _t = openerp._t;
+ website.add_template_file('/website_doc/static/src/xml/website_doc.xml');
+
+ website.is_editable = true;
+ website.EditorBar.include({
+ start: function() {
+ website.is_editable_button = website.is_editable_button || !!$("#wrap").size();
+ var res = this._super();
+ this.$(".dropdown:has(.oe_content_menu)").removeClass("hidden");
+ return res;
+ },
+ events: _.extend({}, website.EditorBar.prototype.events, {
+ 'click a[data-action=new_toc]': function (ev) {
+ ev.preventDefault();
+ website.prompt({
+ id: "editor_new_toc",
+ window_title: _t("New Table Of Content"),
+ input: "Table Of Content Name",
+ }).then(function (toc_name) {
+ website.form('/doc/new', 'POST', {
+ toc_name: toc_name
+ });
+ });
+ }
+ }),
+ });
+})();
--- /dev/null
+$(document).ready(function () {
+
+ $(function () {
+ $('.menu-tree li li').hide();
+ $('.menu-tree li .active').parents().find(' > ul > li').show();
+ $('.menu-tree li').on('click', function (e) {
+ var children = $(this).find(' > ul > li');
+ if (children.is(":visible")) {
+ children.hide('fast');
+ $(this).attr('title', 'Expand this branch');
+ } else {
+ children.show('fast');
+ $(this).attr('title', 'Collapse this branch');
+ }
+ e.stopPropagation();
+ });
+ });
+
+});
--- /dev/null
+<templates id="template" xml:space="preserve">
+ <t t-extend="website.editorbar">
+ <t t-jquery="ul.oe_content_menu" t-operation="append">
+ <li><a href="#" data-action="new_toc">New Table Of Content</a></li>
+ </t>
+ </t>
+</templates>
--- /dev/null
+<?xml version="1.0"?>
+<openerp>
+ <data>
+
+ <!-- DOCUMENTATION TOC VIEWS -->
+
+ <record id="view_documentation_toc_list" model="ir.ui.view">
+ <field name="name">documentation.toc.list</field>
+ <field name="model">documentation.toc</field>
+ <field name="arch" type="xml">
+ <tree string="Documentation TOC" editable="bottom">
+ <field name="sequence" widget="handle"/>
+ <field name="name"/>
+ <field name="parent_id"/>
+ </tree>
+ </field>
+ </record>
+ <record id="action_documentation_toc" model="ir.actions.act_window">
+ <field name="name">Documentation</field>
+ <field name="res_model">documentation.toc</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree</field>
+ </record>
+ <menuitem id="menu_documentation"
+ parent="website_forum.menu_website_forum" groups="base.group_user"
+ name="Documentation ToC" action="action_documentation_toc" sequence="20"/>
+
+
+ <record id="view_documentation_toc_list" model="ir.ui.view">
+ <field name="name">documentation.toc.list</field>
+ <field name="model">documentation.toc</field>
+ <field name="arch" type="xml">
+ <tree string="Documentation TOC" editable="bottom">
+ <field name="sequence" widget="handle"/>
+ <field name="name"/>
+ <field name="parent_id"/>
+ </tree>
+ </field>
+ </record>
+ <record id="action_documentation_toc" model="ir.actions.act_window">
+ <field name="name">Documentation</field>
+ <field name="res_model">documentation.toc</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree</field>
+ </record>
+ <menuitem id="menu_documentation"
+ parent="website_forum.menu_website_forum" groups="base.group_user"
+ name="Documentation ToC" action="action_documentation_toc" sequence="20"/>
+
+
+ <!-- Project Task Kanban View -->
+ <record model="ir.ui.view" id="view_forum_post_kanban">
+ <field name="name">forum.post.kanban</field>
+ <field name="model">forum.post</field>
+ <field name="arch" type="xml">
+ <kanban default_group_by="documentation_stage_id" >
+ <field name="stage_id"/>
+ <field name="create_uid"/>
+ <field name="color"/>
+ <templates>
+ <t t-name="kanban-box">
+ <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click">
+ <div class="oe_dropdown_toggle oe_dropdown_kanban" groups="base.group_user">
+ <span class="oe_e">í</span>
+ <ul class="oe_dropdown_menu">
+ <li t-if="widget.view.is_action_enabled('edit')"><a type="edit">Edit...</a></li>
+ <li t-if="widget.view.is_action_enabled('delete')"><a type="delete">Delete</a></li>
+ <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
+ </ul>
+ </div>
+
+ <div class="oe_kanban_content">
+ <div><b><field name="name"/></b></div>
+ <div>
+ <field name="documentation_toc_id"/>
+ </div>
+ <div class="oe_kanban_bottom_right">
+ <img t-att-src="kanban_image('res.users', 'image_small', record.create_id.raw_value)" t-att-title="record.create_uid.value" width="24" height="24" class="oe_kanban_avatar"/>
+ </div>
+ </div>
+ <div class="oe_clear"></div>
+ </div>
+ </t>
+ </templates>
+ </kanban>
+ </field>
+ </record>
+
+
+ <record id="action_forum_doc_post" model="ir.actions.act_window">
+ <field name="name">Documentation Posts</field>
+ <field name="res_model">forum.post</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">kanban,tree,form</field>
+ <field name="domain">[('documentation_toc_id','<>', False)]</field>
+ </record>
+ <menuitem id="menu_forum_doc_posts"
+ parent="menu_website_forum" name="Documentation Posts"
+ action="action_forum_doc_post" sequence="25"/>
+
+
+
+ </data>
+</openerp>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!-- Layout add nav and footer -->
+ <template id="header_footer_custom" inherit_id="website.layout"
+ name="Footer Documentation Link">
+ <xpath expr="//footer//ul[@name='products']" position="inside">
+ <li><a href="/forum/how-to">Documentation</a></li>
+ </xpath>
+ </template>
+
+ <!-- Page Index -->
+ <template id="documentation" name="Documentation Index">
+ <t t-call="website.layout">
+ <t t-set="head">
+ <link rel='stylesheet' href='/website_forum_doc/static/src/css/website_doc.css'/>
+ <script type="text/javascript" src="/website_forum_doc/static/src/js/website_doc.js"/>
+ </t>
+ <div class="container mt16 document">
+ <div class="col-md-3 mt32 css_noprint bs-sidebar menu-tree">
+ <t t-call="website_doc.side_panel"><t t-set="documentation" t-value="documentaion_toc"/></t>
+ </div>
+ <div class="col-md-9 mt32 document_page">
+ <strong><h2 t-esc="topic.name" class="text-center"/></strong>
+ <div t-foreach="topic.post_ids" t-as="post">
+ <h2><p class="faq-question" t-esc="post.name"/></h2>
+ <div t-if="post.pertinent_answer_id">
+ <p><t t-raw="post.pertinent_answer_id.content"/></p>
+ </div>
+ <div class="pull-right">
+ <a t-attf-href="/forum/#{ slug(post.forum_id) }/question/#{ slug(post) }">Read More About This..</a>
+ </div>
+ </div>
+ </div>
+ <div class="oe_structure"/>
+ </div>
+ </t>
+ </template>
+
+ <!--MENU LIST-->
+ <template id="side_panel">
+ <ul class="nav nav-pills nav-stacked">
+ <t t-foreach="documentation" t-as="toc">
+ <li t-attf-class="tree_toggler #{ topic==toc and 'active' or ''}">
+ <a t-attf-href="/forum/how-to/#{ slug(toc) }" t-if="not toc.child_ids">
+ <t t-esc="toc.name"/>
+ </a>
+ <a t-attf-href="" t-if="toc.child_ids">
+ <t t-esc="toc.name"/>
+ </a>
+ <t t-if="toc.child_ids">
+ <t t-call="website_doc.side_panel"><t t-set="documentation" t-value="toc.child_ids"/></t>
+ </t>
+ </li>
+ </t>
+ </ul>
+ </template>
+
+ <!--TOC ON FORUM POST-->
+ <template id="forum_question_right_column" inherit_id="website_forum.header" name="Table of Content">
+ <xpath expr="//script[@src='/website_forum/static/src/js/website_forum.js']" position="after">
+ <script type="text/javascript" src="/website_doc/static/src/js/website_doc.js"/>
+ </xpath>
+ <xpath expr="//div[@id='about_forum']" position="before">
+ <div t-if="header.get('question_data')" groups="website_doc.group_documentaion_moderator">
+ <div class="panel panel-default">
+ <div class="panel-heading" id="about_forum">
+ <h3 class="panel-title">Documentation</h3>
+ </div>
+ <div class="panel-body">
+ <form t-attf-action="/forum/#{ slug(forum) }/question/#{ slug(question) }/toc" role="form" method="post">
+ <div class="input-group navbar-right">
+ <select class="form-control" name="content">
+ <option value=""></option>
+ <t t-foreach="documentaion_toc or []" t-as="toc">
+ <option t-att-value="toc.id" t-att-selected="toc.id == question.toc_id.id"><t t-esc="toc.name"/></option>
+ </t>
+ </select>
+ <span class="input-group-btn">
+ <button class="btn btn-primary ">save</button>
+ </span>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+ </xpath>
+ </template>
+
+ </data>
+</openerp>