summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2013-06-12 14:07:58 +0200
committerMartin Trigaux <mat@openerp.com>2013-06-12 14:07:58 +0200
commita2b06d2f13c11f0816ca8bb19ffb3fe3e2973249 (patch)
tree2788733b980e4bf2db267d4d4ba38314e6525996
parentbb17b02de508526a90172def7f299636a655eb24 (diff)
[REF] gamification: comments and move changed_users_avatar method
bzr revid: mat@openerp.com-20130612120758-garx32vy8qjcfseb
-rw-r--r--addons/gamification/goal.py16
-rw-r--r--addons/gamification/res_users.py15
2 files changed, 12 insertions, 19 deletions
diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py
index 32a6bd55512..32bcc3e513b 100644
--- a/addons/gamification/goal.py
+++ b/addons/gamification/goal.py
@@ -380,22 +380,6 @@ class gamification_goal(osv.Model):
return action
return False
- #TODO: i find a bit annoying to have this method on the goal class instead of being on only the goal type related.
- # i wouldn't put this in a dedicated method... well i think something is wrong conceptually with this thing
- def changed_users_avatar(self, cr, uid, ids, context):
- """Warning a user changed his avatar.
-
- The goal_type type_base_avatar requires a change of avatar. As an
- avatar is randomly generated by default, trigger warning when change.
- Set the state of every type_base_avatar linked to ids to 'reached' and
- set current value to 1.
- """
-
- goal_type_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'type_base_avatar', context)
- goal_ids = self.search(cr, uid, [('type_id', '=', goal_type_id.id), ('user_id', 'in', ids)], context=context)
- values = {'state': 'reached', 'current': 1}
- self.write(cr, uid, goal_ids, values, context=context)
-
class goal_manual_wizard(osv.TransientModel):
"""Wizard type to update a manual goal"""
diff --git a/addons/gamification/res_users.py b/addons/gamification/res_users.py
index 4962cb1b975..3ccdf592881 100644
--- a/addons/gamification/res_users.py
+++ b/addons/gamification/res_users.py
@@ -43,12 +43,21 @@ class res_users_gamification_group(osv.Model):
goal_plan_obj.write(cr, uid, plan_ids, {'user_ids': [(4, user_id) for user_id in ids]}, context=context)
if vals.get('image'):
- self.pool.get('gamification.goal').changed_users_avatar(cr, uid, ids, context)
+ goal_type_id = self.pool.get('ir.model.data').get_object(cr, uid, 'gamification', 'type_base_avatar', context)
+ goal_ids = self.pool.get('gamification.goal').search(cr, uid, [('type_id', '=', goal_type_id.id), ('user_id', 'in', ids)], context=context)
+ values = {'state': 'reached', 'current': 1}
+ self.pool.get('gamification.goal').write(cr, uid, goal_ids, values, context=context)
return write_res
-#TODO: this method is not clear about what she returns (list of dict but the dict's keys may be different from one to another)... it's doubtfull conceptually. Don't we need some more doc? why is this method looking so overkill?
def get_goals_todo_info(self, cr, uid, context=None):
- """Return the list of goals assigned to the user, grouped by plan"""
+ """Return the list of goals assigned to the user, grouped by plan
+
+ This method intends to return processable data in javascript in the
+ goal_list_to_do template. The output format is not constant as the
+ required information is different between individual and board goal
+ types
+ :return: list of dictionnaries for each goal to display
+ """
all_goals_info = []
plan_obj = self.pool.get('gamification.goal.plan')