Esempio n. 1
0
 def form_valid(self, form):
     form.instance.author = self.request.user
     ret = super().form_valid(form)
     try:
         send_new_to_review_mails(form.instance)
     except Exception:
         pass
     messages.add_message(self.request, messages.INFO,
                          'Materiał dodany, oczekuje na korektę.')
     _action_logger.info('%s added %s' % (self.request.user, form.instance))
     return ret
Esempio n. 2
0
 def form_valid(self, form, formsets):
     ret = super().form_valid(form, formsets)
     try:
         send_new_to_review_mails(form.instance)
     except Exception:
         pass
     messages.add_message(self.request, messages.INFO,
                          "Materiał dodany, oczekuje na korektę.")
     _action_logger.info("%s added %s" % (self.request.user,
                                          form.instance))
     return ret
Esempio n. 3
0
    def test_new_to_review_mails(self):
        author = testing.create_user()
        reviewer_a = testing.create_user(perms=['content.review'])
        testing.create_user(perms=['content.review'])

        # There are two reviewers, both should receive an email about the new
        # article added by Alice.
        article = Article.create_for_testing(author)
        send_new_to_review_mails(article)
        self.assertEqual(len(mail.outbox), 2)

        # Only one email should be sent when an approver adds a new article -
        # only the other one can review it.
        article = Article.create_for_testing(reviewer_a)
        send_new_to_review_mails(article)
        self.assertEqual(len(mail.outbox), 3)

        # https://github.com/ppiet/piosenka/issues/8
        # Set the first reviewers's email to empty - they should now be skipped,
        # but the other reviewer should be notified.
        reviewer_a.email = ''
        reviewer_a.save()
        article = Article.create_for_testing(author)
        send_new_to_review_mails(article)
        self.assertEqual(len(mail.outbox), 4)