[IMP] gamification: usability and shit
authorMartin Trigaux <mat@openerp.com>
Fri, 12 Sep 2014 08:37:14 +0000 (10:37 +0200)
committerThibault Delavallée <tde@openerp.com>
Thu, 18 Sep 2014 09:12:15 +0000 (11:12 +0200)
Challenge
- 'Reward as soon as every goal is reached' box checked by default (most of the time people want this behaviour, few special cases were do not)
- Click on challenge kanban opens goal list instead of challenge form
- Add button 'Start Challenge' clicking on statusbar is not intuitive

Badge
- When creates a challenge from badge view, set by default badge to 'For Every Succeding User' field
- replace filter 'Current' vs 'Passed' by 'Running' (in progress and done with not reached end date) vs 'Done' (done & failed without end date or end date passed)

Goal
- list of badge on employee form not the first tab

addons/gamification/models/challenge.py
addons/gamification/static/src/js/gamification.js
addons/gamification/views/badge.xml
addons/gamification/views/challenge.xml
addons/gamification/views/goal.xml
addons/hr_gamification/views/gamification.xml

index 2a1c6d5..4e128fc 100644 (file)
@@ -204,6 +204,7 @@ class gamification_challenge(osv.Model):
         'category': 'hr',
         'reward_failure': False,
         'report_template_id': lambda s, *a, **k: s._get_report_template(*a, **k),
+        'reward_realtime': True,
     }
 
 
@@ -361,6 +362,9 @@ class gamification_challenge(osv.Model):
 
         return True
 
+    def action_start(self, cr, uid, ids, context=None):
+        """Start a challenge"""
+        return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context)
 
     def action_check(self, cr, uid, ids, context=None):
         """Check a challenge
@@ -707,7 +711,7 @@ class gamification_challenge(osv.Model):
 
             rewarded_users = []
             challenge_ended = end_date == yesterday.strftime(DF) or force
-            if challenge.reward_id and challenge_ended or challenge.reward_realtime:
+            if challenge.reward_id and (challenge_ended or challenge.reward_realtime):
                 # not using start_date as intemportal goals have a start date but no end_date
                 reached_goals = self.pool.get('gamification.goal').read_group(cr, uid, [
                     ('challenge_id', '=', challenge.id),
index 6e2e520..0c02162 100644 (file)
@@ -125,16 +125,5 @@ openerp.gamification = function(instance) {
             sidebar.appendTo($('.oe_mail_wall_aside'));
         },
     });
-
-    instance.web_kanban.KanbanRecord.include({
-        // open related goals when clicking on challenge kanban view
-        on_card_clicked: function() {
-            if (this.view.dataset.model === 'gamification.challenge') {
-                this.$('.oe_kanban_project_list a').first().click();
-            } else {
-                this._super.apply(this, arguments);
-            }
-        },
-    });
     
 };
index 302ad66..315ccd6 100644 (file)
@@ -75,7 +75,7 @@
                             </div>
                         </group>
                         <group string="Rewards for challenges">
-                            <field name="challenge_ids" widget="many2many_kanban" nolabel="1" />
+                            <field name="challenge_ids" widget="many2many_kanban" nolabel="1" context="{'default_reward_id': active_id}" />
                         </group>
                         <group string="Statistics">
                             <group>
index 9c76b73..75515c4 100644 (file)
@@ -34,6 +34,7 @@
             <field name="arch" type="xml">
                 <form string="Goal definitions">
                     <header>
+                        <button string="Start Challenge" type="object" name="action_start" states="draft" class="oe_highlight"/>
                         <button string="Refresh Challenge" type="object" name="action_check" states="inprogress"/>
                         <button string="Send Report" type="object" name="action_report_progress" states="inprogress,done" groups="base.group_no_one"/>
                         <field name="state" widget="statusbar" clickable="True"/>
@@ -48,7 +49,7 @@
                             <label for="user_domain" class="oe_edit_only" string="Assign Challenge To"/>
                             <div>
                                 <field name="user_domain" widget="char_domain" options="{'model': 'res.users'}" />
-                                <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" />
+                                <field name="user_ids" groups="base.group_no_one" widget="many2many_tags" readonly="True" />
                             </div>
                         </div>
 
                     <templates>
                         <t t-name="kanban-box">
                             <div t-attf-class="oe_kanban_card oe_kanban_goal oe_kanban_global_click">
-                                <div class="oe_dropdown_toggle oe_dropdown_kanban">
-                                    <span class="oe_e">í</span>
-                                    <ul class="oe_dropdown_menu">
-                                        <li><a type="edit">Configure Challenge</a></li>
-                                    </ul>
-                                </div>
                                 <div class="oe_kanban_content">
                                    <strong>
                                        <h4 class="text-center"><field name="name"/></h4>
index ed0702f..e8081f4 100644 (file)
                     <filter name="my" string="My Goals" domain="[('user_id', '=', uid)]"/>
                     <separator/>
                     <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]"/>
-                    <filter name="inprogress" string="Current"
+                    <filter name="inprogress" string="Running"
                         domain="[
                             '|',
                                 ('state', '=', 'inprogress'),
-                                ('end_date', '>=', context_today().strftime('%%Y-%%m-%%d'))
-                            ]"/>
-                    <filter name="closed" string="Passed" domain="[('state', 'in', ('reached', 'failed'))]"/>
+                                '&amp;',
+                                    ('state', 'in', ('done', 'failed')),
+                                    ('end_date', '>=', context_today().strftime('%%Y-%%m-%%d'))
+                        ]"/>
+                    <filter name="closed" string="Done"
+                        domain="[
+                            ('state', 'in', ('reached', 'failed')),
+                            '|',
+                                ('end_date', '=', False),
+                                ('end_date', '&lt;', context_today().strftime('%%Y-%%m-%%d'))
+                        ]"/>
                     <separator/>
 
                     <field name="user_id"/>
index 60c758a..1c95fef 100644 (file)
@@ -21,7 +21,7 @@
             <field name="inherit_id" ref="hr.view_employee_form"/>
             <field name="arch" type="xml">
 
-                <xpath expr="//page[@string='Public Information']" position="before">
+                <xpath expr="//page[@string='Public Information']" position="after">
                     <page string="Received Badges" attrs="{'invisible': [('user_id', '=', False)]}">
                         <field name="has_badges" invisible="1"/>
                         <button string="Grant a Badge" type="action" name="%(action_reward_wizard)d"/> to reward this employee for a good action
@@ -34,8 +34,6 @@
                         </div>
                         <field name="badge_ids" widget="many2many_kanban" />
                     </page>
-                </xpath>
-                <xpath expr="//page[@string='Public Information']" position="after">
                     <page string="Goals">
                         <field name="goal_ids" widget="many2many_kanban" />
                     </page>