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
7a6278e6
Commit
7a6278e6
authored
May 02, 2016
by
Ayub khan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12321 from edx/revert-10705-mrehan/SUST-22
Revert "Implement 'from_string_or_404' in utils"
parents
a6b9ba7d
d45c4d8c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
64 deletions
+4
-64
cms/djangoapps/contentstore/views/course.py
+4
-2
common/djangoapps/util/course_key_utils.py
+0
-30
common/djangoapps/util/tests/test_course_key_utils.py
+0
-32
No files found.
cms/djangoapps/contentstore/views/course.py
View file @
7a6278e6
...
...
@@ -91,7 +91,6 @@ from util.organizations_helpers import (
organizations_enabled
,
)
from
util.string_utils
import
_has_non_ascii_characters
from
util.course_key_utils
import
from_string_or_404
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.course_module
import
CourseFields
from
xmodule.course_module
import
DEFAULT_START_DATE
...
...
@@ -875,7 +874,10 @@ def course_info_handler(request, course_key_string):
GET
html: return html for editing the course info handouts and updates.
"""
course_key
=
from_string_or_404
(
course_key_string
)
try
:
course_key
=
CourseKey
.
from_string
(
course_key_string
)
except
InvalidKeyError
:
raise
Http404
with
modulestore
()
.
bulk_operations
(
course_key
):
course_module
=
get_course_and_check_access
(
course_key
,
request
.
user
)
...
...
common/djangoapps/util/course_key_utils.py
deleted
100644 → 0
View file @
a6b9ba7d
"""
Convenience methods for working with course objects
"""
from
django.http
import
Http404
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
def
from_string_or_404
(
course_key_string
):
"""
Gets CourseKey from the string passed as parameter.
Parses course key from string(containing course key) or raises 404 if the string's format is invalid.
Arguments:
course_key_string(str): It is string containing the course key
Returns:
CourseKey: A key that uniquely identifies a course
Raises:
HTTP404: A 404 not found exception will be thrown if course_key_string's format is invalid
"""
try
:
course_key
=
CourseKey
.
from_string
(
course_key_string
)
except
InvalidKeyError
:
raise
Http404
return
course_key
common/djangoapps/util/tests/test_course_key_utils.py
deleted
100644 → 0
View file @
a6b9ba7d
"""
Tests for util.course_key_utils
"""
from
nose.tools
import
assert_equals
,
assert_raises
# pylint: disable=no-name-in-module
from
util.course_key_utils
import
from_string_or_404
from
opaque_keys.edx.keys
import
CourseKey
from
django.http
import
Http404
def
test_from_string_or_404
():
#testing with split style course keys
assert_raises
(
Http404
,
from_string_or_404
,
"/some.invalid.key/course-v1:TTT+CS01+2015_T0"
)
assert_equals
(
CourseKey
.
from_string
(
"course-v1:TTT+CS01+2015_T0"
),
from_string_or_404
(
"course-v1:TTT+CS01+2015_T0"
)
)
#testing with mongo style course keys
assert_raises
(
Http404
,
from_string_or_404
,
"/some.invalid.key/TTT/CS01/2015_T0"
)
assert_equals
(
CourseKey
.
from_string
(
"TTT/CS01/2015_T0"
),
from_string_or_404
(
"TTT/CS01/2015_T0"
)
)
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