[IMP] project rating improved public view
This commit is contained in:
@@ -258,7 +258,7 @@
|
||||
<field name="doc_count"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_project oe_kanban_global_click oe_kanban_project_task_spark">
|
||||
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_project oe_kanban_global_click">
|
||||
<div class="oe_dropdown_toggle oe_dropdown_kanban" groups="base.group_user">
|
||||
<i class="fa fa-bars fa-lg"/>
|
||||
<ul class="oe_dropdown_menu">
|
||||
@@ -285,29 +285,22 @@
|
||||
<field name="label_tasks"/>
|
||||
</a>
|
||||
</div>
|
||||
<div t-if="record.use_tasks.raw_value and record.task_count.raw_value lt 1" class="col-md-12">
|
||||
<img src="/project/static/src/img/top_left_arrow.png" style="margin-top: -8px; width: 22px;" />
|
||||
<span>No activity yet, click to enter in the project.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row oe_margin_top_8 oe_kanban_project_infos">
|
||||
<div class="col-md-6">
|
||||
<a t-if="record.doc_count.raw_value" name="attachment_tree_view" type="object">
|
||||
<field name="doc_count"/> Documents
|
||||
</a>
|
||||
</div>
|
||||
<div t-if="record.use_tasks.raw_value and record.task_count.raw_value lt 1" class="col-md-12">
|
||||
<img src="/project/static/src/img/top_left_arrow.png" style="margin-top: -8px; width: 22px;" />
|
||||
<span>No activity yet, click to enter in the project.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row oe_margin_top_8 oe_kanban_project_tags">
|
||||
<h5 t-if="record.date.raw_value" class="label label-default">
|
||||
<i class="fa fa-calendar"/>
|
||||
<field name="date"/>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="row oe_margin_top_8 oe_kanban_project_avatars">
|
||||
<t t-foreach="record.members.raw_value.slice(0,11)" t-as="member">
|
||||
<div class="oe_margin_top_8 oe_kanban_project_avatars">
|
||||
<t t-foreach="record.members.raw_value.slice(0,12)" t-as="member">
|
||||
<img t-att-src="kanban_image('res.users', 'image_small', member)" t-att-data-member_id="member"/>
|
||||
</t>
|
||||
</div>
|
||||
<div class="clearfix"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
.oe_kanban_project_avatars img {
|
||||
width: 30px;
|
||||
border-radius: 2px;
|
||||
@@ -14,11 +15,9 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.openerp .oe_kanban_view .oe_kanban_project_task_spark {
|
||||
/* Customize width and height of kanban according bootstrap3 */
|
||||
.openerp .oe_kanban_view .oe_kanban_project {
|
||||
width: 290px;
|
||||
min-height: 120px;
|
||||
/* End of customize */
|
||||
min-height: 150px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@@ -26,10 +25,6 @@
|
||||
content: "%";
|
||||
}
|
||||
|
||||
.openerp .oe_project_kanban_content {
|
||||
margin-right: 16px !important;
|
||||
margin-left: 16px !important;
|
||||
}
|
||||
.openerp .oe_margin_top_8 {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@@ -43,12 +43,14 @@
|
||||
<field name="percentage_satisfaction_project" invisible="1"/>
|
||||
<field name="is_visible_happy_customer" invisible="1"/>
|
||||
</field>
|
||||
<xpath expr="//div[contains(@class, 'oe_kanban_project_tags')]" position="inside">
|
||||
<xpath expr="//div[contains(@class, 'oe_kanban_project_list')]" position="after">
|
||||
<div class="pull-right oe_margin_top_16">
|
||||
<a t-if="record.is_visible_happy_customer.raw_value and record.percentage_satisfaction_project.raw_value > -1" name="action_view_all_rating" type="object" title="Percentage of happy people about this project">
|
||||
<h5 t-attf-class="label #{record.percentage_satisfaction_project.raw_value >= 50 ? 'label-success' : 'label-warning'}">
|
||||
<i t-attf-class="fa #{record.percentage_satisfaction_project.raw_value >= 50 ? 'fa-smile-o' : 'fa-frown-o'}"/> <t t-raw="record.percentage_satisfaction_project.raw_value"/> %
|
||||
</h5>
|
||||
</a>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -3,6 +3,7 @@ from openerp import _
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
|
||||
import datetime
|
||||
|
||||
class WebsiteRatingProject(http.Controller):
|
||||
|
||||
@@ -15,38 +16,23 @@ class WebsiteRatingProject(http.Controller):
|
||||
@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
|
||||
domain = [('res_model', '=', 'project.task')]
|
||||
ratings = request.env['rating.rating'].search(domain, order="id desc", limit=100)
|
||||
|
||||
yesterday = (datetime.date.today()-datetime.timedelta(days=-1)).strftime('%Y-%m-%d 23:59:59')
|
||||
stats = {}
|
||||
for x in (7, 30, 90):
|
||||
todate = (datetime.date.today()-datetime.timedelta(days=-x)).strftime('%Y-%m-%d 00:00:00')
|
||||
domdate = domain + [('create_date','<=',yesterday),('create_date','>=',todate)]
|
||||
stats[x] = {0: 0, 5: 0, 10: 0}
|
||||
rating_stats = request.env['rating.rating'].read_group(domdate, [], ['rating'])
|
||||
total = reduce(lambda x, y: y['rating_count']+x, rating_stats, 0)
|
||||
for rate in rating_stats:
|
||||
stats[x][rate['rating']] = (rate['rating_count'] * 100) / total
|
||||
values = {
|
||||
'team': project.sudo().members,
|
||||
'project': project,
|
||||
'ratings' : ratings,
|
||||
'stats': res,
|
||||
'labels': grades_label,
|
||||
'stats': stats,
|
||||
}
|
||||
return request.website.render('website_rating_project_issue.project_rating_page', values)
|
||||
|
||||
+6
-19
@@ -1,24 +1,11 @@
|
||||
.oe_website_rating_project .oe_rate{
|
||||
clear: both;
|
||||
}
|
||||
.oe_website_rating_project .oe_rate img {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
@@ -70,52 +70,73 @@
|
||||
</template>
|
||||
|
||||
<!-- Page : Rating of a particular project -->
|
||||
<template id="project_rating_data" name="Project Issue Rating Page">
|
||||
<div class="oe_rate">
|
||||
<img src='/rating/static/src/img/rating_10.png' alt="Happy Feedback" class="pull-left" style="width:24px"/>
|
||||
<div class="progress mt4">
|
||||
<div t-attf-class="progress-bar" role="progressbar" t-attf-style="width: #{stats[duration][10]}%;">
|
||||
<t t-esc="stats[duration][10]"/>%%
|
||||
</div>
|
||||
</div>
|
||||
</div><div class="oe_rate mt16">
|
||||
<img src='/rating/static/src/img/rating_5.png' alt="Happy Feedback" class="pull-left" style="width:24px"/>
|
||||
<div class="progress mt4">
|
||||
<div t-attf-class="progress-bar" role="progressbar" t-attf-style="width: #{stats[duration][5]}%;">
|
||||
<t t-esc="stats[duration][5]"/>%%
|
||||
</div>
|
||||
</div>
|
||||
</div><div class="oe_rate mt16">
|
||||
<img src='/rating/static/src/img/rating_0.png' alt="Happy Feedback" class="pull-left" style="width:24px"/>
|
||||
<div class="progress mt4">
|
||||
<div t-attf-class="progress-bar" role="progressbar" t-attf-style="width: #{stats[duration][0]}%;">
|
||||
<t t-esc="stats[duration][0]"/>%%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<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>
|
||||
<h1 t-esc="project.name" class="text-center"/>
|
||||
<div class="row mb32">
|
||||
<div class="col-md-8">
|
||||
<h3>The statistics</h3>
|
||||
<h3 class="page-header">Customer Satisfaction</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 class="col-sm-4">
|
||||
<h4>Last 7 days</h4>
|
||||
<t t-set="duration" t-value="7"/>
|
||||
<t t-call="website_rating_project_issue.project_rating_data"/>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<h4>Last 30 days</h4>
|
||||
<t t-set="duration" t-value="30"/>
|
||||
<t t-call="website_rating_project_issue.project_rating_data"/>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<h4>Last 3 months</h4>
|
||||
<t t-set="duration" t-value="90"/>
|
||||
<t t-call="website_rating_project_issue.project_rating_data"/>
|
||||
</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>
|
||||
<h3 class="page-header">Latest Feedbacks</h3>
|
||||
<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>
|
||||
</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>
|
||||
<h3>Team</h3>
|
||||
<div class="media" t-foreach="team" t-as="user">
|
||||
<div class="pull-left">
|
||||
<img t-att-src="'data:image/png;base64,' + user.image_small" class="img-rounded" t-att-alt="user.name" style="width: 32px"/>
|
||||
</div>
|
||||
</t>
|
||||
<div class="media-body">
|
||||
<h5><t t-esc="user.name"/></h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user