Allow overwrite of the serialising method to exclude some categories in the challenge search
bzr revid: mat@openerp.com-20140415134809-uconkvnp0z32jxjs
This commit is contained in:
parent
bc0738e47e
commit
35c7f4814d
|
@ -61,13 +61,12 @@ class res_users_gamification_group(osv.Model):
|
|||
challenge_obj.generate_goals_from_challenge(cr, SUPERUSER_ID, challenge_ids, context=context)
|
||||
return write_res
|
||||
|
||||
# def get_goals_todo_info(self, cr, uid, context=None):
|
||||
def get_serialised_gamification_summary(self, cr, uid, excluded_categories=None, context=None):
|
||||
return self._serialised_goals_summary(cr, uid, user_id=uid, excluded_categories=excluded_categories, context=context)
|
||||
|
||||
def get_serialised_gamification_summary(self, cr, uid, context=None):
|
||||
return self._serialised_goals_summary(cr, uid, user_id=uid, context=context)
|
||||
|
||||
def _serialised_goals_summary(self, cr, uid, user_id, context=None):
|
||||
def _serialised_goals_summary(self, cr, uid, user_id, excluded_categories=None, context=None):
|
||||
"""Return a serialised list of goals assigned to the user, grouped by challenge
|
||||
:excluded_categories: list of challenge categories to exclude in search
|
||||
|
||||
[
|
||||
{
|
||||
|
@ -81,9 +80,11 @@ class res_users_gamification_group(osv.Model):
|
|||
"""
|
||||
all_goals_info = []
|
||||
challenge_obj = self.pool.get('gamification.challenge')
|
||||
|
||||
domain = [('user_ids', 'in', uid), ('state', '=', 'inprogress')]
|
||||
if excluded_categories and isinstance(excluded_categories, list):
|
||||
domain.append(('category', 'not in', excluded_categories))
|
||||
user = self.browse(cr, uid, uid, context=context)
|
||||
challenge_ids = challenge_obj.search(cr, uid, [('user_ids', 'in', uid), ('state', '=', 'inprogress')], context=context)
|
||||
challenge_ids = challenge_obj.search(cr, uid, domain, context=context)
|
||||
for challenge in challenge_obj.browse(cr, uid, challenge_ids, context=context):
|
||||
# serialize goals info to be able to use it in javascript
|
||||
lines = challenge_obj._get_serialized_challenge_lines(cr, uid, challenge, user_id, restrict_top=MAX_VISIBILITY_RANKING, context=context)
|
||||
|
|
|
@ -12,6 +12,7 @@ class gamification_challenge(osv.Model):
|
|||
return res
|
||||
|
||||
|
||||
|
||||
class Badge(osv.Model):
|
||||
_inherit = 'gamification.badge'
|
||||
_columns = {
|
||||
|
|
|
@ -37,3 +37,11 @@ class Users(osv.Model):
|
|||
for user in self.browse(cr, uid, ids, context=context):
|
||||
self.write(cr, uid, [user.id], {'karma': user.karma + karma}, context=context)
|
||||
return True
|
||||
|
||||
def get_serialised_gamification_summary(self, cr, uid, excluded_categories=None, context=None):
|
||||
if isinstance(excluded_categories, list):
|
||||
if 'forum' not in excluded_categories:
|
||||
excluded_categories.append('forum')
|
||||
else:
|
||||
excluded_categories = ['forum']
|
||||
return super(Users, self).get_serialised_gamification_summary(cr, uid, excluded_categories=excluded_categories, context=context)
|
Loading…
Reference in New Issue