[FIX] website_rating_project_issue : fix the domain to retrieve rating of particular project and use website.image_url to display user avatar.

This commit is contained in:
Jérome Maes
2015-03-10 13:05:44 +01:00
parent 87ac4da807
commit f798d84322
2 changed files with 11 additions and 10 deletions
@@ -9,21 +9,22 @@ class WebsiteRatingProject(http.Controller):
@http.route(['/project/rating/'], type='http', auth="public", website=True)
def index(self, **kw):
projects = request.env['project.project'].search([])
projects = request.env['project.project'].search([('is_visible_happy_customer', '=', 1)])
values = {'projects' : projects}
return request.website.render('website_rating_project_issue.index', values)
@http.route(['''/project/rating/<model("project.project", "[('is_visible_happy_customer','=',1)]"):project>'''], type='http', auth="public", website=True)
def page(self, project=None, **kw):
# create domain for rating
domain = [('res_model', '=', 'project.issue')]
issues = request.env['project.issue'].search([('project_id', '=', project.id)])
domain = [('res_model', '=', 'project.issue'), ('res_id', 'in', issues.ids)]
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)]
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)
@@ -74,21 +74,21 @@
<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]}%;">
<div t-attf-class="progress-bar progress-bar-success" 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"/>
<img src='/rating/static/src/img/rating_5.png' alt="Normal 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]}%;">
<div t-attf-class="progress-bar progress-bar-warning" 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"/>
<img src='/rating/static/src/img/rating_0.png' alt="Bad 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]}%;">
<div t-attf-class="progress-bar progress-bar-danger" role="progressbar" t-attf-style="width: #{stats[duration][0]}%;">
<t t-esc="stats[duration][0]"/>%%
</div>
</div>
@@ -131,7 +131,7 @@
<h3 class="page-header">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"/>
<img t-att-src="website.image_url(user, 'image_small')" class="img-rounded" t-att-alt="user.name" style="width: 32px"/>
</div>
<div class="media-body">
<h5><t t-esc="user.name"/></h5>