[IMP] mail follower: allow to remove followers if the user have access to write on the document
bzr revid: chm@openerp.com-20121220140946-hqqkz62xyn0oq9g8
This commit is contained in:
@@ -859,7 +859,11 @@ class mail_thread(osv.AbstractModel):
|
||||
|
||||
def message_unsubscribe(self, cr, uid, ids, partner_ids, context=None):
|
||||
""" Remove partners from the records followers. """
|
||||
self.check_access_rights(cr, uid, 'read')
|
||||
user_pids = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id']
|
||||
if set(partner_ids) == set(user_pids):
|
||||
self.check_access_rights(cr, uid, 'read')
|
||||
else:
|
||||
self.check_access_rights(cr, uid, 'write')
|
||||
return self.write(cr, SUPERUSER_ID, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context)
|
||||
|
||||
#------------------------------------------------------
|
||||
|
||||
@@ -586,6 +586,11 @@
|
||||
margin-right:4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.openerp .oe_followers .oe_remove_follower{
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
|
||||
}
|
||||
|
||||
/* ---------------- MESSAGES BODY ------------------ */
|
||||
.openerp .oe_mail .oe_msg_content .oe_blockquote,
|
||||
|
||||
@@ -69,27 +69,38 @@ openerp_mail_followers = function(session, mail) {
|
||||
// event: click on a subtype, that (un)subscribe for this subtype
|
||||
this.$el.on('click', '.oe_subtype_list input', self.do_update_subscription);
|
||||
// event: click on 'invite' button, that opens the invite wizard
|
||||
this.$('.oe_invite').on('click', function (event) {
|
||||
action = {
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'mail.wizard.invite',
|
||||
view_mode: 'form',
|
||||
view_type: 'form',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
context: {
|
||||
'default_res_model': self.view.dataset.model,
|
||||
'default_res_id': self.view.datarecord.id,
|
||||
},
|
||||
}
|
||||
self.do_action(action, {
|
||||
on_close: function() {
|
||||
self.read_value();
|
||||
},
|
||||
});
|
||||
this.$('.oe_invite').on('click', self.on_invite_follower);
|
||||
this.$el.on('click', '.oe_remove_follower', self.on_remove_follower);
|
||||
},
|
||||
|
||||
on_invite_follower: function (event) {
|
||||
var self = this;
|
||||
var action = {
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'mail.wizard.invite',
|
||||
view_mode: 'form',
|
||||
view_type: 'form',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
context: {
|
||||
'default_res_model': this.view.dataset.model,
|
||||
'default_res_id': this.view.datarecord.id,
|
||||
},
|
||||
}
|
||||
this.do_action(action, {
|
||||
on_close: function() {
|
||||
self.read_value();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
on_remove_follower: function (event) {
|
||||
var partner_id = $(event.target).data('id');
|
||||
var context = new session.web.CompoundContext(this.build_context(), {});
|
||||
return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id], [partner_id], context])
|
||||
.then(this.proxy('read_value'));
|
||||
},
|
||||
|
||||
read_value: function () {
|
||||
var self = this;
|
||||
return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).then(function (results) {
|
||||
@@ -151,7 +162,7 @@ openerp_mail_followers = function(session, mail) {
|
||||
var node_user_list = this.$('.oe_follower_list').empty();
|
||||
this.$('.oe_follower_title').html(this._format_followers(records.length));
|
||||
// truncate number of displayed followers
|
||||
truncated = records.splice(0, this.displayed_nb);
|
||||
var truncated = records.splice(0, this.displayed_nb);
|
||||
_(truncated).each(function (record) {
|
||||
record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id);
|
||||
$(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<div t-name="mail.followers.partner" class='oe_partner'>
|
||||
<img class="oe_mail_thumbnail oe_mail_frame" t-attf-src="{record.avatar_url}"/>
|
||||
<a t-attf-href="#model=res.partner&id=#{record.id}"><t t-raw="record.name"/></a>
|
||||
<span class="oe_remove_follower oe_e" title="Remove this follower" t-att-data-id="record.id">X</span>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
|
||||
Reference in New Issue
Block a user