Merge pull request #12757 from edx/renzo/link-to-detail
Link program listing cards to detail pages
This commit is contained in:
@@ -14,7 +14,7 @@ class UserCredential(factory.Factory):
|
||||
username = FuzzyText(prefix='user_')
|
||||
status = 'awarded'
|
||||
uuid = FuzzyText(prefix='uuid_')
|
||||
certificate_url = 'http=//credentials.edx.org/credentials/dummy-uuid'
|
||||
certificate_url = FuzzyText(prefix='https://www.example.com/credentials/')
|
||||
credential = {}
|
||||
|
||||
|
||||
|
||||
@@ -49,12 +49,14 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
|
||||
factories.UserCredential(
|
||||
id=1,
|
||||
username='test',
|
||||
credential=factories.ProgramCredential()
|
||||
credential=factories.ProgramCredential(),
|
||||
certificate_url=self.CREDENTIALS_API_RESPONSE['results'][0]['certificate_url'],
|
||||
),
|
||||
factories.UserCredential(
|
||||
id=2,
|
||||
username='test',
|
||||
credential=factories.ProgramCredential()
|
||||
credential=factories.ProgramCredential(),
|
||||
certificate_url=self.CREDENTIALS_API_RESPONSE['results'][1]['certificate_url'],
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import logging
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.text import slugify
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
import pytz
|
||||
|
||||
@@ -128,6 +129,26 @@ def get_programs_for_credentials(user, programs_credentials):
|
||||
return certificate_programs
|
||||
|
||||
|
||||
def get_program_detail_url(program, marketing_root):
|
||||
"""Construct the URL to be used when linking to program details.
|
||||
|
||||
Arguments:
|
||||
program (dict): Representation of a program.
|
||||
marketing_root (str): Root URL used to build links to XSeries marketing pages.
|
||||
|
||||
Returns:
|
||||
str, a link to program details
|
||||
"""
|
||||
if ProgramsApiConfig.current().show_program_details:
|
||||
base = reverse('program_details_view', kwargs={'program_id': program['id']}).rstrip('/')
|
||||
slug = slugify(program['name'])
|
||||
else:
|
||||
base = marketing_root.rstrip('/')
|
||||
slug = program['marketing_slug']
|
||||
|
||||
return '{base}/{slug}'.format(base=base, slug=slug)
|
||||
|
||||
|
||||
def get_display_category(program):
|
||||
""" Given the program, return the category of the program for display
|
||||
Arguments:
|
||||
|
||||
Reference in New Issue
Block a user