diff --git a/addons/website_rating_project_issue/__init__.py b/addons/website_rating_project_issue/__init__.py new file mode 100644 index 00000000000..7175b82c57f --- /dev/null +++ b/addons/website_rating_project_issue/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +import controllers +import project_project diff --git a/addons/website_rating_project_issue/__openerp__.py b/addons/website_rating_project_issue/__openerp__.py new file mode 100644 index 00000000000..e7b33314681 --- /dev/null +++ b/addons/website_rating_project_issue/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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': 'Website Rating Project Issue', + 'version': '0.1', + 'category': 'Website', + 'complexity': 'easy', + 'description': """ +This module display project customer satisfaction on your website. +================================================================================================== + """, + 'author': 'Odoo SA', + 'depends': [ + 'website_project_issue', + 'rating_project_issue' + ], + 'data': [ + 'views/website_rating_project.xml' + ], + 'installable': True, +} diff --git a/addons/website_rating_project_issue/controllers/__init__.py b/addons/website_rating_project_issue/controllers/__init__.py new file mode 100644 index 00000000000..a84d81a791b --- /dev/null +++ b/addons/website_rating_project_issue/controllers/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import main diff --git a/addons/website_rating_project_issue/controllers/main.py b/addons/website_rating_project_issue/controllers/main.py new file mode 100644 index 00000000000..ae12d9eefb2 --- /dev/null +++ b/addons/website_rating_project_issue/controllers/main.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +from openerp import _ +from openerp.addons.web import http +from openerp.addons.web.http import request + + +class WebsiteRatingProject(http.Controller): + + @http.route(['/project/rating/'], type='http', auth="public", website=True) + def index(self, **kw): + projects = request.env['project.project'].search([]) + values = {'projects' : projects} + return request.website.render('website_rating_project_issue.index', values) + + @http.route(['/project/rating/'], type='http', auth="public", website=True) + def page(self, project=None, **kw): + # create domain for rating + domain = [] + if project.use_tasks: + task_ids = [t.id for t in project.tasks] + domain += ['&', ('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)] + if project.use_issues: + issue_ids = [i.id for i in project.issue_ids] + domain += ['&', ('res_model', '=', 'project.issue'), ('res_id', 'in', issue_ids)] + if project.use_issues and project.use_tasks: + domain = ['|'] + domain + ratings = request.env['rating.rating'].search(domain, order="write_date desc", limit=100) + # compute stat only for the last 100 ratings + grades_label = { + 'success' : _('Happy'), + 'warning': _('Okay'), + 'danger': _('Bad'), + } + res = dict.fromkeys(grades_label.keys(), 0) + for rating in ratings: + if rating.rating >= 7: + res['success'] += 1 + elif rating.rating > 3: + res['warning'] += 1 + else: + res['danger'] += 1 + for key, value in res.iteritems(): + res[key] = value / float(len(ratings)) * 100 if len(ratings) else 0 + # prepare and render + values = { + 'team': project.sudo().members, + 'project': project, + 'ratings' : ratings, + 'stats': res, + 'labels': grades_label, + } + return request.website.render('website_rating_project_issue.project_rating_page', values) diff --git a/addons/website_rating_project_issue/project_project.py b/addons/website_rating_project_issue/project_project.py new file mode 100644 index 00000000000..00897d3b333 --- /dev/null +++ b/addons/website_rating_project_issue/project_project.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from openerp import api, models + + +class Project(models.Model): + + _inherit = 'project.project' + + @api.multi + def action_view_all_rating(self): + """ Override this method without calling parent to redirect to rating website project page """ + self.ensure_one() + return { + 'type': 'ir.actions.act_url', + 'name': "Redirect to the Website Projcet Rating Page", + 'target': 'self', + 'url': "/project/rating/%s" % (self.id,) + } diff --git a/addons/website_rating_project_issue/static/src/css/website_rating_project_issue.css b/addons/website_rating_project_issue/static/src/css/website_rating_project_issue.css new file mode 100644 index 00000000000..7c4b741abad --- /dev/null +++ b/addons/website_rating_project_issue/static/src/css/website_rating_project_issue.css @@ -0,0 +1,24 @@ + +.oe_website_rating_project .thumbnail{ + height: 355px; +} + + +.oe_website_rating_project .progress { + position: relative; + height: 25px; +} +.oe_website_rating_project .progress > .progress-type { + position: absolute; + left: 0px; + font-weight: 800; + padding: 3px 30px 2px 10px; + color: rgb(255, 255, 255); + background-color: rgba(25, 25, 25, 0.2); +} +.oe_website_rating_project .progress > .progress-completed { + position: absolute; + right: 0px; + font-weight: 800; + padding: 3px 10px 2px; +} \ No newline at end of file diff --git a/addons/website_rating_project_issue/views/website_rating_project.xml b/addons/website_rating_project_issue/views/website_rating_project.xml new file mode 100644 index 00000000000..54f8263437a --- /dev/null +++ b/addons/website_rating_project_issue/views/website_rating_project.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + +