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
0dc035de
Commit
0dc035de
authored
Oct 02, 2014
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/rebase-20140926: Repaired faulty keygen logic
parent
31b22d2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
common/djangoapps/util/request.py
+19
-16
No files found.
common/djangoapps/util/request.py
View file @
0dc035de
...
@@ -8,6 +8,7 @@ from django.test.client import RequestFactory
...
@@ -8,6 +8,7 @@ from django.test.client import RequestFactory
from
microsite_configuration
import
microsite
from
microsite_configuration
import
microsite
from
opaque_keys
import
InvalidKeyError
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -37,31 +38,33 @@ def course_id_from_url(url):
...
@@ -37,31 +38,33 @@ def course_id_from_url(url):
if
not
url
:
if
not
url
:
return
None
return
None
COURSE_REGEX
=
re
.
compile
(
r'^.*?/courses/(?P<course_id>[a-zA-Z0-9_+\/:]+)'
)
deprecated
=
False
if
'/'
in
url
:
deprecated
=
True
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
)
match
=
COURSE_REGEX
.
match
(
url
)
if
match
is
None
:
if
match
is
None
:
return
None
return
None
course_id
=
match
.
group
(
'course_id'
)
course_id
=
match
.
group
(
'course_id'
)
if
course_id
is
None
:
if
course_id
is
None
:
return
None
return
None
try
:
try
:
return
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
course_key
=
key_generator
(
course_id
)
except
InvalidKeyError
:
except
InvalidKeyError
:
COURSE_REGEX
=
re
.
compile
(
r'(?P<course_id>[^/]+/[^/]+/[^/]+)'
)
log
.
warning
(
match
=
COURSE_REGEX
.
match
(
course_id
)
'unable to parse course_id "{}"'
.
format
(
course_id
),
if
match
is
None
:
exc_info
=
True
return
None
)
course_id
=
match
.
group
(
'course_id'
)
return
None
if
course_id
is
None
:
return
None
try
:
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
except
InvalidKeyError
:
log
.
warning
(
'unable to parse course_id "{}"'
.
format
(
course_id
),
exc_info
=
True
)
return
course_key
return
course_key
...
...
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