[ADD] display list of unique user in badge kanban view
bzr revid: mat@openerp.com-20130402084027-n3g0lp3riikfukk0
This commit is contained in:
@@ -27,8 +27,6 @@ from openerp.tools.safe_eval import safe_eval
|
||||
from templates import TemplateHelper
|
||||
from datetime import date
|
||||
|
||||
import base64
|
||||
|
||||
|
||||
class gamification_badge_user(osv.Model):
|
||||
"""User having received a badge"""
|
||||
@@ -71,6 +69,17 @@ class gamification_badge(osv.Model):
|
||||
result[obj.id] = len(obj.owner_ids)
|
||||
return result
|
||||
|
||||
def _get_unique_global_list(self, cr, uid, ids, name, args, context=None):
|
||||
"""Return the list of unique res.users ids having received this badge"""
|
||||
result = dict.fromkeys(ids, False)
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
res = self.pool.get('gamification.badge.user').read_group(
|
||||
cr, uid, domain=[('badge_id', '=', obj.id)],
|
||||
fields=['badge_id', 'user_id'],
|
||||
groupby=['user_id'], context=context)
|
||||
result[obj.id] = [badge_user['user_id'][0] for badge_user in res]
|
||||
return result
|
||||
|
||||
def _get_unique_global_count(self, cr, uid, ids, name, args, context=None):
|
||||
"""Return the number of time this badge has been granted to individual users"""
|
||||
result = dict.fromkeys(ids, False)
|
||||
@@ -171,6 +180,10 @@ class gamification_badge(osv.Model):
|
||||
help="A message will be posted on the user profile or just sent to him"),
|
||||
'owner_ids': fields.one2many('gamification.badge.user', 'badge_id',
|
||||
string='Owners', help='The list of instances of this badge granted to users'),
|
||||
'unique_owner_ids': fields.function(_get_unique_global_list,
|
||||
string='Unique Owners',
|
||||
help="The list of unique users having received this badge.",
|
||||
type="many2many", relation="res.users"),
|
||||
|
||||
'stat_count': fields.function(_get_global_count, string='Total',
|
||||
help="The number of time this badge has been received."),
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
<field name="stat_my"/>
|
||||
<field name="stat_count"/>
|
||||
<field name="stat_count_distinct"/>
|
||||
<field name="unique_owner_ids"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-attf-class="#{record.stat_my.raw_value ? 'oe_kanban_color_5' : 'oe_kanban_color_white'} oe_kanban_card oe_kanban_global_click oe_kanban_badge">
|
||||
@@ -147,9 +148,9 @@ jspW8F2wIbhtSRr0Vf4AD6Nod0TaN4kAAAAASUVORK5CYII=" alt="got-it" /></t> -->
|
||||
<em><field name="description"/></em>
|
||||
</t>
|
||||
<p>Granted <t t-esc="record.stat_count.raw_value" />x (<t t-esc="record.stat_count_distinct.raw_value"/> pers.)</p>
|
||||
<div class="oe_kanban_project_avatars">
|
||||
<t t-foreach="record.owner_ids.user_id.raw_value.slice(0,11)" t-as="member">
|
||||
<img t-att-src="kanban_image('res.users', 'image_small', member)" t-att-data-member_id="member"/>
|
||||
<div class="oe_kanban_badge_avatars">
|
||||
<t t-foreach="record.unique_owner_ids.raw_value.slice(0,11)" t-as="owner">
|
||||
<img t-att-src="kanban_image('res.users', 'image_small', owner)" t-att-data-member_id="owner"/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
}
|
||||
|
||||
|
||||
.oe_kanban_badge_avatars img {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding-left: 0;
|
||||
margin-top: 3px;
|
||||
border-radius: 2px;
|
||||
-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
/* Mail Sidebar */
|
||||
|
||||
.openerp .oe_mail_wall .oe_mail_wall_aside {
|
||||
|
||||
Reference in New Issue
Block a user