diff --git a/ietf/ietfauth/tests.py b/ietf/ietfauth/tests.py index 633dc8320..7aa5200b1 100644 --- a/ietf/ietfauth/tests.py +++ b/ietf/ietfauth/tests.py @@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse as urlreverse from django.contrib.auth.models import User from django.conf import settings -from ietf.utils.test_utils import TestCase, login_testing_unauthorized +from ietf.utils.test_utils import TestCase, login_testing_unauthorized, unicontent from ietf.utils.test_data import make_test_data from ietf.utils.mail import outbox, empty_outbox from ietf.person.models import Person, Email @@ -89,6 +89,7 @@ class IetfAuthTests(TestCase): empty_outbox() r = self.client.post(url, { 'email': email }) self.assertEqual(r.status_code, 200) + self.assertTrue("Account created" in unicontent(r.content)) self.assertEqual(len(outbox), 1) # go to confirm page diff --git a/ietf/ietfauth/views.py b/ietf/ietfauth/views.py index 909eabbc7..903d39d8e 100644 --- a/ietf/ietfauth/views.py +++ b/ietf/ietfauth/views.py @@ -80,7 +80,8 @@ def index(request): # return HttpResponseRedirect(redirect_to) def create_account(request): - success = False + to_email = None + if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): @@ -103,7 +104,7 @@ def create_account(request): return render(request, 'registration/create.html', { 'form': form, - 'success': success, + 'to_email': to_email, }) def confirm_account(request, auth): @@ -140,10 +141,12 @@ def confirm_account(request, auth): name=email, ascii=email) if not email_obj: - email_obj = Email.objects.create(address=email, - person=person) - email_obj.person = person - email_obj.save() + email_obj = Email.objects.create(address=email, person=person) + else: + if not email_obj.person: + email_obj.person = person + email_obj.save() + person.user = user person.save() @@ -315,6 +318,8 @@ def confirm_password_reset(request, auth): user.save() # password is also stored in htpasswd file save_htpasswd_file(user.username, password) + + success = True else: form = PasswordForm() diff --git a/ietf/templates/registration/create.html b/ietf/templates/registration/create.html index a61f362f0..107896457 100644 --- a/ietf/templates/registration/create.html +++ b/ietf/templates/registration/create.html @@ -9,10 +9,12 @@ {% block content %} {% origin %} - {% if success %} + {% if to_email %}
Your account creation request has been successfully received.
-We have sent you an email with instructions on how to complete the process.
+ +We have sent an email to {{ to_email }} with instructions on how to complete the process.
{% else %}