diff --git a/addons/web_uservoice/LICENSE b/addons/web_uservoice/LICENSE index 27a1a4cf453..ff64be448e9 100644 --- a/addons/web_uservoice/LICENSE +++ b/addons/web_uservoice/LICENSE @@ -1,5 +1,5 @@ OpenERP, Open Source Management Solution -Copyright © 2010 OpenERP SA (). +Copyright © 2010-2011 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 diff --git a/addons/web_uservoice/__init__.py b/addons/web_uservoice/__init__.py index 723a87ab410..61c9429ffc4 100644 --- a/addons/web_uservoice/__init__.py +++ b/addons/web_uservoice/__init__.py @@ -1,7 +1,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2010 OpenERP s.a. (). +# Copyright (C) 2010-2011 OpenERP s.a. (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,3 +17,5 @@ # along with this program. If not, see . # ############################################################################## + +import controllers diff --git a/addons/web_uservoice/__openerp__.py b/addons/web_uservoice/__openerp__.py index ebcc91e7e67..bbf20b2e83c 100644 --- a/addons/web_uservoice/__openerp__.py +++ b/addons/web_uservoice/__openerp__.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2010 OpenERP s.a. (). +# Copyright (C) 2010-2011 OpenERP s.a. (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,7 +20,7 @@ ############################################################################## { 'name': 'Receive User Feedback', - 'version': '1.0', + 'version': '2.0', 'category': 'Tools', 'complexity': "easy", 'description': """ @@ -36,5 +36,8 @@ Invite OpenERP user feedback, powered by uservoice. 'installable': True, 'active': False, 'certificate': '0040452504963885', - 'images': ['images/submit_an_idea.jpeg','images/web_uservoice_feedback.jpeg'], + + 'js': ['static/src/js/web_uservoice.js'], + 'css': ['static/src/css/uservoice.css'], + 'images': ['static/src/img/submit_an_idea.jpeg', 'static/src/img/web_uservoice_feedback.jpeg'], } diff --git a/addons/web_uservoice/web/__init__.py b/addons/web_uservoice/controllers/__init__.py similarity index 88% rename from addons/web_uservoice/web/__init__.py rename to addons/web_uservoice/controllers/__init__.py index c651b91f353..2e0d87b177e 100644 --- a/addons/web_uservoice/web/__init__.py +++ b/addons/web_uservoice/controllers/__init__.py @@ -1,7 +1,7 @@ ############################################################################## -# +# # OpenERP, Open Source Management Solution -# Copyright (C) 2010 OpenERP s.a. (). +# Copyright (C) 2011 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 @@ -14,9 +14,8 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import editors -import controllers +import main diff --git a/addons/web_uservoice/controllers/main.py b/addons/web_uservoice/controllers/main.py new file mode 100644 index 00000000000..cf5be3d5e7a --- /dev/null +++ b/addons/web_uservoice/controllers/main.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 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 . +# +############################################################################## + +import web.common.dispatch as openerpweb + + +class UserVoiceController(openerpweb.Controller): + _cp_path = '/web_uservoice/uv' + + @openerpweb.jsonrequest + def forum(self, req, menu_id): + menu = '' + if menu_id: + try: + menu_id = int(menu_id) + except ValueError: + pass + else: + ctx = dict(lang='NO_LANG') # force loading original string even if the english have been translated... + menus = req.session.model('ir.ui.menu') + try: + menu = menus.read([menu_id], ['name'], ctx)[0]['name'] or '' + except KeyError: + pass + + general_forum = '77459' + forum = { + 'accounting': '87921', + 'administration': '87935', + 'human resources': '87923', + 'knowledge': '87927', + 'manufacturing': '87915', + 'marketing': '87925', + 'point of sale': '87929', + 'project': '87919', + 'purchases': '87911', + 'sales': '87907', + 'tools': '87933', + 'warehouse': '87913', + }.get(menu.lower().strip(), general_forum) + + return {'forum': forum} + diff --git a/addons/web_uservoice/web/static/css/uservoice.css b/addons/web_uservoice/static/src/css/uservoice.css similarity index 52% rename from addons/web_uservoice/web/static/css/uservoice.css rename to addons/web_uservoice/static/src/css/uservoice.css index 9ca2af55678..665ccee7f6e 100644 --- a/addons/web_uservoice/web/static/css/uservoice.css +++ b/addons/web_uservoice/static/src/css/uservoice.css @@ -1,7 +1,7 @@ -#corner p.feedback a { +div.header_corner div.feedback a { /*color: #9a0404;*/ } -#corner p.feedback img { +div.header_corner div.feedback img { vertical-align: middle; margin-right: 0.5em; } diff --git a/addons/web_uservoice/static/src/js/web_uservoice.js b/addons/web_uservoice/static/src/js/web_uservoice.js new file mode 100644 index 00000000000..ec1ddd65d28 --- /dev/null +++ b/addons/web_uservoice/static/src/js/web_uservoice.js @@ -0,0 +1,59 @@ + +openerp.web_uservoice = function(instance) { + +var QWeb = instance.web.qweb; +QWeb.add_template('/web_uservoice/static/src/xml/web_uservoice.xml'); + +$(function() { + var src = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js"; + $.getScript(src); +}); + + +instance.web_uservoice.UserVoice = instance.web.Widget.extend({ + template: 'Header-UserVoice', + default_forum: '77459', + + init: function() { + this._super.apply(this, arguments); + this.uservoiceOptions = { + key: 'openerpsa', + host: 'feedback.openerp.com', + forum: this.default_forum, + lang: 'en', + showTab: false + }; + + instance.webclient.menu.do_menu_click.add_last(this.do_menu_click); + }, + + start: function() { + this._super(); + + var self = this; + this.$element.find('a').click(function(e) { + e.preventDefault(); + UserVoice.Popin.show(self.uservoiceOptions); + return false; + }); + }, + + + do_menu_click: function($clicked_menu, manual) { + var id = $clicked_menu.attr('data-menu'); + if (id) { + var self = this; + this.rpc('/web_uservoice/uv/forum', {menu_id: id}, function(result) { + self.uservoiceOptions.forum = result.forum || self.default_forum; + }); + } + }, + +}); + + +instance.webclient.uservoice = new instance.web_uservoice.UserVoice(instance.webclient); +instance.webclient.uservoice.prependTo('div.header_corner'); + +}; + diff --git a/addons/web_uservoice/static/src/xml/web_uservoice.xml b/addons/web_uservoice/static/src/xml/web_uservoice.xml new file mode 100644 index 00000000000..e37ed2c17d3 --- /dev/null +++ b/addons/web_uservoice/static/src/xml/web_uservoice.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/addons/web_uservoice/web/controllers.py b/addons/web_uservoice/web/controllers.py deleted file mode 100644 index 07376ee8fed..00000000000 --- a/addons/web_uservoice/web/controllers.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2010 OpenERP s.a. (). -# -# 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 . -# -############################################################################## - -from openerp.controllers import SecuredController -from openobject import rpc -from openobject.tools import expose -import cherrypy - -class Root(SecuredController): - - _cp_path = "/openerp" - - @expose(mark_only=True) - def menu(self, active=None, next=None): - try: - menu_id = int(active) - except (TypeError, ValueError): - menu_id = False - - menus = rpc.RPCProxy("ir.ui.menu") - ids = menus.search([('parent_id', '=', False)]) - if next or active: - if not menu_id and ids: - menu_id = ids[0] - - menu = '' - if menu_id: - ctx = dict(lang='NO_LANG') # force loading original string even if the english have been translated... - menu = menus.read([menu_id], ['name'], ctx)[0]['name'] or '' - - general_forum = 77459 - forum = { - 'accounting': 87921, - 'administration': 87935, - 'human resources': 87923, - 'knowledge': 87927, - 'manufacturing': 87915, - 'marketing': 87925, - 'point of sale': 87929, - 'project': 87919, - 'purchases': 87911, - 'sales': 87907, - 'tools': 87933, - 'warehouse': 87913, - }.get(menu.lower().strip(), general_forum) - - cherrypy.request.uservoice_forum = forum - return super(Root, self).menu(active, next) - - diff --git a/addons/web_uservoice/web/editors.py b/addons/web_uservoice/web/editors.py deleted file mode 100644 index 585bc3428f3..00000000000 --- a/addons/web_uservoice/web/editors.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2010-2011 OpenERP s.a. (). -# -# 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 . -# -############################################################################## -import openobject.templating - -class BaseTemplateEditor(openobject.templating.TemplateEditor): - templates = ['/openobject/controllers/templates/base.mako'] - - def edit(self, template, template_text): - output = super(BaseTemplateEditor, self).edit(template, template_text) - - end_head = output.index('') - - output = output[:end_head] + """ - - """ + output[end_head:] - - - end_body = output.index('') - - # testing forum: 84397 - output = output[:end_body] + """ - - """ + output[end_body:] - - return output - - -class HeaderTemplateEditor(openobject.templating.TemplateEditor): - templates = ['/openerp/controllers/templates/header.mako'] - - def edit(self, template, template_text): - output = super(HeaderTemplateEditor, self).edit(template, template_text) - - PAT = '
    ' - - ul = output.index(PAT) - output = output[:ul] + (""" - - """ % _('feedback')) + output[ul:] - - - return output -