summaryrefslogtreecommitdiff
path: root/addons/gamification
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2013-04-18 12:32:29 +0200
committerMartin Trigaux <mat@openerp.com>2013-04-18 12:32:29 +0200
commit06159a516abb7203d997d2dcb77b0fcc849c2b5a (patch)
treefc92b02df31748b842def1e2cd6d0b10529518cf /addons/gamification
parent5c082c36a7ceb81322501551c9726e6cbdad6238 (diff)
[IMP] show suggested threads
bzr revid: mat@openerp.com-20130418103229-xkyu6qyzdola03hn
Diffstat (limited to 'addons/gamification')
-rw-r--r--addons/gamification/plan.py2
-rw-r--r--addons/gamification/res_users.py16
-rw-r--r--addons/gamification/static/src/css/goal.css27
-rw-r--r--addons/gamification/static/src/js/gamification.js30
-rw-r--r--addons/gamification/static/src/xml/gamification.xml14
5 files changed, 60 insertions, 29 deletions
diff --git a/addons/gamification/plan.py b/addons/gamification/plan.py
index 5e36206e4d5..17a0ee79c43 100644
--- a/addons/gamification/plan.py
+++ b/addons/gamification/plan.py
@@ -131,7 +131,7 @@ class gamification_goal_plan(osv.Model):
help='Group of users whose members will automatically be added to the users'),
'proposed_user_ids': fields.many2many('res.users', 'proposed_user_ids',
- string="Propose to users"),
+ string="Suggest to users"),
'planline_ids': fields.one2many('gamification.goal.planline', 'plan_id',
string='Planline',
diff --git a/addons/gamification/res_users.py b/addons/gamification/res_users.py
index a3ee85337b4..2cdf24d4c4b 100644
--- a/addons/gamification/res_users.py
+++ b/addons/gamification/res_users.py
@@ -30,7 +30,7 @@ class res_users_gamification_group(osv.Model):
all_goals_info = []
plan_obj = self.pool.get('gamification.goal.plan')
- plan_ids = plan_obj.search(cr, uid, [('user_ids', 'in', uid)], context=context)
+ plan_ids = plan_obj.search(cr, uid, [('user_ids', 'in', uid), ('state', '=', 'inprogress')], context=context)
for plan in plan_obj.browse(cr, uid, plan_ids, context=context):
# serialize goals info to be able to use it in javascript
serialized_goals_info = {
@@ -103,6 +103,20 @@ class res_users_gamification_group(osv.Model):
all_goals_info.append(serialized_goals_info)
return all_goals_info
+ def get_challenge_suggestions(self, cr, uid, context=None):
+ """Return the list of goal plans suggested to the user"""
+ if context is None: context = {}
+ plan_info = []
+ plan_ids = self.pool.get('gamification.goal.plan').search(cr, uid, [('proposed_user_ids', 'in', uid), ('state', '=', 'inprogress')], context=context)
+ for plan in self.pool.get('gamification.goal.plan').browse(cr, uid, plan_ids, context=context):
+ values = {
+ 'id': plan.id,
+ 'name': plan.name,
+ 'description': plan.description,
+ }
+ plan_info.append(values)
+ return plan_info
+
class res_groups_gamification_group(osv.Model):
""" Update of res.groups class
diff --git a/addons/gamification/static/src/css/goal.css b/addons/gamification/static/src/css/goal.css
index 81a7d0bf9c9..e3dd25b67e4 100644
--- a/addons/gamification/static/src/css/goal.css
+++ b/addons/gamification/static/src/css/goal.css
@@ -58,30 +58,23 @@
}
/* Mail Sidebar */
-
.openerp .oe_mail_wall .oe_mail_wall_aside {
- margin-left: 20px;
- margin-top: 20px;
+ margin-top: 15px;
position: relative;
display: inline-block;
vertical-align: top;
- width: 300px;
+ width: 260px;
+}
+.openerp .oe_mail_wall .oe_mail_wall_aside {
+ position: relative;
+ vertical-align: top;
+ background: #EDEDF6;
+ border-radius: 2px;
}
-.openerp .oe_mail_wall_aside .oe_gamification_goal {
+.openerp .oe_mail_wall_aside > div {
background: #EDEDF6;
- height: auto;
- padding: 15px;
- border: solid 1px rgba(0,0,0,0.03);
+ padding: 5px 0 0 15px;
}
-
-/*.openerp .oe_gamification_goal .oe_goal_reached:before {
- content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMSCREbCamR5gAAAXhJREFUOMuV0z9rlEEQBvDf7htFFIwQBCvRQuFAJSJooY29VrH0E1hcCqNign8SYzAxRfTA0nyAg3wBK1GCKSwTK8G7j6AgiHl3LbLmwOQu8Wl2mZ15Zp6ZnWC/GMcrjBvBdTRkX4P/QdNZrGKkWN7sn+CuE5IvsqOyKFnRMhb3DJwsZ2VV5ZgoCt5qGdsyD8ITzGJSW3BVkAUdlZsu++0T/SU8xxQeuyj7LKEWJKcs6Px16y9harv0NVEQBZWmBR33e26Dm/hMW3BLLUvW/XJBlM31XIZMlNsi7pWa5jGjIbiBXBLd8UL+N0e0WIInvMNp8+Wltqx2SBJk06Z98HRnkUHTOZWPomEVojOiUZV26foP2XkHdD3aSRBxXDIsSRKyddmyGklQa5vRtbl7myprvrnisOBa0TuEgyBhziXwfneCrTG+9kDSkgQJSbaJ2ix42H9QYXvTakdEG4KThfanoKHS9XIvgt7KjspW8F2wIbhtSRr0Vf4AD6Nod0TaN4kAAAAASUVORK5CYII=);
- margin-left:-20px;
-}
-.openerp .oe_gamification_goal .oe_goal_failed:before {
- content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMVECkXmaDBcAAAAUxJREFUKM+N0jFrVEEUhuFnV1KICS7ExcLCSgiCYJXCxt5C8B+ohYVgYeUfMJBCUIydkCpRLG3EThSxU0ypxMZKYQkSzd7cO3dmLJxNNhckGTgMfHPe+c6ZOZ7Sb7gauOIIq+V2wwVjFjNtYhS4dgh0L1EnvhtzKbGdyQW+8R/ofmJc8r64Ra/hYuJHEbda7nSgB1PQRsVpc2j+xfnEZjncjtz9zLHIw0SdyZH3uwx/wmDq5oaFyKeJc2QzsVOgVzXDveRBp5fAucjbTJ5E5EWYhtDvPkJiC1878rdEdUAZHHQ7FVkrpdaJ35lQXJ8EZveST5a9Zr7lZYFS5HHF2cjztF/ys11OgDP0auYjbwrURFZGzMAvjkfW077z6z/MGjGMfCxQFXnU7fsdvcjq5FsSH1RcnkAty4eM3EqiyTTW6AeuB5aOOOTLgZt/AfLdvLh74DfrAAAAAElFTkSuQmCC);
- margin-left:-20px;
-}*/
.openerp .oe_mail_wall_aside .oe_gamification_goal .oe_goal_reached,
.openerp .oe_mail_wall_aside .oe_gamification_goal .oe_goal_failed {
text-decoration: line-through;
diff --git a/addons/gamification/static/src/js/gamification.js b/addons/gamification/static/src/js/gamification.js
index e68874c866b..464fd1ace5a 100644
--- a/addons/gamification/static/src/js/gamification.js
+++ b/addons/gamification/static/src/js/gamification.js
@@ -9,6 +9,7 @@ openerp.gamification = function(instance) {
this.deferred = $.Deferred();
this.res_user = new instance.web.DataSetSearch(this, 'res.users');
this.goals_info = {};
+ this.challenge_suggestions = {};
},
events: {
'click a.oe_update_goal': function(event) {
@@ -45,6 +46,7 @@ openerp.gamification = function(instance) {
var self = this;
this._super.apply(this, arguments);
self.get_goal_todo_info();
+ self.get_challenge_suggestions();
},
render_template: function(target,template) {
var self = this;
@@ -65,6 +67,22 @@ openerp.gamification = function(instance) {
self.render_money_fields(self.goals_info.info[0].currency);
self.render_progress_bars();
self.render_piechars();
+ } else {
+ self.$el.filter(".oe_gamification_goal").hide();
+ }
+ });
+ },
+ get_challenge_suggestions: function() {
+ var self = this;
+ var challenge_suggestions = this.res_user.call('get_challenge_suggestions', {}).then(function(res) {
+ self.challenge_suggestions['info'] = res;
+ console.log(res);
+ });
+ $.when(challenge_suggestions).done(function() {
+ if(self.challenge_suggestions.info.length > 0){
+ self.render_template_replace(self.$el.filter(".oe_gamification_suggestion"),'gamification.challenge_suggestions');
+ } else {
+ self.$el.filter(".oe_gamification_suggestion").hide();
}
});
},
@@ -128,6 +146,7 @@ openerp.gamification = function(instance) {
var rendering = this._super();
var self = this;
+ // add gauge in goal kanban views
$.when(rendering).done(function() {
if (self.view.dataset.model === 'gamification.goal' && self.$el.find('.oe_goal_gauge').length == 1) {
var unique_id = _.uniqueId("goal_gauge_");
@@ -140,16 +159,6 @@ openerp.gamification = function(instance) {
max: self.record.target_goal.raw_value,
relativeGaugeSize: true,
humanFriendly: true,
- // add space between value and symbol
- // textRenderer: function(value) {
- // symbol = self.record.type_suffix.raw_value;
- // humannbr = humanFriendlyNumber(value, 0)
- // if ((humannbr + symbol).length > 6) {
- // return humannbr;
- // } else {
- // return humannbr + " " + symbol;
- // }
- // },
label: self.record.type_suffix.raw_value,
levelColors: [
"#ff0000",
@@ -160,6 +169,7 @@ openerp.gamification = function(instance) {
}
});
},
+ // open related goals when clicking on challenge kanban view
on_card_clicked: function() {
if (this.view.dataset.model === 'gamification.goal.plan') {
this.$('.oe_kanban_project_list a').first().click();
diff --git a/addons/gamification/static/src/xml/gamification.xml b/addons/gamification/static/src/xml/gamification.xml
index adcd6fa37b0..22c1233d336 100644
--- a/addons/gamification/static/src/xml/gamification.xml
+++ b/addons/gamification/static/src/xml/gamification.xml
@@ -1,5 +1,6 @@
<templates>
<t t-name="gamification.user_wall_sidebar" class="oe_gamification_user_wall_sidebar">
+ <div class="oe_gamification_suggestion"><em>No challenge suggestions</em></div>
<div class="oe_gamification_goal"><em>Your goal list is empty</em></div>
</t>
<t t-name="gamification.goal_list_to_do">
@@ -63,4 +64,17 @@
</div>
</t>
+ <t t-name="gamification.challenge_suggestions">
+ <h3>Suggested challenges</h3>
+ <div t-foreach="widget.challenge_suggestions.info" t-as="challenge" class="oe_challenge">
+ <p>
+ <strong><t t-esc="challenge.name"/></strong> <a class="oe_challenge_reply">reply</a>
+ <t t-if="challenge.description.value">
+ <br/>
+ <em><t t-esc="challenge.description.value"/></em>
+ </t>
+ </p>
+ </div>
+ </t>
+
</templates>