[MERGE] web_uservoice by chs

bzr revid: al@openerp.com-20111014004025-dhybe3j4u6c7xkzp
This commit is contained in:
Antony Lesuisse 2011-10-14 02:40:25 +02:00
commit f4c4e83926
9 changed files with 99 additions and 173 deletions

View File

@ -1,5 +1,5 @@
OpenERP, Open Source Management Solution
Copyright © 2010 OpenERP SA (<http://openerp.com>).
Copyright © 2010-2011 OpenERP SA (<http://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

View File

@ -1,7 +1,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
# Copyright (C) 2010-2011 OpenERP s.a. (<http://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
@ -17,3 +17,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

View File

@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
# Copyright (C) 2010-2011 OpenERP s.a. (<http://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
@ -20,7 +20,7 @@
##############################################################################
{
'name': 'Receive User Feedback',
'version': '1.0',
'version': '2.0',
'category': 'Hidden',
'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'],
}

View File

@ -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;
}

View File

@ -0,0 +1,80 @@
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.uservoiceForums = {};
this.uservoiceOptions = {
key: 'openerpsa',
host: 'feedback.openerp.com',
forum: this.default_forum,
lang: 'en',
showTab: false
};
instance.webclient.menu.do_menu_click.add_first(this.do_menu_click);
},
start: function() {
this._super();
var self = this;
var forum_mapping = {
'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',
};
var ds = new instance.web.DataSetSearch(this, 'ir.ui.menu', {lang: 'NO_LANG'}, [['parent_id', '=', false]]);
ds.read_slice(['name'], null, function(result) {
_.each(result, function(menu) {
self.uservoiceForums[menu.id] = forum_mapping[menu.name.toLowerCase()] || self.default_forum;
});
});
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) {
this.uservoiceOptions.forum = this.uservoiceForums[id] || this.default_forum;
}
},
});
instance.webclient.uservoice = new instance.web_uservoice.UserVoice(instance.webclient);
instance.webclient.uservoice.prependTo('div.header_corner');
};

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1:
-->
<templates id="template" xml:space="preserve">
<t t-name="Header-UserVoice">
<div class="block logout feedback"><a href="#"><img src="/web_uservoice/static/src/img/uv_favicon.png" />feedback</a></div>
</t>
</templates>

View File

@ -1,22 +0,0 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010 OpenERP s.a. (<http://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/>.
#
##############################################################################
import editors
import controllers

View File

@ -1,68 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010 OpenERP s.a. (<http://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/>.
#
##############################################################################
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)

View File

@ -1,76 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010-2011 OpenERP s.a. (<http://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/>.
#
##############################################################################
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('</head>')
output = output[:end_head] + """
<link rel="stylesheet" type="text/css" href="/web_uservoice/static/css/uservoice.css"/>
""" + output[end_head:]
end_body = output.index('</body>')
# testing forum: 84397
output = output[:end_body] + """
<script type="text/javascript">
var uservoiceOptions = {
key: 'openerpsa',
host: 'feedback.openerp.com',
forum: '${getattr(cp.request, 'uservoice_forum', 77459)}',
lang: 'en',
showTab: false
};
function _loadUserVoice() {
var s = document.createElement('script');
s.src = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js";
document.getElementsByTagName('head')[0].appendChild(s);
}
_loadSuper = window.onload;
window.onload = (typeof window.onload != 'function') ? _loadUserVoice : function() { _loadSuper(); _loadUserVoice(); };
</script>
""" + 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 class="tools">'
ul = output.index(PAT)
output = output[:ul] + ("""
<p class="logout feedback"><a href="#" onclick="UserVoice.Popin.show(uservoiceOptions); return false;"><img src="/web_uservoice/static/images/uv_favicon.png" />%s</a></p>
""" % _('feedback')) + output[ul:]
return output