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
1f0ab9e0
Commit
1f0ab9e0
authored
Oct 21, 2013
by
Don Mitchell
Committed by
David Baumgold
Oct 22, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove as_old_location methods
They were incorrect if there were periods in the org or name.
parent
4ed83222
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
71 deletions
+4
-71
cms/djangoapps/auth/authz.py
+1
-3
cms/djangoapps/contentstore/views/course.py
+3
-3
common/lib/xmodule/xmodule/modulestore/locator.py
+0
-50
common/lib/xmodule/xmodule/modulestore/tests/test_locators.py
+0
-15
No files found.
cms/djangoapps/auth/authz.py
View file @
1f0ab9e0
...
@@ -37,9 +37,7 @@ def get_course_groupname_for_role(location, role):
...
@@ -37,9 +37,7 @@ def get_course_groupname_for_role(location, role):
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
location
.
course
))
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
location
.
course
))
elif
isinstance
(
location
,
CourseLocator
):
elif
isinstance
(
location
,
CourseLocator
):
old_location
=
loc_mapper
()
.
translate_locator_to_location
(
location
)
old_location
=
loc_mapper
()
.
translate_locator_to_location
(
location
)
if
old_location
is
None
:
if
old_location
:
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
location
.
as_old_location_course_id
))
else
:
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
old_location
.
course_id
))
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
old_location
.
course_id
))
for
groupname
in
groupnames
:
for
groupname
in
groupnames
:
...
...
cms/djangoapps/contentstore/views/course.py
View file @
1f0ab9e0
...
@@ -131,9 +131,9 @@ def course_index(request, course_url):
...
@@ -131,9 +131,9 @@ def course_index(request, course_url):
lms_link
=
get_lms_link_for_item
(
old_location
)
lms_link
=
get_lms_link_for_item
(
old_location
)
upload_asset_callback_url
=
reverse
(
'upload_asset'
,
kwargs
=
{
upload_asset_callback_url
=
reverse
(
'upload_asset'
,
kwargs
=
{
'org'
:
location
.
as_old_location_
org
,
'org'
:
old_location
.
org
,
'course'
:
location
.
as_old_location_
course
,
'course'
:
old_location
.
course
,
'coursename'
:
location
.
as_old_location_run
'coursename'
:
old_location
.
name
})
})
course
=
modulestore
()
.
get_item
(
old_location
,
depth
=
3
)
course
=
modulestore
()
.
get_item
(
old_location
,
depth
=
3
)
...
...
common/lib/xmodule/xmodule/modulestore/locator.py
View file @
1f0ab9e0
...
@@ -263,56 +263,6 @@ class CourseLocator(Locator):
...
@@ -263,56 +263,6 @@ class CourseLocator(Locator):
version_guid
=
self
.
version_guid
,
version_guid
=
self
.
version_guid
,
branch
=
self
.
branch
)
branch
=
self
.
branch
)
OLD_COURSE_ID_RE
=
re
.
compile
(
r'^(?P<org>[^.]+)\.?(?P<old_course_id>.+)?\.(?P<run>[^.]+)$'
)
@property
def
as_old_location_course_id
(
self
):
"""
The original Location type presented its course id as org/course/run. This function
assumes the course_id starts w/ org, has an arbitrarily long 'course' identifier, and then
ends w/ run all separated by periods.
If this object does not have a course_id, this function returns None.
"""
if
self
.
course_id
is
None
:
return
None
parsed
=
self
.
OLD_COURSE_ID_RE
.
match
(
self
.
course_id
)
# check whether there are 2 or > 2 'fields'
if
parsed
.
group
(
'old_course_id'
):
return
'/'
.
join
(
parsed
.
groups
())
else
:
return
parsed
.
group
(
'org'
)
+
'/'
+
parsed
.
group
(
'run'
)
def
_old_location_field_helper
(
self
,
field
):
"""
Parse course_id to get the old location field named field out
"""
if
self
.
course_id
is
None
:
return
None
parsed
=
self
.
OLD_COURSE_ID_RE
.
match
(
self
.
course_id
)
return
parsed
.
group
(
field
)
@property
def
as_old_location_org
(
self
):
"""
Presume the first part of the course_id is the org and return it.
"""
return
self
.
_old_location_field_helper
(
'org'
)
@property
def
as_old_location_course
(
self
):
"""
Presume the middle part, if any, of the course_id is the old location scheme's
course id and return it.
"""
return
self
.
_old_location_field_helper
(
'old_course_id'
)
@property
def
as_old_location_run
(
self
):
"""
Presume the last part of the course_id is the old location scheme's run and return it.
"""
return
self
.
_old_location_field_helper
(
'run'
)
def
init_from_url
(
self
,
url
):
def
init_from_url
(
self
,
url
):
"""
"""
url must be a string beginning with 'edx://' and containing
url must be a string beginning with 'edx://' and containing
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_locators.py
View file @
1f0ab9e0
...
@@ -283,21 +283,6 @@ class LocatorTest(TestCase):
...
@@ -283,21 +283,6 @@ class LocatorTest(TestCase):
Locator
.
to_locator_or_location
(
"hello.world.not.a.url"
)
Locator
.
to_locator_or_location
(
"hello.world.not.a.url"
)
self
.
assertIsNone
(
Locator
.
parse_url
(
"unknown://foo.bar/baz"
))
self
.
assertIsNone
(
Locator
.
parse_url
(
"unknown://foo.bar/baz"
))
def
test_as_old
(
self
):
"""
Test the as_old_location_xxx accessors
"""
locator
=
CourseLocator
(
course_id
=
'org.course.id.run'
,
branch
=
'mybranch'
)
self
.
assertEqual
(
'org'
,
locator
.
as_old_location_org
)
self
.
assertEqual
(
'course.id'
,
locator
.
as_old_location_course
)
self
.
assertEqual
(
'run'
,
locator
.
as_old_location_run
)
self
.
assertEqual
(
'org/course.id/run'
,
locator
.
as_old_location_course_id
)
locator
=
CourseLocator
(
course_id
=
'org.course'
,
branch
=
'mybranch'
)
self
.
assertEqual
(
'org'
,
locator
.
as_old_location_org
)
self
.
assertIsNone
(
locator
.
as_old_location_course
)
self
.
assertEqual
(
'course'
,
locator
.
as_old_location_run
)
self
.
assertEqual
(
'org/course'
,
locator
.
as_old_location_course_id
)
def
test_description_locator_url
(
self
):
def
test_description_locator_url
(
self
):
object_id
=
'{:024x}'
.
format
(
random
.
randrange
(
16
**
24
))
object_id
=
'{:024x}'
.
format
(
random
.
randrange
(
16
**
24
))
definition_locator
=
DefinitionLocator
(
object_id
)
definition_locator
=
DefinitionLocator
(
object_id
)
...
...
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