Success Message for Account Activation for logged out users.
This commit is contained in:
@@ -6,6 +6,8 @@ from django.conf import settings
|
||||
from django.test import TestCase, override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
from edxmako.shortcuts import render_to_string
|
||||
from student.models import Registration
|
||||
from student.tests.factories import UserFactory
|
||||
@@ -159,3 +161,28 @@ class TestActivateAccount(TestCase):
|
||||
)
|
||||
response = self.client.get(reverse('dashboard'))
|
||||
self.assertNotContains(response, expected_message, html=True)
|
||||
|
||||
def test_account_activation_notification_on_logistration(self):
|
||||
"""
|
||||
Verify that logistration page displays success/error/info messages
|
||||
about account activation.
|
||||
"""
|
||||
login_page_url = "{login_url}?next={redirect_url}".format(
|
||||
login_url=reverse('signin_user'),
|
||||
redirect_url=reverse('dashboard'),
|
||||
)
|
||||
# Access activation link, message should say that account has been activated.
|
||||
response = self.client.get(reverse('activate', args=[self.registration.activation_key]), follow=True)
|
||||
self.assertRedirects(response, login_page_url)
|
||||
self.assertContains(response, 'You have activated your account.')
|
||||
|
||||
# Access activation link again, message should say that account is already active.
|
||||
response = self.client.get(reverse('activate', args=[self.registration.activation_key]), follow=True)
|
||||
self.assertRedirects(response, login_page_url)
|
||||
self.assertContains(response, 'This account has already been activated.')
|
||||
|
||||
# Open account activation page with an invalid activation link,
|
||||
# there should be an error message displayed.
|
||||
response = self.client.get(reverse('activate', args=[uuid4().hex]), follow=True)
|
||||
self.assertRedirects(response, login_page_url)
|
||||
self.assertContains(response, 'Your account could not be activated')
|
||||
|
||||
@@ -90,7 +90,7 @@ from openedx.core.djangoapps.external_auth.login_and_register import (
|
||||
register as external_auth_register
|
||||
)
|
||||
from openedx.core.djangoapps import monitoring_utils
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
import track.views
|
||||
|
||||
@@ -2302,7 +2302,7 @@ def activate_account(request, key):
|
||||
except (Registration.DoesNotExist, Registration.MultipleObjectsReturned):
|
||||
messages.error(
|
||||
request,
|
||||
Text(_(
|
||||
HTML(_(
|
||||
'{html_start}Your account could not be activated{html_end}'
|
||||
'Something went wrong, please <a href="{support_url}">contact support</a> to resolve this issue.'
|
||||
)).format(
|
||||
@@ -2310,7 +2310,7 @@ def activate_account(request, key):
|
||||
html_start=HTML('<p class="message-title">'),
|
||||
html_end=HTML('</p>'),
|
||||
),
|
||||
extra_tags='account-activation icon'
|
||||
extra_tags='account-activation aa-icon'
|
||||
)
|
||||
else:
|
||||
if not registration.user.is_active:
|
||||
@@ -2318,20 +2318,20 @@ def activate_account(request, key):
|
||||
# Add account activation success message for display later
|
||||
messages.success(
|
||||
request,
|
||||
Text(_('{html_start}Success{html_end} You have activated your account.')).format(
|
||||
HTML(_('{html_start}Success{html_end} You have activated your account.')).format(
|
||||
html_start=HTML('<p class="message-title">'),
|
||||
html_end=HTML('</p>'),
|
||||
),
|
||||
extra_tags='account-activation icon',
|
||||
extra_tags='account-activation aa-icon',
|
||||
)
|
||||
else:
|
||||
messages.info(
|
||||
request,
|
||||
Text(_('{html_start}This account has already been activated.{html_end}')).format(
|
||||
HTML(_('{html_start}This account has already been activated.{html_end}')).format(
|
||||
html_start=HTML('<p class="message-title">'),
|
||||
html_end=HTML('</p>'),
|
||||
),
|
||||
extra_tags='account-activation icon',
|
||||
extra_tags='account-activation aa-icon',
|
||||
)
|
||||
|
||||
# Enroll student in any pending courses he/she may have if auto_enroll flag is set
|
||||
|
||||
@@ -353,7 +353,7 @@ class CombinedLoginAndRegisterPage(PageObject):
|
||||
"""Wait for a status message to be visible following third_party registration, then return it."""
|
||||
def _check_func():
|
||||
"""Return third party auth status notice message."""
|
||||
selector = '.js-auth-warning p'
|
||||
selector = '.js-auth-warning div'
|
||||
msg_element = self.q(css=selector)
|
||||
if msg_element.visible:
|
||||
return (True, msg_element.text[0])
|
||||
|
||||
Reference in New Issue
Block a user