[IMP] users follow goal plan
bzr revid: mat@openerp.com-20130423130351-pq3tepnmx2u74au5
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.safe_eval import safe_eval
|
||||
from openerp.tools.translate import _
|
||||
|
||||
from templates import TemplateHelper
|
||||
|
||||
@@ -138,17 +139,17 @@ class gamification_goal(osv.Model):
|
||||
"""Return the percentage of completeness of the goal, between 0 and 100"""
|
||||
res = {}
|
||||
for goal in self.browse(cr, uid, ids, context):
|
||||
# if goal.computation_mode == 'higher':
|
||||
if goal.type_condition == 'higher':
|
||||
if goal.current > 0:
|
||||
res[goal.id] = min(100, round(100.0 * goal.current / goal.target_goal, 2))
|
||||
else:
|
||||
res[goal.id] = 0.0
|
||||
# else:
|
||||
# # a goal 'lower than' has only two values possible: 0 or 100%
|
||||
# if goal.current < goal.target_goal:
|
||||
# res[goal.id] = 100.0
|
||||
# else:
|
||||
# res[goal.id] = 0.0
|
||||
else:
|
||||
# a goal 'lower than' has only two values possible: 0 or 100%
|
||||
if goal.current < goal.target_goal:
|
||||
res[goal.id] = 100.0
|
||||
else:
|
||||
res[goal.id] = 0.0
|
||||
return res
|
||||
|
||||
def on_change_type_id(self, cr, uid, ids, type_id=False, context=None):
|
||||
@@ -342,8 +343,8 @@ class gamification_goal(osv.Model):
|
||||
"""Overwrite the write method to update the last_update field to today
|
||||
|
||||
If the current value is changed and the report frequency is set to On
|
||||
change, a report is generated"""
|
||||
|
||||
change, a report is generated
|
||||
"""
|
||||
vals['last_update'] = fields.date.today()
|
||||
result = super(gamification_goal, self).write(cr, uid, ids, vals, context=context)
|
||||
for goal in self.browse(cr, uid, ids, context=context):
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<form string="Goal types" version="7.0">
|
||||
<header>
|
||||
<button string="Start Now" type="object" name="action_start" states="draft" class="oe_highlight"/>
|
||||
<button string="Check Challenge" type="object" name="action_check" states="inprogress"/>
|
||||
<button string="Refresh Challenge" type="object" name="action_check" states="inprogress"/>
|
||||
<button string="Close Challenge" type="object" name="action_close" states="inprogress" class="oe_highlight"/>
|
||||
<button string="Reset to Draft" type="object" name="action_cancel" states="inprogress"/>
|
||||
<button string="Reset Completion" type="object" name="action_reset" states="done"/>
|
||||
@@ -92,8 +92,7 @@
|
||||
<field name="reward_failure" attrs="{'invisible': [('reward_first_id','=', False)]}" />
|
||||
</group>
|
||||
<div class="oe_grey">
|
||||
<p>Badges are granted when a challenge is finished. This is either when at the end of a running period (eg: end of the month for a monthly challenge) or at the end date of a challenge (if no periodicity is set).</p>
|
||||
<p>Ranking is done on the number of succeeded goals and the percentage of each one.</p>
|
||||
<p>Badges are granted when a challenge is finished. This is either at the end of a running period (eg: end of the month for a monthly challenge), at the end date of a challenge (if no periodicity is set) or when the challenge is manually closed.</p>
|
||||
</div>
|
||||
</page>
|
||||
<page string="Advanced Options">
|
||||
|
||||
@@ -12,14 +12,7 @@ openerp.gamification = function(instance) {
|
||||
this.challenge_suggestions = {};
|
||||
},
|
||||
events: {
|
||||
'click a.oe_update_goal': function(event) {
|
||||
var self = this;
|
||||
var goal_id = parseInt(event.currentTarget.id, 10);
|
||||
var goal_updated = new instance.web.Model('gamification.goal').call('update', [[goal_id]]);
|
||||
$.when(goal_updated).done(function() {
|
||||
self.get_goal_todo_info();
|
||||
});
|
||||
},
|
||||
// update a plan and related goals
|
||||
'click a.oe_update_plan': function(event) {
|
||||
var self = this;
|
||||
var plan_id = parseInt(event.currentTarget.id, 10);
|
||||
@@ -28,6 +21,7 @@ openerp.gamification = function(instance) {
|
||||
self.get_goal_todo_info();
|
||||
});
|
||||
},
|
||||
// action to modify a goal
|
||||
'click a.oe_goal_action': function(event) {
|
||||
var self = this;
|
||||
var goal_id = parseInt(event.currentTarget.id, 10);
|
||||
@@ -41,6 +35,7 @@ openerp.gamification = function(instance) {
|
||||
});
|
||||
});
|
||||
},
|
||||
// get more info about a challenge request
|
||||
'click a.oe_challenge_reply': function(event) {
|
||||
var self = this;
|
||||
var plan_id = parseInt(event.currentTarget.id, 10);
|
||||
|
||||
Reference in New Issue
Block a user