From f66453a0f537fe481afcaac10927e16d91b37228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2019 13:46:40 +0000 Subject: [PATCH 1/3] [FIX] website_profile: correctly display rank position image in top 3 users As user is a loop variable we can directly use its index instead of a rank position that is not always correctly computed when not being logged due to access rights issues. Linked to task 2005840 Related to PR #34220 --- addons/website_profile/views/website_profile.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml index 0cd047fa31b..9aac0a4376d 100644 --- a/addons/website_profile/views/website_profile.xml +++ b/addons/website_profile/views/website_profile.xml @@ -510,7 +510,7 @@
- User rank + User rank

Unpublished From d5f8e39923de39c3a5b7daa39ea29f71178fe56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2019 13:47:48 +0000 Subject: [PATCH 2/3] [FIX] website_profile: fix leaderboard / top3 computation Contains some small fixes * correctly order leaderboard by descending karma, not creation date; * top 3 users displayed in footer banner should be published, otherwise displayed images do not match the top 3 displayed in the page displayed when clicking; * correctly say Leaderboard is an overall leaderboard, not only limited to the current week; Linked to task 2005840 Related to PR #34220 --- addons/website_slides/controllers/main.py | 3 ++- .../website_slides/views/website_slides_templates_homepage.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index 5b690682d35..f0e4658ce6d 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -257,7 +257,7 @@ class WebsiteSlides(WebsiteProfile): if request.env.user._is_public(): users = request.env['res.users'].sudo().search([ ('karma', '>', 0), - ('website_published', '=', True)], limit=5, order='create_date desc') + ('website_published', '=', True)], limit=5, order='karma desc') else: users = None @@ -323,6 +323,7 @@ class WebsiteSlides(WebsiteProfile): def _get_top3_users(self): return request.env['res.users'].sudo().search_read([ ('karma', '>', 0), + ('website_published', '=', True), ('image', '!=', False)], ['id'], limit=3, order='karma desc') @http.route([ diff --git a/addons/website_slides/views/website_slides_templates_homepage.xml b/addons/website_slides/views/website_slides_templates_homepage.xml index d163f3fbeb6..828b6d2dfa8 100644 --- a/addons/website_slides/views/website_slides_templates_homepage.xml +++ b/addons/website_slides/views/website_slides_templates_homepage.xml @@ -355,7 +355,7 @@
View all -
Leaderboard of the week
+
Leaderboard

From cd039b64d46b01a293ad496bd07ba28fd8e53d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Jun 2019 14:08:02 +0000 Subject: [PATCH 3/3] [FIX] gamification, website_{profile, slides}: correctly display next rank This fix correctly displayed motivational of next rank to achieve depending on current karma. Indeed description_motivational field is not the motivational to reach next rank but to reach the current rank, taken from previous rank point of view. That way a given rank is configured by modifying only 1 data. When not having any karma points (newly created user) the next rank is computed as being the first available rank. Motivational phrases and badges are updated accordingly. This commit partially reverts 489c8623e2c4869ce1ed8be3d186e36cc1c47456. Result * new user with no karma: next rank is the first rank; * user with karma and next rank: as currently; * user being at final rank: next rank is just current rank with a 100% circle; Linked to task 2005840 Related to PR #34220 --- .../data/gamification_karma_rank_data.xml | 19 ++++++------ .../data/gamification_karma_rank_demo.xml | 4 +-- addons/gamification/models/res_users.py | 8 +++++ .../website_profile/views/website_profile.xml | 31 ++++++++++--------- .../website_slides_templates_homepage.xml | 14 ++++----- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/addons/gamification/data/gamification_karma_rank_data.xml b/addons/gamification/data/gamification_karma_rank_data.xml index f86b827cceb..5eba07b1a3d 100644 --- a/addons/gamification/data/gamification_karma_rank_data.xml +++ b/addons/gamification/data/gamification_karma_rank_data.xml @@ -14,8 +14,8 @@

You just began the adventure! Welcome!

-
Reach the next rank to show the rest of the world you exist!
- +
Earn your first points and join the adventure !
+
1 @@ -27,8 +27,8 @@

You're a young padawan now. May the force be with you!

-
Reach the next rank to improve your status.
- +
Reach the next rank to show the rest of the world you exist.
+
100 @@ -40,8 +40,8 @@

You love learning things. Curiosity is a good way to progress.

-
Reach the next rank and become a Master!
- +
Reach the next rank to improve your status!
+
500 @@ -53,8 +53,8 @@

You know what you are talking about. People learn from you.

-
Reach the next rank and become a powerful user!
- +
Reach the next rank and become a Master!
+
2000 @@ -66,7 +66,8 @@

You have reached the last rank. Congratulations!

-
You have reached the last rank. Congratulations!
+
Reach the next rank and become a powerful user!
+
10000 diff --git a/addons/gamification/data/gamification_karma_rank_demo.xml b/addons/gamification/data/gamification_karma_rank_demo.xml index 6250ee227f6..839e8750047 100644 --- a/addons/gamification/data/gamification_karma_rank_demo.xml +++ b/addons/gamification/data/gamification_karma_rank_demo.xml @@ -1,5 +1,5 @@ - + 20 @@ -39,7 +39,7 @@
-
You have reached the last rank. Congratulations!
+
Reach the next rank and gain a very nice unicorn !
diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py index daa9d4bc1e1..a0ca65ced45 100644 --- a/addons/gamification/models/res_users.py +++ b/addons/gamification/models/res_users.py @@ -96,6 +96,14 @@ class Users(models.Model): if old_rank != user.rank_id: user._rank_changed() + def _get_next_rank(self): + """ For fresh users with 0 karma that don't have a rank_id and next_rank_id yet + this method returns the first karma rank (by karma ascending). This acts as a + default value in related views. + + TDE FIXME in post-12.4: make next_rank_id a non-stored computed field correctly computed """ + return self.next_rank_id or (not self.rank_id and self.env['gamification.karma.rank'].search([], order="karma_min ASC", limit=1)) + def get_gamification_redirection_data(self): """ Hook for other modules to add redirect button(s) in new rank reached mail diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml index 9aac0a4376d..c28712f06ac 100644 --- a/addons/website_profile/views/website_profile.xml +++ b/addons/website_profile/views/website_profile.xml @@ -258,12 +258,11 @@
-
- Next rank: - - 40% - -
+ + Next rank: + + 40% + @@ -315,17 +314,21 @@