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] [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 @@