summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJérome Maes <jem@openerp.com>2015-02-04 11:40:54 +0100
committerJérome Maes <jem@openerp.com>2015-02-04 15:24:48 +0100
commit6219c0b0fa593e9c1d28f42b2fc5988dc2d6df62 (patch)
tree3a9475b471acbb67b64d8ea22c52e8adcda0c01a /addons
parenta82b1394962b57ec27bd167fba63e5c1d844b623 (diff)
[ADD] website_rating_project_issue : display project feedback on the website. Using privacy/visibily defined on project.project and security rules defined in website_project_issue.
Diffstat (limited to 'addons')
-rw-r--r--addons/website_rating_project_issue/__init__.py3
-rw-r--r--addons/website_rating_project_issue/__openerp__.py39
-rw-r--r--addons/website_rating_project_issue/controllers/__init__.py2
-rw-r--r--addons/website_rating_project_issue/controllers/main.py52
-rw-r--r--addons/website_rating_project_issue/project_project.py18
-rw-r--r--addons/website_rating_project_issue/static/src/css/website_rating_project_issue.css24
-rw-r--r--addons/website_rating_project_issue/views/website_rating_project.xml128
7 files changed, 266 insertions, 0 deletions
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 (<http://tiny.be>).
+#
+# 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': '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/<model("project.project"):project>'], 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <data>
+ <!-- CSS Style Bundle -->
+ <template id="assets_frontend" inherit_id="website.assets_frontend" name="Website Rating Project Issue Assets">
+ <xpath expr="." position="inside">
+ <link rel="stylesheet" href="/website_rating_project_issue/static/src/css/website_rating_project_issue.css"/>
+ </xpath>
+ </template>
+
+ <!-- Layout add footer -->
+ <template id="header_footer_custom" inherit_id="website.footer_default" name="Project Issue Rating Footer Link">
+ <xpath expr="//ul[@id='products']" position="inside">
+ <li><a href="/project/rating/">Project Customer Satisfaction</a></li>
+ </xpath>
+ </template>
+
+ <!-- Page : List of project -->
+ <template id="index" name="Project Issue Rating List">
+ <t t-call="website.layout">
+ <t t-set="additional_title">Project Satisfaction</t>
+ <div id="wrap">
+ <div class="oe_structure"/>
+ <div class="container oe_website_rating_project">
+ <div class="row text-center">
+ <h2>Projects</h2>
+ </div>
+ <div class="oe_structure"/>
+ <div class="row">
+ <t t-foreach="projects" t-as="project">
+ <div t-if="project.percentage_satisfaction_project != -1" class="col-sm-6 col-xs-4 col-md-4 col-lg-4">
+ <div class="thumbnail">
+ <div>
+ <div class="caption">
+ <span class="label label-default pull-right"><t t-esc="project.privacy_visibility"/></span>
+ <h4><t t-esc="project.name"/></h4>
+ <p t-if="project.date" class="text-muted">
+ <i class="fa fa-calendar"/> End date : <t t-esc="project.date"/>
+ </p>
+ <p t-if="project.alias_name and project.alias_domain" class="text-muted">
+ <i class="fa fa-envelope"/> Email : <t t-esc="project.alias_name"/>@<t t-esc="project.alias_domain"/>
+ </p>
+ <div class="row">
+ <div t-if="project.use_tasks" class="col-md-6 text-center">
+ <h2><t t-esc="len(project.task_ids)"/></h2>
+ <p><t t-esc="project.label_tasks"/></p>
+ </div>
+ <div t-if="project.use_issues" class="col-md-6 text-center">
+ <h2><t t-esc="len(project.issue_ids)"/></h2>
+ <p><t t-esc="project.label_issues"/></p>
+ </div>
+ </div>
+ </div>
+ <div class="caption">
+ <p>
+ <a t-att-href="'/project/rating/%s' % (slug(project),)" class="btn btn-primary btn-lg btn-block">
+ <i class="fa fa-arrow-circle-right "/> See the feedbacks
+ </a>
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </t>
+ </div>
+ </div>
+ <div class="oe_structure"/>
+ </div>
+ </t>
+ </template>
+
+ <!-- Page : Rating of a particular project -->
+ <template id="project_rating_page" name="Project Issue Rating Page">
+ <t t-call="website.layout">
+ <div id="wrap">
+ <div class="oe_structure"/>
+ <div class="container oe_website_rating_project">
+ <div class="row text-center">
+ <h2><t t-esc="project.name"/> <small>Customer Satisfaction</small></h2>
+ </div>
+ <div class="row mb32">
+ <div class="col-md-8">
+ <h3>The statistics</h3>
+ <div class="row">
+ <div class="col-md-8 col-md-offset-2 well">
+ <t t-foreach="stats" t-as="grade">
+ <div class="progress">
+ <div t-attf-class="progress-bar progress-bar-#{grade}" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" t-att-style="'width: '+ str(stats[grade]) +'%;'">
+ <span class="sr-only"><t t-esc="stats[grade]"/>% Complete</span>
+ </div>
+ <span class="progress-type"><t t-esc="labels[grade]"/></span>
+ <span class="progress-completed"><t t-esc="stats[grade]"/>%</span>
+ </div>
+ </t>
+ </div>
+ </div>
+ <h3>The <t t-esc="len(ratings)"/> last feedbacks</h3>
+ <div class="text-center">
+ <t t-foreach="ratings" t-as="rating" class="media">
+ <img t-attf-src='/rating/static/src/img/rating_#{int(rating.rating)}.png' t-att-alt="rating.res_name" t-att-title="rating.res_name"/>
+ <t t-if="(rating_index+1) % 10 == 0">
+ <br/>
+ </t>
+ </t>
+ </div>
+ </div>
+ <div class="col-md-4">
+ <h3>The Team</h3>
+ <t t-foreach="team" t-as="user" class="media">
+ <div class="media">
+ <div class="pull-left">
+ <img t-att-src="'data:image/png;base64,' + user.image_small" class="img-rounded" t-att-alt="user.name"/>
+ </div>
+ <div class="media-body">
+ <h5><t t-esc="user.name"/></h5>
+ </div>
+ </div>
+ </t>
+ </div>
+ </div>
+ </div>
+ <div class="oe_structure"/>
+ </div>
+ </t>
+ </template>
+
+ </data>
+</odoo>