Merge pull request #19797 from edx/arch/redirect-profile-page
Redirect Profile view to Profile Microfrontend
This commit is contained in:
@@ -3452,11 +3452,17 @@ RETIREMENT_STATES = [
|
||||
'COMPLETE',
|
||||
]
|
||||
|
||||
############## Settings for Writable Gradebook #########################
|
||||
############## Settings for Microfrontends #########################
|
||||
# If running a Gradebook container locally,
|
||||
# modify lms/envs/private.py to give it a non-null value
|
||||
WRITABLE_GRADEBOOK_URL = None
|
||||
|
||||
# TODO (DEPR-17)
|
||||
# This URL value is needed to redirect the old profile page to a new
|
||||
# micro-frontend based implementation. Once the old implementation is
|
||||
# completely removed and this redirect is no longer needed, we can remove this.
|
||||
PROFILE_MICROFRONTEND_URL = "http://some.profile.spa/u/"
|
||||
|
||||
############### Settings for django-fernet-fields ##################
|
||||
FERNET_KEYS = [
|
||||
'DUMMY KEY CHANGE BEFORE GOING TO PRODUCTION',
|
||||
|
||||
@@ -1102,8 +1102,9 @@ RETIREMENT_STATES = ENV_TOKENS.get('RETIREMENT_STATES', RETIREMENT_STATES)
|
||||
############## Settings for Course Enrollment Modes ######################
|
||||
COURSE_ENROLLMENT_MODES = ENV_TOKENS.get('COURSE_ENROLLMENT_MODES', COURSE_ENROLLMENT_MODES)
|
||||
|
||||
############## Settings for Writable Gradebook #########################
|
||||
############## Settings for Microfrontend URLS #########################
|
||||
WRITABLE_GRADEBOOK_URL = ENV_TOKENS.get('WRITABLE_GRADEBOOK_URL', WRITABLE_GRADEBOOK_URL)
|
||||
PROFILE_MICROFRONTEND_URL = ENV_TOKENS.get('PROFILE_MICROFRONTEND_URL', PROFILE_MICROFRONTEND_URL)
|
||||
|
||||
############################### Plugin Settings ###############################
|
||||
|
||||
|
||||
@@ -14,3 +14,6 @@ SHOW_PROFILE_MESSAGE = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'show_message')
|
||||
|
||||
# Waffle flag to show achievements on the learner profile.
|
||||
SHOW_ACHIEVEMENTS_FLAG = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'show_achievements', flag_undefined_default=True)
|
||||
|
||||
# Waffle flag to redirect to another learner profile experience.
|
||||
REDIRECT_TO_PROFILE_MICROFRONTEND = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'redirect_to_microfrontend')
|
||||
|
||||
@@ -5,6 +5,8 @@ import datetime
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.certificates.api import is_passing_status
|
||||
from lms.envs.test import CREDENTIALS_PUBLIC_SERVICE_URL
|
||||
@@ -13,7 +15,9 @@ from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.test.client import RequestFactory
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from openedx.features.learner_profile import REDIRECT_TO_PROFILE_MICROFRONTEND
|
||||
from openedx.features.learner_profile.views.learner_profile import learner_profile_context
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from util.testing import UrlResetMixin
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
@@ -111,6 +115,14 @@ class LearnerProfileViewTest(UrlResetMixin, ModuleStoreTestCase):
|
||||
for attribute in self.CONTEXT_DATA:
|
||||
self.assertIn(attribute, response.content)
|
||||
|
||||
def test_redirect_view(self):
|
||||
profile_url = "http://profile-spa/abc/"
|
||||
with override_settings(PROFILE_MICROFRONTEND_URL=profile_url):
|
||||
with override_waffle_flag(REDIRECT_TO_PROFILE_MICROFRONTEND, active=True):
|
||||
profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME})
|
||||
response = self.client.get(path=profile_path)
|
||||
self.assertRedirects(response, profile_url + self.USERNAME, target_status_code=404)
|
||||
|
||||
def test_records_link(self):
|
||||
profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME})
|
||||
response = self.client.get(path=profile_path)
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.urls import reverse
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render_to_response
|
||||
from django.shortcuts import render_to_response, redirect
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django_countries import countries
|
||||
@@ -23,7 +23,7 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.features.journals.api import journals_enabled
|
||||
from student.models import User
|
||||
|
||||
from .. import SHOW_PROFILE_MESSAGE
|
||||
from .. import SHOW_PROFILE_MESSAGE, REDIRECT_TO_PROFILE_MICROFRONTEND
|
||||
|
||||
from learner_achievements import LearnerAchievementsFragmentView
|
||||
|
||||
@@ -47,6 +47,10 @@ def learner_profile(request, username):
|
||||
Example usage:
|
||||
GET /account/profile
|
||||
"""
|
||||
if REDIRECT_TO_PROFILE_MICROFRONTEND.is_enabled():
|
||||
profile_microfrontend_url = "{}{}".format(settings.PROFILE_MICROFRONTEND_URL, username)
|
||||
return redirect(profile_microfrontend_url)
|
||||
|
||||
try:
|
||||
context = learner_profile_context(request, username, request.user.is_staff)
|
||||
# TODO: LEARNER-2554: 09/2017: Remove message and cookie logic when we no longer want this message
|
||||
|
||||
Reference in New Issue
Block a user