Skip to content

Commit

Permalink
🚑 mail_private: fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ommo73 committed Dec 18, 2019
1 parent e67caee commit 1f4d131
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
31 changes: 18 additions & 13 deletions mail_private/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,21 @@ def _notify_compute_internal_recipients(self, record, msg_vals):
recipient_data['channels'] = [i for i in recipient_data['channels'] if i['id'] in cids]
return recipient_data

# First test it without this model
# class MailThread(models.AbstractModel):
# _inherit = 'mail.thread'
#
# @api.multi
# @api.returns('self', lambda value: value.id)
# def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False,
# attachments=None, content_subtype='html', **kwargs):
# if 'channel_ids' in kwargs:
# kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
# return super(MailThread, self).message_post(body, subject, message_type,
# subtype, parent_id, attachments,
# content_subtype, **kwargs)

class MailThread(models.AbstractModel):
_inherit = 'mail.thread'

@api.multi
@api.returns('mail.message', lambda value: value.id)
def message_post(self, body='', subject=None,
message_type='notification', subtype=None,
parent_id=False, attachments=None,
notif_layout=False, add_sign=True, model_description=False,
mail_auto_delete=True, **kwargs):
if 'channel_ids' in kwargs:
kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
return super(MailThread, self).message_post(body, subject,
message_type, subtype,
parent_id, attachments,
notif_layout, add_sign, model_description,
mail_auto_delete, **kwargs)
11 changes: 10 additions & 1 deletion mail_private/static/src/js/mail_private.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ var core = require('web.core');
var Chatter = require('mail.Chatter');
var ChatterComposer = require('mail.composer.Chatter');
var session = require('web.session');
var Thread = require('mail.model.Thread');

var rpc = require('web.rpc');
var config = require('web.config');
var mailUtils = require('mail.utils');

Thread.include({
_postMessage: function (data) {
return this._super.apply(this, arguments).then(function (messageData) {
messageData['channel_ids'] = data['channel_ids'];
return messageData;
});
},
});

Chatter.include({
init: function () {
Expand Down Expand Up @@ -63,7 +72,7 @@ Chatter.include({
self._composer.on('post_message', self, function (messageData) {
if (options.is_private) {
self._composer.options.isLog = true;
self.composer.options.is_private = options.is_private;
self._composer.options.is_private = options.is_private;
}
self._discardOnReload(messageData).then(function () {
self._disableComposer();
Expand Down
12 changes: 9 additions & 3 deletions mail_private/static/src/xml/mail_private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@
<t t-jquery="div[class='o_composer_suggested_partners']" t-operation="after">
<div class="o_composer_suggested_channels">
<t t-if="widget.suggested_channels">
<t t-set="count" t-value="0"/>
<t t-foreach='widget.suggested_channels' t-as='channel'>
<div t-attf-title="Add as channel and follower">
<div class="o_checkbox">
<div class="custom-control custom-checkbox">
<input type="checkbox"
t-att-checked="channel.checked ? 'checked' : undefined"
t-att-data-fullname="channel.full_name"/>
t-att-data-fullname="channel.full_name"
class="custom-control-input"
t-att-id="'o_composer_suggested_channels_p' + count"/>
<span/>
<label class="custom-control-label" t-att-for="'o_composer_suggested_channels_p' + count">
<t t-esc="channel.name"/>
</label>
</div>
<t t-esc="channel.name"/>
</div>
<t t-set="count" t-value="count+1"/>
</t>
</t>
<button class="btn btn-link oe_composer_uncheck" t-if="widget.options.is_private">Uncheck all</button>
Expand Down

0 comments on commit 1f4d131

Please sign in to comment.