From 229c057f3bdeacb4c646e217734030fc2f3ef7f4 Mon Sep 17 00:00:00 2001 From: "Jignesh Rathod (OpenERP)" Date: Mon, 2 Dec 2013 11:23:31 +0530 Subject: [PATCH 01/23] [IMP] Add colors in tree view of components.. bzr revid: jir@tinyerp.com-20131202055331-jk00a7cgpu55vnwf --- addons/mrp/mrp_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 2576235586f..5c2b45cc900 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -680,7 +680,7 @@ - + From 3abf050afc33a4baa16431e236801b1999546a7f Mon Sep 17 00:00:00 2001 From: "Pooja Zankhariya (OpenERP)" Date: Mon, 9 Dec 2013 14:49:48 +0500 Subject: [PATCH 02/23] [IMP]Improved colors for components bzr revid: pza@tinyerp.com-20131209094948-4zne4efiijzm2ly6 --- addons/mrp/mrp_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 5c2b45cc900..55973d6f47c 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -680,7 +680,7 @@ - + From cd25de6989577992a96140b9247f388f2582699c Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 16 Apr 2014 16:21:22 +0530 Subject: [PATCH 03/23] [ADD] website_doc: modue based on website_forum to show documentatoin based on questions and best answers. bzr revid: tpa@tinyerp.com-20140416105122-2368jv31gy26ek32 --- addons/website_doc/__init__.py | 4 + addons/website_doc/__openerp__.py | 48 +++++++++++ addons/website_doc/controllers/__init__.py | 3 + addons/website_doc/controllers/main.py | 61 +++++++++++++ addons/website_doc/data/doc_data.xml | 24 ++++++ addons/website_doc/data/doc_demo.xml | 22 +++++ addons/website_doc/models/__init__.py | 3 + addons/website_doc/models/doc.py | 37 ++++++++ .../website_doc/security/ir.model.access.csv | 3 + addons/website_doc/static/src/css/Makefile | 5 ++ .../static/src/css/website_doc.css | 0 .../static/src/css/website_doc.sass | 0 .../static/src/js/website_doc.editor.js | 31 +++++++ .../website_doc/static/src/js/website_doc.js | 12 +++ .../static/src/xml/website_doc.xml | 7 ++ addons/website_doc/views/doc.xml | 42 +++++++++ addons/website_doc/views/website_doc.xml | 86 +++++++++++++++++++ addons/website_forum/controllers/main.py | 7 +- addons/website_forum/views/website_forum.xml | 2 +- 19 files changed, 395 insertions(+), 2 deletions(-) create mode 100644 addons/website_doc/__init__.py create mode 100644 addons/website_doc/__openerp__.py create mode 100644 addons/website_doc/controllers/__init__.py create mode 100644 addons/website_doc/controllers/main.py create mode 100644 addons/website_doc/data/doc_data.xml create mode 100644 addons/website_doc/data/doc_demo.xml create mode 100644 addons/website_doc/models/__init__.py create mode 100644 addons/website_doc/models/doc.py create mode 100644 addons/website_doc/security/ir.model.access.csv create mode 100644 addons/website_doc/static/src/css/Makefile create mode 100644 addons/website_doc/static/src/css/website_doc.css create mode 100644 addons/website_doc/static/src/css/website_doc.sass create mode 100644 addons/website_doc/static/src/js/website_doc.editor.js create mode 100644 addons/website_doc/static/src/js/website_doc.js create mode 100644 addons/website_doc/static/src/xml/website_doc.xml create mode 100644 addons/website_doc/views/doc.xml create mode 100644 addons/website_doc/views/website_doc.xml diff --git a/addons/website_doc/__init__.py b/addons/website_doc/__init__.py new file mode 100644 index 00000000000..bde83af3aea --- /dev/null +++ b/addons/website_doc/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +import controllers +import models diff --git a/addons/website_doc/__openerp__.py b/addons/website_doc/__openerp__.py new file mode 100644 index 00000000000..8bf980b3a70 --- /dev/null +++ b/addons/website_doc/__openerp__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014-Today OpenERP SA (). +# +# 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 . +# +############################################################################## + +{ + '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', + 'views/doc.xml', + 'views/website_doc.xml', + 'security/ir.model.access.csv', + ], + 'qweb': [ + 'static/src/xml/*.xml' + ], + 'demo': [ + 'data/doc_demo.xml', + ], + 'installable': True, + 'application': True, +} diff --git a/addons/website_doc/controllers/__init__.py b/addons/website_doc/controllers/__init__.py new file mode 100644 index 00000000000..bbd183e955b --- /dev/null +++ b/addons/website_doc/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import main diff --git a/addons/website_doc/controllers/main.py b/addons/website_doc/controllers/main.py new file mode 100644 index 00000000000..87a7a934a5e --- /dev/null +++ b/addons/website_doc/controllers/main.py @@ -0,0 +1,61 @@ +# -*- 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'], type='http', auth="public", website=True, multilang=True) + def documentation(self, content='', **kwargs): + cr, uid, context, toc_id = request.cr, request.uid, request.context, False + TOC = request.registry['documentation.toc'] + obj_ids = TOC.search(cr, uid, [], context=context) + toc = TOC.browse(cr, uid, obj_ids, context=context) + if content: + toc_ids = TOC.search(cr, uid, [('name', '=', content)], context=context) + toc_id = TOC.browse(cr, uid, toc_ids, context=context)[0] + value = { + 'documentaion_toc': toc, + 'toc_id': toc_id, + } + 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" % slug(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, [], 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/question/toc', type='json', auth="user", multilang=True, website=True) + def post_toc(self, post_id, toc_id): + toc_id = int(toc_id) if toc_id else False + request.registry['forum.post'].write(request.cr, request.uid, [int(post_id)], {'toc_id': toc_id}, context=request.context) + return True \ No newline at end of file diff --git a/addons/website_doc/data/doc_data.xml b/addons/website_doc/data/doc_data.xml new file mode 100644 index 00000000000..124fb68a83b --- /dev/null +++ b/addons/website_doc/data/doc_data.xml @@ -0,0 +1,24 @@ + + + + + + Documentation + + + 65 + + + + + Documentation + self + + + + + open + + + + diff --git a/addons/website_doc/data/doc_demo.xml b/addons/website_doc/data/doc_demo.xml new file mode 100644 index 00000000000..b02fa647fe3 --- /dev/null +++ b/addons/website_doc/data/doc_demo.xml @@ -0,0 +1,22 @@ + + + + + + + CMS & eCommerce + + + Employee Contract + + + + + + + + + + + + diff --git a/addons/website_doc/models/__init__.py b/addons/website_doc/models/__init__.py new file mode 100644 index 00000000000..30f5c61cfe0 --- /dev/null +++ b/addons/website_doc/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import doc diff --git a/addons/website_doc/models/doc.py b/addons/website_doc/models/doc.py new file mode 100644 index 00000000000..07a8cd3831a --- /dev/null +++ b/addons/website_doc/models/doc.py @@ -0,0 +1,37 @@ +# -*- 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), + '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), + } + ), + } diff --git a/addons/website_doc/security/ir.model.access.csv b/addons/website_doc/security/ir.model.access.csv new file mode 100644 index 00000000000..49767b2a203 --- /dev/null +++ b/addons/website_doc/security/ir.model.access.csv @@ -0,0 +1,3 @@ +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 + diff --git a/addons/website_doc/static/src/css/Makefile b/addons/website_doc/static/src/css/Makefile new file mode 100644 index 00000000000..3cae206a13a --- /dev/null +++ b/addons/website_doc/static/src/css/Makefile @@ -0,0 +1,5 @@ +all: website_doc.css +%.css: %.sass + sass -t expanded --compass --unix-newlines $< $@ +watch: + sass -t expanded --compass --unix-newlines --watch .:. diff --git a/addons/website_doc/static/src/css/website_doc.css b/addons/website_doc/static/src/css/website_doc.css new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/website_doc/static/src/css/website_doc.sass b/addons/website_doc/static/src/css/website_doc.sass new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/website_doc/static/src/js/website_doc.editor.js b/addons/website_doc/static/src/js/website_doc.editor.js new file mode 100644 index 00000000000..5f7af42544d --- /dev/null +++ b/addons/website_doc/static/src/js/website_doc.editor.js @@ -0,0 +1,31 @@ +(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 + }); + }); + } + }), + }); +})(); diff --git a/addons/website_doc/static/src/js/website_doc.js b/addons/website_doc/static/src/js/website_doc.js new file mode 100644 index 00000000000..fad553863c9 --- /dev/null +++ b/addons/website_doc/static/src/js/website_doc.js @@ -0,0 +1,12 @@ +$(document).ready(function () { + + $('.post_toc').change(function (ev) { + var $option = $(ev.currentTarget); + openerp.jsonRpc("/forum/question/toc", 'call', { + 'post_id' : $('#question').attr("value"), + 'toc_id': $option.attr("value"), + }) + return true; + }); + +}); diff --git a/addons/website_doc/static/src/xml/website_doc.xml b/addons/website_doc/static/src/xml/website_doc.xml new file mode 100644 index 00000000000..b1ea9191b00 --- /dev/null +++ b/addons/website_doc/static/src/xml/website_doc.xml @@ -0,0 +1,7 @@ + + + +
  • New Table Of Content
  • +
    +
    +
    diff --git a/addons/website_doc/views/doc.xml b/addons/website_doc/views/doc.xml new file mode 100644 index 00000000000..d629a4b22a9 --- /dev/null +++ b/addons/website_doc/views/doc.xml @@ -0,0 +1,42 @@ + + + + + + + documentation.toc.list + documentation.toc + + + + + + + + + documentation.toc.form + documentation.toc + +
    + + + + + + + +
    +
    +
    + + + Documentation TOC + documentation.toc + form + tree,form + + + + +
    +
    diff --git a/addons/website_doc/views/website_doc.xml b/addons/website_doc/views/website_doc.xml new file mode 100644 index 00000000000..6cb310b882a --- /dev/null +++ b/addons/website_doc/views/website_doc.xml @@ -0,0 +1,86 @@ + + + + + +