summaryrefslogtreecommitdiff
path: root/addons/website_profile/controllers/main.py
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-03-29 12:06:25 +0000
committerThibault Delavallée <tde@odoo.com>2019-11-22 15:30:53 +0000
commit5ac64d6e02bc8bc0fbdddd73cfc561023b58e566 (patch)
tree925344b1b7d33475f1dc524591faf6819c501864 /addons/website_profile/controllers/main.py
parent1f52435966edeb1d57ef8bccce7f82eb0b08a2ae (diff)
[IMP] website_slides_survey: add certification badges section to ranks badge page
This commit adds a section to distinguish the certification badges from the other badges users may obtain in eLearning. Certification badges are available on the ranks page, linked to a running survey. Clicking on them directly redirects into the linked course. Task ID : 1961053 PR #32594
Diffstat (limited to 'addons/website_profile/controllers/main.py')
-rw-r--r--addons/website_profile/controllers/main.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py
index cfe1f5a96a4..3d14024d1a0 100644
--- a/addons/website_profile/controllers/main.py
+++ b/addons/website_profile/controllers/main.py
@@ -171,8 +171,7 @@ class WebsiteProfile(http.Controller):
domain = expression.AND([[('challenge_ids.challenge_category', '=', kwargs.get('badge_category'))], domain])
return domain
- @http.route('/profile/ranks_badges', type='http', auth="public", website=True, sitemap=True)
- def view_ranks_badges(self, **kwargs):
+ def _prepare_ranks_badges_values(self, **kwargs):
ranks = []
if 'badge_category' not in kwargs:
Rank = request.env['gamification.karma.rank']
@@ -180,7 +179,7 @@ class WebsiteProfile(http.Controller):
Badge = request.env['gamification.badge']
badges = Badge.sudo().search(self._prepare_badges_domain(**kwargs))
- badges = sorted(badges, key=lambda b: b.granted_users_count, reverse=True)
+ badges = badges.sorted("granted_users_count", reverse=True)
values = self._prepare_user_values(searches={'badges': True})
values.update({
@@ -188,6 +187,11 @@ class WebsiteProfile(http.Controller):
'badges': badges,
'user': request.env.user,
})
+ return values
+
+ @http.route('/profile/ranks_badges', type='http', auth="public", website=True, sitemap=True)
+ def view_ranks_badges(self, **kwargs):
+ values = self._prepare_ranks_badges_values(**kwargs)
return request.render("website_profile.rank_badge_main", values)
# All Users Page