예제 #1
0
파일: user.py 프로젝트: cralison/Spirit
def resend_activation_email(request):
    if request.user.is_authenticated():
        return redirect(
            request.GET.get('next', reverse('spirit:profile-update')))

    if request.method == 'POST':
        form = ResendActivationForm(data=request.POST)

        if form.is_valid():
            user = form.get_user()
            logger.debug("register user:%s", user)

            send_activation_email(request, user)

        messages.info(
            request,
            _("If you don't receive an email, please make sure you've entered "
              "the address you registered with, and check your spam folder."))
        return redirect(reverse('spirit:user-login'))
    else:
        form = ResendActivationForm()

    return render(request, 'spirit/user/activation_resend.html', {
        'form': form,
    })
예제 #2
0
 def test_user_activation_email_complete(self):
     """
     Integration test
     """
     req = RequestFactory().get('/')
     send_activation_email(req, self.user)
     self.assertEquals(len(mail.outbox), 1)
예제 #3
0
파일: user.py 프로젝트: cralison/Spirit
def register(request):
    if request.user.is_authenticated():
        return redirect(
            request.GET.get('next', reverse('spirit:profile-update')))

    if request.method == 'POST':
        form = RegistrationForm(data=request.POST)

        if form.is_valid():
            user = form.save()
            logger.debug("register user:%s", user)

            send_activation_email(request, user)
            messages.info(
                request,
                _("We have sent you an email so you can activate your account!"
                  ))

            # TODO: email-less activation
            #if not settings.REGISTER_EMAIL_ACTIVATION_REQUIRED:
            #login(request, user)
            #return redirect(request.GET.get('next', reverse('spirit:profile-update')))

            return redirect(reverse('spirit:user-login'))
    else:
        form = RegistrationForm()

    return render(request, 'spirit/user/register.html', {
        'form': form,
    })
예제 #4
0
    def test_user_activation_email(self):
        """
        Send activation email
        """
        self._monkey_sender_called = False

        def monkey_sender(request, subject, template_name, context, email):
            self.assertEqual(request, req)
            self.assertEqual(email, [self.user.email, ])

            activation_token = UserActivationTokenGenerator()
            token = activation_token.generate(self.user)
            self.assertDictEqual(context, {'token': token, 'user_id': self.user.pk})

            self.assertEqual(subject, _("User activation"))
            self.assertEqual(template_name, 'spirit/user/activation_email.html')

            self._monkey_sender_called = True

        req = RequestFactory().get('/')

        org_sender, email.sender = email.sender, monkey_sender
        try:
            send_activation_email(req, self.user)
            self.assertTrue(self._monkey_sender_called)
        finally:
            email.sender = org_sender
예제 #5
0
파일: tests_utils.py 프로젝트: gone/Spirit
 def test_user_activation_email_complete(self):
     """
     Integration test
     """
     req = RequestFactory().get('/')
     send_activation_email(req, self.user)
     self.assertEquals(len(mail.outbox), 1)
예제 #6
0
파일: tests_utils.py 프로젝트: gone/Spirit
    def test_user_activation_email(self):
        """
        Send activation email
        """
        self._monkey_sender_called = False

        def monkey_sender(request, subject, template_name, context, email):
            self.assertEqual(request, req)
            self.assertEqual(email, [
                self.user.email,
            ])

            activation_token = UserActivationTokenGenerator()
            token = activation_token.generate(self.user)
            self.assertDictEqual(context, {
                'token': token,
                'user_id': self.user.pk
            })

            self.assertEqual(subject, _("User activation"))
            self.assertEqual(template_name,
                             'spirit/user/activation_email.html')

            self._monkey_sender_called = True

        req = RequestFactory().get('/')

        org_sender, email.sender = email.sender, monkey_sender
        try:
            send_activation_email(req, self.user)
            self.assertTrue(self._monkey_sender_called)
        finally:
            email.sender = org_sender
예제 #7
0
파일: user.py 프로젝트: BigManager/Spirit
def resend_activation_email(request):
    if request.user.is_authenticated():
        return redirect(request.GET.get('next', reverse('spirit:profile-update')))

    if request.method == 'POST':
        form = ResendActivationForm(data=request.POST)

        if form.is_valid():
            user = form.get_user()
            send_activation_email(request, user)

        messages.info(request, _("If you don't receive an email, please make sure you've entered "
                                 "the address you registered with, and check your spam folder."))
        return redirect(reverse('spirit:user-login'))
    else:
        form = ResendActivationForm()

    return render(request, 'spirit/user/activation_resend.html', {'form': form, })
예제 #8
0
파일: user.py 프로젝트: BigManager/Spirit
def register(request):
    if request.user.is_authenticated():
        return redirect(request.GET.get('next', reverse('spirit:profile-update')))

    if request.method == 'POST':
        form = RegistrationForm(data=request.POST)

        if form.is_valid():
            user = form.save()
            send_activation_email(request, user)
            messages.info(request, _("We have sent you an email so you can activate your account!"))

            # TODO: email-less activation
            #if not settings.REGISTER_EMAIL_ACTIVATION_REQUIRED:
                #login(request, user)
                #return redirect(request.GET.get('next', reverse('spirit:profile-update')))

            return redirect(reverse('spirit:user-login'))
    else:
        form = RegistrationForm()

    return render(request, 'spirit/user/register.html', {'form': form, })
예제 #9
0
파일: user.py 프로젝트: sanorchid/wingzen
def resend_activation_email(request):
    if request.user.is_authenticated():
        return redirect(request.GET.get("next", reverse("spirit:profile-update")))

    if request.method == "POST":
        form = ResendActivationForm(data=request.POST)

        if not request.is_limited and form.is_valid():
            user = form.get_user()
            send_activation_email(request, user)

        messages.info(
            request,
            _(
                "If you don't receive an email, please make sure you've entered "
                "the address you registered with, and check your spam folder."
            ),
        )
        return redirect(reverse("spirit:user-login"))
    else:
        form = ResendActivationForm()

    return render(request, "spirit/user/activation_resend.html", {"form": form})
예제 #10
0
파일: user.py 프로젝트: sanorchid/wingzen
def register(request):
    if request.user.is_authenticated():
        return redirect(request.GET.get("next", reverse("spirit:profile-update")))

    if request.method == "POST":
        form = RegistrationForm(data=request.POST)

        if not request.is_limited and form.is_valid():
            user = form.save()
            send_activation_email(request, user)
            messages.info(request, _("We have sent you an email so you can activate your account!"))

            # TODO: email-less activation
            # if not settings.REGISTER_EMAIL_ACTIVATION_REQUIRED:
            # login(request, user)
            # return redirect(request.GET.get('next', reverse('spirit:profile-update')))

            return redirect(reverse("spirit:user-login"))
    else:
        form = RegistrationForm()

    # get_uploadavatar_context().update( {'form': form, })

    return render(request, "spirit/user/register.html", {"form": form})