From 777e1098604b6401ceb9935a212d1f4f5d6d84bd Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 30 Jul 2022 21:45:04 +0200 Subject: [PATCH] Notifier normalement les MP de sanction (#6323) --- zds/member/commons.py | 2 +- zds/member/tests/views/tests_moderation.py | 229 ++++++++++++++----- zds/member/views/register.py | 1 - zds/mp/api/serializers.py | 2 +- zds/mp/utils.py | 39 ++-- zds/notification/models.py | 62 ++--- zds/notification/receivers.py | 11 +- zds/tutorialv2/views/contributors.py | 1 - zds/tutorialv2/views/validations_contents.py | 3 - zds/tutorialv2/views/validations_opinions.py | 5 - zds/utils/tests/tests_interventions.py | 2 +- 11 files changed, 225 insertions(+), 132 deletions(-) diff --git a/zds/member/commons.py b/zds/member/commons.py index 9b188e5837..b0b218765a 100644 --- a/zds/member/commons.py +++ b/zds/member/commons.py @@ -213,7 +213,7 @@ def notify_member(self, ban, msg): "", msg, send_by_mail=True, - direct=True, + force_email=True, hat=get_hat_from_settings("moderation"), ) diff --git a/zds/member/tests/views/tests_moderation.py b/zds/member/tests/views/tests_moderation.py index ae1f8a71d9..7205c2a04b 100644 --- a/zds/member/tests/views/tests_moderation.py +++ b/zds/member/tests/views/tests_moderation.py @@ -12,6 +12,7 @@ from zds.member.views.moderation import member_from_ip from zds.member.tests.factories import ProfileFactory, StaffProfileFactory, UserFactory from zds.member.models import Profile, Ban, KarmaNote +from zds.notification.models import Notification class TestsModeration(TestCase): @@ -28,7 +29,7 @@ def setUp(self): self.bot = Group(name=settings.ZDS_APP["member"]["bot_group"]) self.bot.save() - def test_sanctions(self): + def test_ls_followed_by_unls(self): """ Test various sanctions. """ @@ -43,20 +44,23 @@ def test_sanctions(self): # Test: LS user_ls = ProfileFactory() + ls_text = "Texte de test pour LS" result = self.client.post( reverse("member-modify-profile", kwargs={"user_pk": user_ls.user.id}), - {"ls": "", "ls-text": "Texte de test pour LS"}, + {"ls": "", "ls-text": ls_text}, follow=False, ) - user = Profile.objects.get(id=user_ls.id) # Refresh profile from DB + profile = Profile.objects.get(id=user_ls.id) # Refresh profile from DB self.assertEqual(result.status_code, 302) - self.assertFalse(user.can_write) - self.assertTrue(user.can_read) - self.assertIsNone(user.end_ban_write) - self.assertIsNone(user.end_ban_read) - ban = Ban.objects.filter(user__id=user.user.id).order_by("-pubdate")[0] + self.assertFalse(profile.can_write) + self.assertTrue(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-pubdate")[0] self.assertEqual(ban.type, "Lecture seule illimitée") - self.assertEqual(ban.note, "Texte de test pour LS") + self.assertEqual(ban.note, ls_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 1) + self.assertEqual(Notification.objects.all().count(), 1) self.assertEqual(len(mail.outbox), 1) result = self.client.get(reverse("member-list"), follow=False) @@ -64,109 +68,208 @@ def test_sanctions(self): self.assertEqual(nb_users + 1, len(result.context["members"])) # LS guy still shows up, good # Test: Un-LS + unls_text = "Texte de test pour un-LS" result = self.client.post( reverse("member-modify-profile", kwargs={"user_pk": user_ls.user.id}), - {"un-ls": "", "unls-text": "Texte de test pour un-LS"}, + {"un-ls": "", "unls-text": unls_text}, follow=False, ) - user = Profile.objects.get(id=user_ls.id) # Refresh profile from DB + profile = Profile.objects.get(id=user_ls.id) # Refresh profile from DB self.assertEqual(result.status_code, 302) - self.assertTrue(user.can_write) - self.assertTrue(user.can_read) - self.assertIsNone(user.end_ban_write) - self.assertIsNone(user.end_ban_read) - ban = Ban.objects.filter(user__id=user.user.id).order_by("-id")[0] + self.assertTrue(profile.can_write) + self.assertTrue(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] self.assertEqual(ban.type, "Levée de la lecture seule") - self.assertEqual(ban.note, "Texte de test pour un-LS") + self.assertEqual(ban.note, unls_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 2) self.assertEqual(len(mail.outbox), 2) result = self.client.get(reverse("member-list"), follow=False) self.assertEqual(result.status_code, 200) self.assertEqual(nb_users + 1, len(result.context["members"])) # LS guy still shows up, good - # Test: LS temp - user_ls_temp = ProfileFactory() + def test_temp_ls_followed_by_unls(self): + """ + Test various sanctions. + """ + + staff = StaffProfileFactory() + self.client.force_login(staff.user) + + # list of members. + result = self.client.get(reverse("member-list"), follow=False) + self.assertEqual(result.status_code, 200) + nb_users = len(result.context["members"]) + + # Test: Temp LS + profile = ProfileFactory() + ls_text = "Texte de test pour LS TEMP" result = self.client.post( - reverse("member-modify-profile", kwargs={"user_pk": user_ls_temp.user.id}), - {"ls-temp": "", "ls-jrs": 10, "ls-text": "Texte de test pour LS TEMP"}, + reverse("member-modify-profile", kwargs={"user_pk": profile.user.id}), + {"ls-temp": "", "ls-jrs": 10, "ls-text": ls_text}, follow=False, ) - user = Profile.objects.get(id=user_ls_temp.id) # Refresh profile from DB + profile = Profile.objects.get(id=profile.id) # Refresh profile from DB self.assertEqual(result.status_code, 302) - self.assertFalse(user.can_write) - self.assertTrue(user.can_read) - self.assertIsNotNone(user.end_ban_write) - self.assertIsNone(user.end_ban_read) - ban = Ban.objects.filter(user__id=user.user.id).order_by("-id")[0] + self.assertFalse(profile.can_write) + self.assertTrue(profile.can_read) + self.assertIsNotNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] self.assertIn("Lecture seule temporaire", ban.type) - self.assertEqual(ban.note, "Texte de test pour LS TEMP") - self.assertEqual(len(mail.outbox), 3) + self.assertEqual(ban.note, ls_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 1) + self.assertEqual(Notification.objects.all().count(), 1) + self.assertEqual(len(mail.outbox), 1) + + result = self.client.get(reverse("member-list"), follow=False) + self.assertEqual(result.status_code, 200) + self.assertEqual(nb_users + 1, len(result.context["members"])) # LS guy still shows up, good + + # Test: Un-LS + unls_text = "Texte de test pour un-LS" + result = self.client.post( + reverse("member-modify-profile", kwargs={"user_pk": profile.user.id}), + {"un-ls": "", "unls-text": unls_text}, + follow=False, + ) + profile = Profile.objects.get(id=profile.id) # Refresh profile from DB + self.assertEqual(result.status_code, 302) + self.assertTrue(profile.can_write) + self.assertTrue(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] + self.assertEqual(ban.type, "Levée de la lecture seule") + self.assertEqual(ban.note, unls_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 2) + self.assertEqual(len(mail.outbox), 2) + + result = self.client.get(reverse("member-list"), follow=False) + self.assertEqual(result.status_code, 200) + self.assertEqual(nb_users + 1, len(result.context["members"])) # LS guy still shows up, good + + def test_ban_followed_by_unban(self): + """ + Test ban followed by unban. + """ + + staff = StaffProfileFactory() + self.client.force_login(staff.user) - # reset nb_users + # list of members. result = self.client.get(reverse("member-list"), follow=False) self.assertEqual(result.status_code, 200) nb_users = len(result.context["members"]) # Test: BAN - user_ban = ProfileFactory() + profile = ProfileFactory() + ban_text = "Texte de test pour BAN" result = self.client.post( - reverse("member-modify-profile", kwargs={"user_pk": user_ban.user.id}), - {"ban": "", "ban-text": "Texte de test pour BAN"}, + reverse("member-modify-profile", kwargs={"user_pk": profile.user.id}), + {"ban": "", "ban-text": ban_text}, follow=False, ) - user = Profile.objects.get(id=user_ban.id) # Refresh profile from DB + profile = Profile.objects.get(id=profile.id) # Refresh profile from DB self.assertEqual(result.status_code, 302) - self.assertTrue(user.can_write) - self.assertFalse(user.can_read) - self.assertIsNone(user.end_ban_write) - self.assertIsNone(user.end_ban_read) - ban = Ban.objects.filter(user__id=user.user.id).order_by("-id")[0] + self.assertTrue(profile.can_write) + self.assertFalse(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] self.assertEqual(ban.type, "Bannissement illimité") - self.assertEqual(ban.note, "Texte de test pour BAN") - self.assertEqual(len(mail.outbox), 4) + self.assertEqual(ban.note, ban_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 1) + self.assertEqual(len(mail.outbox), 1) result = self.client.get(reverse("member-list"), follow=False) self.assertEqual(result.status_code, 200) self.assertEqual(nb_users, len(result.context["members"])) # Banned guy doesn't show up, good # Test: un-BAN + unban_text = "Texte de test pour UNBAN" result = self.client.post( - reverse("member-modify-profile", kwargs={"user_pk": user_ban.user.id}), - {"un-ban": "", "unban-text": "Texte de test pour BAN"}, + reverse("member-modify-profile", kwargs={"user_pk": profile.user.id}), + {"un-ban": "", "unban-text": unban_text}, follow=False, ) - user = Profile.objects.get(id=user_ban.id) # Refresh profile from DB + profile = Profile.objects.get(id=profile.id) # Refresh profile from DB self.assertEqual(result.status_code, 302) - self.assertTrue(user.can_write) - self.assertTrue(user.can_read) - self.assertIsNone(user.end_ban_write) - self.assertIsNone(user.end_ban_read) - ban = Ban.objects.filter(user__id=user.user.id).order_by("-id")[0] + self.assertTrue(profile.can_write) + self.assertTrue(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] self.assertEqual(ban.type, "Levée du bannissement") - self.assertEqual(ban.note, "Texte de test pour BAN") - self.assertEqual(len(mail.outbox), 5) + self.assertEqual(ban.note, unban_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 2) + self.assertEqual(len(mail.outbox), 2) result = self.client.get(reverse("member-list"), follow=False) self.assertEqual(result.status_code, 200) self.assertEqual(nb_users + 1, len(result.context["members"])) # UnBanned guy shows up, good - # Test: BAN temp - user_ban_temp = ProfileFactory() + def test_temp_ban_followed_by_unban(self): + """ + Test temporary ban followed by unban. + """ + + staff = StaffProfileFactory() + self.client.force_login(staff.user) + + # list of members. + result = self.client.get(reverse("member-list"), follow=False) + self.assertEqual(result.status_code, 200) + nb_users = len(result.context["members"]) + + # Test: BAN + profile = ProfileFactory() + ban_text = "Texte de test pour BAN TEMP" result = self.client.post( - reverse("member-modify-profile", kwargs={"user_pk": user_ban_temp.user.id}), - {"ban-temp": "", "ban-jrs": 10, "ban-text": "Texte de test pour BAN TEMP"}, + reverse("member-modify-profile", kwargs={"user_pk": profile.user.id}), + {"ban-temp": "", "ban-jrs": 10, "ban-text": ban_text}, follow=False, ) - user = Profile.objects.get(id=user_ban_temp.id) # Refresh profile from DB + profile = Profile.objects.get(id=profile.id) # Refresh profile from DB self.assertEqual(result.status_code, 302) - self.assertTrue(user.can_write) - self.assertFalse(user.can_read) - self.assertIsNone(user.end_ban_write) - self.assertIsNotNone(user.end_ban_read) - ban = Ban.objects.filter(user__id=user.user.id).order_by("-id")[0] + self.assertTrue(profile.can_write) + self.assertFalse(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNotNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] self.assertIn("Bannissement temporaire", ban.type) - self.assertEqual(ban.note, "Texte de test pour BAN TEMP") - self.assertEqual(len(mail.outbox), 6) + self.assertEqual(ban.note, ban_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 1) + self.assertEqual(len(mail.outbox), 1) + + result = self.client.get(reverse("member-list"), follow=False) + self.assertEqual(result.status_code, 200) + self.assertEqual(nb_users, len(result.context["members"])) # Banned guy doesn't show up, good + + # Test: un-BAN + unban_text = "Texte de test pour UNBAN" + result = self.client.post( + reverse("member-modify-profile", kwargs={"user_pk": profile.user.id}), + {"un-ban": "", "unban-text": unban_text}, + follow=False, + ) + profile = Profile.objects.get(id=profile.id) # Refresh profile from DB + self.assertEqual(result.status_code, 302) + self.assertTrue(profile.can_write) + self.assertTrue(profile.can_read) + self.assertIsNone(profile.end_ban_write) + self.assertIsNone(profile.end_ban_read) + ban = Ban.objects.filter(user__id=profile.user.id).order_by("-id")[0] + self.assertEqual(ban.type, "Levée du bannissement") + self.assertEqual(ban.note, unban_text) + self.assertEqual(Notification.objects.filter(subscription__user=profile.user, is_read=False).count(), 2) + self.assertEqual(len(mail.outbox), 2) + + result = self.client.get(reverse("member-list"), follow=False) + self.assertEqual(result.status_code, 200) + self.assertEqual(nb_users + 1, len(result.context["members"])) # UnBanned guy shows up, good def test_sanctions_with_not_staff_user(self): user = ProfileFactory().user diff --git a/zds/member/views/register.py b/zds/member/views/register.py index b4637a92f5..38e8dcb14b 100644 --- a/zds/member/views/register.py +++ b/zds/member/views/register.py @@ -283,7 +283,6 @@ def activate_account(request): msg, send_by_mail=False, leave=True, - direct=False, hat=get_hat_from_settings("moderation"), ) token.delete() diff --git a/zds/mp/api/serializers.py b/zds/mp/api/serializers.py index 554338761b..4017b7e100 100644 --- a/zds/mp/api/serializers.py +++ b/zds/mp/api/serializers.py @@ -185,7 +185,7 @@ def create(self, validated_data): author = self.context.get("view").request.user # Send post in mp - send_message_mp(author, topic, self.validated_data.get("text"), send_by_mail=True, direct=False) + send_message_mp(author, topic, self.validated_data.get("text"), send_by_mail=True) return topic.last_message def update(self, instance, validated_data): diff --git a/zds/mp/utils.py b/zds/mp/utils.py index c74cb14403..948c8fa221 100644 --- a/zds/mp/utils.py +++ b/zds/mp/utils.py @@ -20,8 +20,8 @@ def send_mp( subtitle, text, send_by_mail=True, + force_email=False, leave=True, - direct=False, hat=None, automatically_read=None, ): @@ -33,8 +33,8 @@ def send_mp( :param title: title of the private topic :param subtitle: subtitle of the private topic :param text: content of the private message - :param send_by_mail: - :param direct: send a mail directly without mp (ex : ban members who wont connect again) + :param send_by_mail: if True, also notify by email + :param force_email: if True, send email even if the user has not enabled email notifications :param leave: if True, do not add the sender to the topic :param hat: hat with which to send the private message :param automatically_read: a user or a list of users that will automatically be marked as having read of the mp @@ -44,7 +44,7 @@ def send_mp( n_topic = PrivateTopic.create(title=title, subtitle=subtitle, author=author, recipients=users) signals.topic_created.send(sender=PrivateTopic, topic=n_topic, by_email=send_by_mail) - topic = send_message_mp(author, n_topic, text, send_by_mail, direct, hat) + topic = send_message_mp(author, n_topic, text, send_by_mail, force_email, hat) if automatically_read: if not isinstance(automatically_read, list): @@ -58,7 +58,7 @@ def send_mp( return topic -def send_message_mp(author, n_topic, text, send_by_mail=True, direct=False, hat=None, no_notification_for=None): +def send_message_mp(author, n_topic, text, send_by_mail=True, force_email=False, hat=None, no_notification_for=None): """ Send a post in an MP. @@ -66,7 +66,7 @@ def send_message_mp(author, n_topic, text, send_by_mail=True, direct=False, hat= :param n_topic: topic in which it will be sent :param text: content of the message :param send_by_mail: if True, also notify by email - :param direct: send a mail directly without private message (ex : banned members who won't connect again) + :param force_email: if True, send email even if the user has not enabled email notifications :param hat: hat attached to the message :param no_notification_for: list of participants who won't be notified of the message """ @@ -91,26 +91,13 @@ def send_message_mp(author, n_topic, text, send_by_mail=True, direct=False, hat= n_topic.last_message = post n_topic.save() - if not direct: - signals.message_added.send( - sender=post.__class__, post=post, by_email=send_by_mail, no_notification_for=no_notification_for - ) - - if send_by_mail and direct: - subject = "{} : {}".format(settings.ZDS_APP["site"]["literal_name"], n_topic.title) - from_email = "{} <{}>".format( - settings.ZDS_APP["site"]["literal_name"], settings.ZDS_APP["site"]["email_noreply"] - ) - for recipient in n_topic.participants.values_list("email", flat=True): - message_html = render_to_string("email/direct.html", {"msg": emarkdown(text)}) - message_txt = render_to_string("email/direct.txt", {"msg": text}) - - msg = EmailMultiAlternatives(subject, message_txt, from_email, [recipient]) - msg.attach_alternative(message_html, "text/html") - try: - msg.send() - except Exception as e: - logger.exception("Message was not sent to %s due to %s", recipient, e) + signals.message_added.send( + sender=post.__class__, + post=post, + by_email=send_by_mail, + force_email=force_email, + no_notification_for=no_notification_for, + ) if no_notification_for: if not isinstance(no_notification_for, list): no_notification_for = [no_notification_for] diff --git a/zds/notification/models.py b/zds/notification/models.py index e38093e35a..cacd3ff406 100644 --- a/zds/notification/models.py +++ b/zds/notification/models.py @@ -151,36 +151,40 @@ def send_notification(self, content=None, send_email=True, sender=None): assert hasattr(self, "send_email") if self.last_notification is None or self.last_notification.is_read: + notifications = list(Notification.objects.filter(subscription=self)) + if len(notifications) > 1: + LOG.error("Found %s notifications for %s", len(notifications), self, exc_info=True) + Notification.objects.filter(pk__in=[n.pk for n in notifications[1:]]).delete() + LOG.info("Duplicates deleted.") + + notification = self.build_notification(content, sender) with transaction.atomic(): - notifications = list(Notification.objects.filter(subscription=self)) - if len(notifications) > 1: - LOG.error("Found %s notifications for %s", len(notifications), self, exc_info=True) - Notification.objects.filter(pk__in=[n.pk for n in notifications[1:]]).delete() - LOG.info("Duplicates deleted.") - - # If there isn't a notification yet or the last one is read, we generate a new one. - try: - notification = Notification.objects.get(subscription=self) - except Notification.DoesNotExist: - notification = Notification(subscription=self, content_object=content, sender=sender) - notification.content_object = content - notification.sender = sender - notification.url = self.get_notification_url(content) - notification.title = self.get_notification_title(content) - notification.pubdate = content.pubdate - notification.is_read = False notification.save() self.last_notification = notification self.save() - if send_email and self.by_email: - self.send_email(notification) + if send_email and self.by_email: + self.send_email(notification) elif self.last_notification is not None and not self.last_notification.is_read: # Update last notification if the new content is older (marking answer as unread) if self.last_notification.pubdate > content.pubdate: self.last_notification.content_object = content self.last_notification.save() + def build_notification(self, content, sender): + # If there isn't a notification yet or the last one is read, we generate a new one. + try: + notification = Notification.objects.get(subscription=self) + except Notification.DoesNotExist: + notification = Notification(subscription=self, content_object=content, sender=sender) + notification.content_object = content + notification.sender = sender + notification.url = self.get_notification_url(content) + notification.title = self.get_notification_title(content) + notification.pubdate = content.pubdate + notification.is_read = False + return notification + def mark_notification_read(self): """ Marks the notification of the subscription as read. @@ -206,19 +210,23 @@ def send_notification(self, content=None, send_email=True, sender=None): if self.last_notification and not self.last_notification.is_read: return + notification = self.build_notification(content, sender) with transaction.atomic(): - notification = Notification(subscription=self, content_object=content, sender=sender) - notification.content_object = content - notification.sender = sender - notification.url = self.get_notification_url(content) - notification.title = self.get_notification_title(content) - notification.is_read = False notification.save() self.last_notification = notification self.save() - if send_email and self.by_email: - self.send_email(notification) + if send_email and self.by_email: + self.send_email(notification) + + def build_notification(self, content, sender): + notification = Notification(subscription=self, content_object=content, sender=sender) + notification.content_object = content + notification.sender = sender + notification.url = self.get_notification_url(content) + notification.title = self.get_notification_title(content) + notification.is_read = False + return notification def mark_notification_read(self, content): """ diff --git a/zds/notification/receivers.py b/zds/notification/receivers.py index 37b7354cc5..53d66c2959 100644 --- a/zds/notification/receivers.py +++ b/zds/notification/receivers.py @@ -425,13 +425,14 @@ def create_private_topic_event(sender, *, topic, by_email, **__): @receiver(mp_signals.message_added, sender=PrivatePost) @disable_for_loaddata -def answer_private_topic_event(sender, *, post, by_email, no_notification_for=None, **__): +def answer_private_topic_event(sender, *, post, by_email, force_email, no_notification_for=None, **__): """ Sends PrivateTopicAnswerSubscription to the subscribers to the topic and subscribe the author to the following answers to the topic. :param post: the new post. :param by_email: Send or not an email. + :param force_email: Send email even if the user has not enabled email notifications :param no_notification_for: user or group of user to ignore, really usefull when dealing with moderation message. """ @@ -439,8 +440,12 @@ def answer_private_topic_event(sender, *, post, by_email, no_notification_for=No for subscription in subscription_list: if subscription.user != post.author: is_new_mp = post.position_in_topic == 1 - send_email = by_email and ( - subscription.user.profile.email_for_answer or (is_new_mp and subscription.user.profile.email_for_new_mp) + send_email = force_email or ( + by_email + and ( + subscription.user.profile.email_for_answer + or (is_new_mp and subscription.user.profile.email_for_new_mp) + ) ) subscription.send_notification(content=post, sender=post.author, send_email=send_email) diff --git a/zds/tutorialv2/views/contributors.py b/zds/tutorialv2/views/contributors.py index 5756a9b36e..86a6604896 100644 --- a/zds/tutorialv2/views/contributors.py +++ b/zds/tutorialv2/views/contributors.py @@ -90,7 +90,6 @@ def form_valid(self, form): }, ), send_by_mail=True, - direct=False, leave=True, ) signals.contributors_management.send( diff --git a/zds/tutorialv2/views/validations_contents.py b/zds/tutorialv2/views/validations_contents.py index 635becf757..231f991946 100644 --- a/zds/tutorialv2/views/validations_contents.py +++ b/zds/tutorialv2/views/validations_contents.py @@ -340,7 +340,6 @@ def post(self, request, *args, **kwargs): msg, send_by_mail=True, leave=False, - direct=False, hat=get_hat_from_settings("validation"), ) validation.content.save() @@ -441,7 +440,6 @@ def form_valid(self, form): validation.content.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("validation"), ) validation.content.save() @@ -593,7 +591,6 @@ def form_valid(self, form): validation.content.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("validation"), ) self.object.save() diff --git a/zds/tutorialv2/views/validations_opinions.py b/zds/tutorialv2/views/validations_opinions.py index d59ab77254..bc255d550f 100644 --- a/zds/tutorialv2/views/validations_opinions.py +++ b/zds/tutorialv2/views/validations_opinions.py @@ -145,7 +145,6 @@ def form_valid(self, form): versioned.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("moderation"), ) self.object.save() @@ -241,7 +240,6 @@ def form_valid(self, form): versioned.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("moderation"), ) self.object.save() @@ -337,7 +335,6 @@ def form_valid(self, form): versioned.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("moderation"), ) self.object.save() @@ -411,7 +408,6 @@ def form_valid(self, form): versioned.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("moderation"), ) self.object.save() @@ -551,7 +547,6 @@ def form_valid(self, form): versionned_article.title, msg, send_by_mail=True, - direct=False, hat=get_hat_from_settings("validation"), ) article.save() diff --git a/zds/utils/tests/tests_interventions.py b/zds/utils/tests/tests_interventions.py index 500a67d404..1238b06867 100644 --- a/zds/utils/tests/tests_interventions.py +++ b/zds/utils/tests/tests_interventions.py @@ -44,7 +44,7 @@ def setUp(self): ) self.validation.save() - self.topic = send_mp(author=self.author.user, users=[], title="Title", text="Testing", subtitle="", leave=False) + self.topic = send_mp(author=self.author.user, users=[], title="Title", subtitle="", text="Testing", leave=False) self.topic.add_participant(self.user.user) send_message_mp(self.user.user, self.topic, "Testing")