diff options
| author | Atul Patel (OpenERP) <atp@tinyerp.com> | 2014-02-18 11:26:18 +0530 |
|---|---|---|
| committer | Atul Patel (OpenERP) <atp@tinyerp.com> | 2014-02-18 11:26:18 +0530 |
| commit | 33b99c8a0737e08e6a243e41bb455d3ab7e6c851 (patch) | |
| tree | a1db52bfbeecf0c6fd9096604b7ec4540bb04197 /addons/gamification/wizard | |
| parent | caa3510ea434e10c32dcbc134f9c74b2b9f18b2a (diff) | |
| parent | aa0eac1257b97c1be693e8a804fec6ecbf2bb22f (diff) | |
[MERGE]: Merged with addons
bzr revid: atp@tinyerp.com-20140218055618-r36w29vat7zig9ar
Diffstat (limited to 'addons/gamification/wizard')
| -rw-r--r-- | addons/gamification/wizard/__init__.py | 23 | ||||
| -rw-r--r-- | addons/gamification/wizard/grant_badge.py | 56 | ||||
| -rw-r--r-- | addons/gamification/wizard/grant_badge.xml | 33 | ||||
| -rw-r--r-- | addons/gamification/wizard/update_goal.py | 44 | ||||
| -rw-r--r-- | addons/gamification/wizard/update_goal.xml | 24 |
5 files changed, 180 insertions, 0 deletions
diff --git a/addons/gamification/wizard/__init__.py b/addons/gamification/wizard/__init__.py new file mode 100644 index 00000000000..638fbef4373 --- /dev/null +++ b/addons/gamification/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 OpenERP SA (<http://openerp.com>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import update_goal +import grant_badge diff --git a/addons/gamification/wizard/grant_badge.py b/addons/gamification/wizard/grant_badge.py new file mode 100644 index 00000000000..44f739fff4e --- /dev/null +++ b/addons/gamification/wizard/grant_badge.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +from openerp.osv import fields, osv +from openerp.tools.translate import _ + + +class grant_badge_wizard(osv.TransientModel): + """ Wizard allowing to grant a badge to a user""" + + _name = 'gamification.badge.user.wizard' + _columns = { + 'user_id': fields.many2one("res.users", string='User', required=True), + 'badge_id': fields.many2one("gamification.badge", string='Badge', required=True), + 'comment': fields.text('Comment'), + } + + def action_grant_badge(self, cr, uid, ids, context=None): + """Wizard action for sending a badge to a chosen user""" + + badge_obj = self.pool.get('gamification.badge') + badge_user_obj = self.pool.get('gamification.badge.user') + + for wiz in self.browse(cr, uid, ids, context=context): + if uid == wiz.user_id.id: + raise osv.except_osv(_('Warning!'), _('You can not grant a badge to yourself')) + + #create the badge + values = { + 'user_id': wiz.user_id.id, + 'sender_id': uid, + 'badge_id': wiz.badge_id.id, + 'comment': wiz.comment, + } + badge_user = badge_user_obj.create(cr, uid, values, context=context) + result = badge_obj._send_badge(cr, uid, badge_user, context=context) + + return result diff --git a/addons/gamification/wizard/grant_badge.xml b/addons/gamification/wizard/grant_badge.xml new file mode 100644 index 00000000000..e03dbac4096 --- /dev/null +++ b/addons/gamification/wizard/grant_badge.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<openerp> + <data> + + <record id="view_badge_wizard_grant" model="ir.ui.view"> + <field name="name">Grant Badge User Form</field> + <field name="model">gamification.badge.user.wizard</field> + <field name="arch" type="xml"> + <form string="Grant Badge To" version="7.0"> + Who would you like to reward? + <group> + <field name="user_id" nolabel="1" /> + <field name="badge_id" invisible="1"/> + <field name="comment" nolabel="1" placeholder="Describe what they did and why it matters (will be public)" class="oe_no_padding" /> + </group> + <footer> + <button string="Grant Badge" type="object" name="action_grant_badge" class="oe_highlight" /> or + <button string="Cancel" special="cancel" class="oe_link"/> + </footer> + </form> + </field> + </record> + + <act_window domain="[]" id="action_grant_wizard" + name="Grant Badge" + target="new" + res_model="gamification.badge.user.wizard" + context="{'default_badge_id': active_id, 'badge_id': active_id}" + view_type="form" view_mode="form" + view_id="gamification.view_badge_wizard_grant" /> + + </data> +</openerp> diff --git a/addons/gamification/wizard/update_goal.py b/addons/gamification/wizard/update_goal.py new file mode 100644 index 00000000000..cbda3fefbce --- /dev/null +++ b/addons/gamification/wizard/update_goal.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +from openerp.osv import fields, osv + +class goal_manual_wizard(osv.TransientModel): + """Wizard to update a manual goal""" + _name = 'gamification.goal.wizard' + _columns = { + 'goal_id': fields.many2one("gamification.goal", string='Goal', required=True), + 'current': fields.float('Current'), + } + + def action_update_current(self, cr, uid, ids, context=None): + """Wizard action for updating the current value""" + + goal_obj = self.pool.get('gamification.goal') + + for wiz in self.browse(cr, uid, ids, context=context): + towrite = { + 'current': wiz.current, + 'goal_id': wiz.goal_id.id, + } + goal_obj.write(cr, uid, [wiz.goal_id.id], towrite, context=context) + goal_obj.update(cr, uid, [wiz.goal_id.id], context=context) + return {} diff --git a/addons/gamification/wizard/update_goal.xml b/addons/gamification/wizard/update_goal.xml new file mode 100644 index 00000000000..793efab90ff --- /dev/null +++ b/addons/gamification/wizard/update_goal.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<openerp> + <data> + + <record id="view_goal_wizard_update_current" model="ir.ui.view"> + <field name="name">Update the current value of the Goal</field> + <field name="model">gamification.goal.wizard</field> + <field name="arch" type="xml"> + <form string="Grant Badge To" version="7.0"> + Set the current value you have reached for this goal + <group> + <field name="goal_id" invisible="1"/> + <field name="current" /> + </group> + <footer> + <button string="Update" type="object" name="action_update_current" class="oe_highlight" /> or + <button string="Cancel" special="cancel" class="oe_link"/> + </footer> + </form> + </field> + </record> + + </data> +</openerp> |
