[REF] gamification: comments and move changed_users_avatar method

bzr revid: mat@openerp.com-20130612120758-garx32vy8qjcfseb
This commit is contained in:
Martin Trigaux 2013-06-12 14:07:58 +02:00
parent bb17b02de5
commit a2b06d2f13
2 changed files with 12 additions and 19 deletions

View File

@ -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"""

View File

@ -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')