Ejemplo n.º 1
0
    def action_activate(self, request, users):
        inactive_users = []
        for user in users:
            if user.requires_activation:
                inactive_users.append(user)

        if not inactive_users:
            message = _("You have to select inactive users.")
            raise generic.MassActionError(message)
        else:
            activated_users_pks = [u.pk for u in inactive_users]
            queryset = User.objects.filter(pk__in=activated_users_pks)
            queryset.update(requires_activation=ACTIVATION_REQUIRED_NONE)

            mail_subject = _("Your account on %(forum_title)s "
                             "forums has been activated")
            subject_formats = {'forum_title': settings.forum_name}
            mail_subject = mail_subject % subject_formats

            mail_subject = mail_subject
            mail_users(request, inactive_users, mail_subject,
                       'misago/emails/activation/by_admin')

            message = _("Selected users accounts have been activated.")
            messages.success(request, message)
Ejemplo n.º 2
0
def test_mail_users(request):
    User = get_user_model()

    mail.mail_users(request, User.objects.iterator(), "Misago Test Spam",
                    "misago/emails/base")

    return HttpResponse("Mailed users!")
Ejemplo n.º 3
0
def test_mail_users(request):
    User = get_user_model()

    mail.mail_users(request,
                    User.objects.iterator(),
                    "Misago Test Spam",
                    "misago/emails/base")

    return HttpResponse("Mailed users!")
    def test_mail_users(self):
        """mail_users sets messages in backend"""
        test_users = [
            UserModel.objects.create_user('Alpha', '*****@*****.**',
                                          'pass123'),
            UserModel.objects.create_user('Beta', '*****@*****.**', 'pass123'),
            UserModel.objects.create_user('Niner', '*****@*****.**',
                                          'pass123'),
            UserModel.objects.create_user('Foxtrot', '*****@*****.**',
                                          'pass123'),
            UserModel.objects.create_user('Uniform', '*****@*****.**',
                                          'pass123'),
        ]

        mail_users(test_users, "Misago Test Spam", "misago/emails/base")

        spams_sent = 0
        for message in mail.outbox:
            if message.subject == 'Misago Test Spam':
                spams_sent += 1

        self.assertEqual(spams_sent, len(test_users))