Add some links to student records
Add some waffle-guarded connection points to the Credentials service to start filling out the user flow for Student Records. Specifically, add a button to the Program Progress Details page if a certificate exists, and add a link in the Learner Profile page. Both only appear if the 'student_records' waffle switch is active. LEARNER-4701
This commit is contained in:
committed by
Michael Terry
parent
4297c999c4
commit
502287b07e
@@ -2,6 +2,7 @@
|
||||
Models for credentials support for the LMS and Studio.
|
||||
"""
|
||||
|
||||
import waffle
|
||||
from urlparse import urljoin
|
||||
|
||||
from config_models.models import ConfigurationModel
|
||||
@@ -77,6 +78,17 @@ class CredentialsApiConfig(ConfigurationModel):
|
||||
root = helpers.get_value('CREDENTIALS_PUBLIC_SERVICE_URL', settings.CREDENTIALS_PUBLIC_SERVICE_URL)
|
||||
return urljoin(root, '/api/{}/'.format(API_VERSION))
|
||||
|
||||
@property
|
||||
def public_records_url(self):
|
||||
"""
|
||||
Publicly-accessible Records URL root.
|
||||
"""
|
||||
# Temporarily disable this feature while we work on it
|
||||
if not waffle.switch_is_active('student_records'):
|
||||
return None
|
||||
root = helpers.get_value('CREDENTIALS_PUBLIC_SERVICE_URL', settings.CREDENTIALS_PUBLIC_SERVICE_URL)
|
||||
return urljoin(root, '/records/')
|
||||
|
||||
@property
|
||||
def is_learner_issuance_enabled(self):
|
||||
"""
|
||||
|
||||
@@ -9,6 +9,19 @@ from openedx.core.lib.edx_api_utils import get_edx_api_data
|
||||
from openedx.core.lib.token_utils import JwtBuilder
|
||||
|
||||
|
||||
def get_credentials_records_url(program_uuid=None):
|
||||
"""
|
||||
Returns a URL for a given records page (or general records list if given no UUID).
|
||||
May return None if this feature is disabled.
|
||||
"""
|
||||
base_url = CredentialsApiConfig.current().public_records_url
|
||||
if base_url is None:
|
||||
return None
|
||||
if program_uuid:
|
||||
return base_url + 'programs/{}/'.format(program_uuid)
|
||||
return base_url
|
||||
|
||||
|
||||
def get_credentials_api_client(user):
|
||||
""" Returns an authenticated Credentials API client. """
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ from openedx.core.djangolib.markup import HTML
|
||||
${_('Build out your profile to personalize your identity on {platform_name}.').format(
|
||||
platform_name=platform_name,
|
||||
)}
|
||||
% if records_url:
|
||||
## We don't translate this yet because we know it's not the final string
|
||||
<p>To view and share your program records, go to <a href="${records_url}">My Records</a>.</p>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
import datetime
|
||||
import ddt
|
||||
import mock
|
||||
from waffle.testutils import override_switch
|
||||
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
from lms.envs.test import CREDENTIALS_PUBLIC_SERVICE_URL
|
||||
from course_modes.models import CourseMode
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
@@ -20,6 +22,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@override_switch('student_records', True)
|
||||
class LearnerProfileViewTest(UrlResetMixin, ModuleStoreTestCase):
|
||||
""" Tests for the student profile view. """
|
||||
|
||||
@@ -110,6 +113,11 @@ class LearnerProfileViewTest(UrlResetMixin, ModuleStoreTestCase):
|
||||
for attribute in self.CONTEXT_DATA:
|
||||
self.assertIn(attribute, response.content)
|
||||
|
||||
def test_records_link(self):
|
||||
profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME})
|
||||
response = self.client.get(path=profile_path)
|
||||
self.assertContains(response, '<a href="{}/records/">'.format(CREDENTIALS_PUBLIC_SERVICE_URL))
|
||||
|
||||
def test_undefined_profile_page(self):
|
||||
"""
|
||||
Verify that a 404 is returned for a non-existent profile page.
|
||||
|
||||
@@ -12,6 +12,7 @@ from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django_countries import countries
|
||||
from edxmako.shortcuts import marketing_link
|
||||
from openedx.core.djangoapps.credentials.utils import get_credentials_records_url
|
||||
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.user_api.accounts.api import get_account_settings
|
||||
@@ -139,6 +140,7 @@ def learner_profile_context(request, profile_username, user_is_staff):
|
||||
'show_dashboard_tabs': True,
|
||||
'disable_courseware_js': True,
|
||||
'nav_hidden': True,
|
||||
'records_url': get_credentials_records_url(),
|
||||
}
|
||||
|
||||
if badges_enabled():
|
||||
|
||||
Reference in New Issue
Block a user