Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
297601d0
Commit
297601d0
authored
Aug 05, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify course URL discovery util.
parent
4ecf2286
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
15 deletions
+1
-15
common/djangoapps/util/request.py
+1
-15
No files found.
common/djangoapps/util/request.py
View file @
297601d0
...
...
@@ -37,21 +37,9 @@ def course_id_from_url(url):
"""
if
not
url
:
return
None
deprecated
=
False
if
'/'
in
url
:
deprecated
=
True
# Ignore query string
url
=
url
.
split
(
'?'
)[
0
]
if
deprecated
:
COURSE_REGEX
=
re
.
compile
(
r'^.*/courses/(?P<course_id>[^/]+/[^/]+/[^/]+)'
)
key_generator
=
SlashSeparatedCourseKey
.
from_deprecated_string
else
:
COURSE_REGEX
=
re
.
compile
(
r'^.*?/courses/(?P<course_id>[a-zA-Z0-9_+\/:]+)'
)
key_generator
=
CourseKey
.
from_string
match
=
COURSE_REGEX
.
match
(
url
)
if
match
is
None
:
return
None
...
...
@@ -60,7 +48,7 @@ def course_id_from_url(url):
return
None
try
:
course_key
=
key_generator
(
course_id
)
return
CourseKey
.
from_string
(
course_id
)
except
InvalidKeyError
:
log
.
warning
(
'unable to parse course_id "{}"'
.
format
(
course_id
),
...
...
@@ -68,8 +56,6 @@ def course_id_from_url(url):
)
return
None
return
course_key
class
RequestMock
(
RequestFactory
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment