Files
odoo_source/addons/test_mail/tests/test_res_users.py
T
Mathieu Duckaerts-Antoine 299ebb2cdf [IMP] mail: add moderation on channels
Purpose of this commit is to allow moderation on incoming messages in
discussion channels. On some channels on which moderation is required
messages should be in a pending moderation stage. Moderators can accept
or refuse messages as well as always allow or ban messages coming from
a given set of emails.

Channels now have an option to be moderated. Moderators can be added on
channels. They have access to a specific UI in Discuss to see and take
action on messages waiting for moderation.

Concerning mail.thread message that are pending moderation are not notified.
It means nobody receives a notification about them. Moderation process calls
the notification once the message is validated.

Various features included in this commit :

 * a model is added to store the decision about emails, allow or ban;
 * access rights are updated so that only moderators can modify moderation
   fields on message;
 * specific bus notifications are send to moderated people as well as to
   moderators on incoming emails as well as when a decision is taken;
 * options are added on channels to send explanations to moderated emails;
 * options are added on channels to write and send guidelines explaining
   why and how moderation is performed;
 * a reminder is send daily to moderators with remaining messages to moderate;
 * discuss UI is adapted and a new channel is added below Inbox and Starred
   giving access to moderation tools;
 * chanenl UI is adapted allowing to moderate directly inside channels;

This commit is linked to task ID 29521. Closes #21921.
2018-06-06 16:01:33 +02:00

35 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests import common
from odoo.tests import tagged
@tagged('moderation')
class TestMessageModeration(common.Moderation):
@classmethod
def setUpClass(cls):
super(TestMessageModeration, cls).setUpClass()
def test_is_moderator(self):
self.assertTrue(self.user_employee.is_moderator)
self.assertFalse(self.user_admin.is_moderator)
self.assertTrue(self.user_employee_2.is_moderator)
def test_moderation_counter(self):
self._create_new_message(self.channel_1.id, status='pending_moderation', author=self.partner_admin)
self._create_new_message(self.channel_1.id, status='accepted', author=self.partner_admin)
self._create_new_message(self.channel_1.id, status='accepted', author=self.partner_employee)
self._create_new_message(self.channel_1.id, status='pending_moderation', author=self.partner_employee)
self._create_new_message(self.channel_1.id, status='accepted', author=self.partner_employee_2)
self.assertEqual(self.user_employee.moderation_counter, 2)
self.assertEqual(self.user_employee_2.moderation_counter, 0)
self.assertEqual(self.user_admin.moderation_counter, 0)
self.channel_1.write({'channel_partner_ids': [(4, self.partner_employee_2.id)], 'moderator_ids': [(4, self.user_employee_2.id)]})
self.assertEqual(self.user_employee.moderation_counter, 2)
self.assertEqual(self.user_employee_2.moderation_counter, 0)
self.assertEqual(self.user_admin.moderation_counter, 0)