Files
edx-platform/common/djangoapps/track/contexts.py
Gabe Mulley 5aa19c08b5 Revert "emit enrollment event"
This reverts commit 5734cae1c3.
2013-11-06 14:35:28 -05:00

32 lines
560 B
Python

"""Generates common contexts"""
import re
COURSE_REGEX = re.compile(r'^.*?/courses/(?P<course_id>(?P<org_id>[^/]+)/[^/]+/[^/]+)')
def course_context_from_url(url):
"""
Extracts the course_id from the given `url.`
Example Returned Context::
{
'course_id': 'org/course/run',
'org_id': 'org'
}
"""
url = url or ''
context = {
'course_id': '',
'org_id': ''
}
match = COURSE_REGEX.match(url)
if match:
context.update(match.groupdict())
return context