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
c7bf96f0
Commit
c7bf96f0
authored
May 22, 2014
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3822 from edx/sarina/course-modes-display
Sarina/course modes display
parents
253ed3b8
1223c8a0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
23 deletions
+68
-23
common/djangoapps/course_modes/admin.py
+33
-1
common/djangoapps/course_modes/models.py
+1
-1
common/djangoapps/embargo/forms.py
+8
-14
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+5
-1
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+10
-0
lms/djangoapps/bulk_email/forms.py
+11
-6
No files found.
common/djangoapps/course_modes/admin.py
View file @
c7bf96f0
from
ratelimitbackend
import
admin
from
ratelimitbackend
import
admin
from
course_modes.models
import
CourseMode
from
course_modes.models
import
CourseMode
from
django
import
forms
admin
.
site
.
register
(
CourseMode
)
from
opaque_keys
import
InvalidKeyError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.keys
import
CourseKey
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
class
CourseModeForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
CourseMode
def
clean_course_id
(
self
):
course_id
=
self
.
cleaned_data
[
'course_id'
]
try
:
course_key
=
CourseKey
.
from_string
(
course_id
)
except
InvalidKeyError
:
try
:
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
except
InvalidKeyError
:
raise
forms
.
ValidationError
(
"Cannot make a valid CourseKey from id {}!"
.
format
(
course_id
))
if
not
modulestore
()
.
has_course
(
course_key
):
raise
forms
.
ValidationError
(
"Cannot find course with id {} in the modulestore"
.
format
(
course_id
))
return
course_key
class
CourseModeAdmin
(
admin
.
ModelAdmin
):
form
=
CourseModeForm
admin
.
site
.
register
(
CourseMode
,
CourseModeAdmin
)
common/djangoapps/course_modes/models.py
View file @
c7bf96f0
...
@@ -126,5 +126,5 @@ class CourseMode(models.Model):
...
@@ -126,5 +126,5 @@ class CourseMode(models.Model):
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
u"{} : {}, min={}, prices={}"
.
format
(
return
u"{} : {}, min={}, prices={}"
.
format
(
self
.
course_id
,
self
.
mode_slug
,
self
.
min_price
,
self
.
suggested_prices
self
.
course_id
.
to_deprecated_string
()
,
self
.
mode_slug
,
self
.
min_price
,
self
.
suggested_prices
)
)
common/djangoapps/embargo/forms.py
View file @
c7bf96f0
...
@@ -11,6 +11,7 @@ import socket
...
@@ -11,6 +11,7 @@ import socket
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
opaque_keys
import
InvalidKeyError
from
opaque_keys
import
InvalidKeyError
from
xmodule.modulestore.keys
import
CourseKey
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
...
@@ -24,31 +25,24 @@ class EmbargoedCourseForm(forms.ModelForm): # pylint: disable=incomplete-protoc
...
@@ -24,31 +25,24 @@ class EmbargoedCourseForm(forms.ModelForm): # pylint: disable=incomplete-protoc
"""Validate the course id"""
"""Validate the course id"""
cleaned_id
=
self
.
cleaned_data
[
"course_id"
]
cleaned_id
=
self
.
cleaned_data
[
"course_id"
]
try
:
try
:
course_id
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
cleaned_id
)
course_key
=
CourseKey
.
from_string
(
cleaned_id
)
except
InvalidKeyError
:
try
:
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
cleaned_id
)
except
InvalidKeyError
:
except
InvalidKeyError
:
msg
=
'COURSE NOT FOUND'
msg
=
'COURSE NOT FOUND'
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
cleaned_id
)
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
cleaned_id
)
msg
+=
'Please recheck that you have supplied a valid course id.'
msg
+=
'Please recheck that you have supplied a valid course id.'
raise
forms
.
ValidationError
(
msg
)
raise
forms
.
ValidationError
(
msg
)
# Try to get the course. If this returns None, it's not a real course
if
not
modulestore
()
.
has_course
(
course_key
):
try
:
course
=
modulestore
()
.
get_course
(
course_id
)
except
ValueError
:
msg
=
'COURSE NOT FOUND'
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
course_id
.
to_deprecated_string
())
msg
+=
'Please recheck that you have supplied a valid course id.'
raise
forms
.
ValidationError
(
msg
)
if
not
course
:
msg
=
'COURSE NOT FOUND'
msg
=
'COURSE NOT FOUND'
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
course_
id
.
to_deprecated_string
())
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
course_
key
.
to_deprecated_string
())
msg
+=
'Please recheck that you have supplied a valid course id.'
msg
+=
'Please recheck that you have supplied a valid course id.'
raise
forms
.
ValidationError
(
msg
)
raise
forms
.
ValidationError
(
msg
)
return
course_
id
return
course_
key
class
EmbargoedStateForm
(
forms
.
ModelForm
):
# pylint: disable=incomplete-protocol
class
EmbargoedStateForm
(
forms
.
ModelForm
):
# pylint: disable=incomplete-protocol
...
...
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
c7bf96f0
...
@@ -608,10 +608,14 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -608,10 +608,14 @@ class MongoModuleStore(ModuleStoreWriteBase):
otherwise, do a case sensitive search
otherwise, do a case sensitive search
"""
"""
assert
(
isinstance
(
course_key
,
SlashSeparatedCourseKey
))
assert
(
isinstance
(
course_key
,
SlashSeparatedCourseKey
))
course_query
=
self
.
_course_key_to_son
(
course_key
)
location
=
course_key
.
make_usage_key
(
'course'
,
course_key
.
run
)
if
ignore_case
:
if
ignore_case
:
course_query
=
location
.
to_deprecated_son
(
'_id.'
)
for
key
in
course_query
.
iterkeys
():
for
key
in
course_query
.
iterkeys
():
if
isinstance
(
course_query
[
key
],
basestring
):
course_query
[
key
]
=
re
.
compile
(
r"(?i)^{}$"
.
format
(
course_query
[
key
]))
course_query
[
key
]
=
re
.
compile
(
r"(?i)^{}$"
.
format
(
course_query
[
key
]))
else
:
course_query
=
{
'_id'
:
location
.
to_deprecated_son
()}
return
self
.
collection
.
find_one
(
course_query
,
fields
=
{
'_id'
:
True
})
is
not
None
return
self
.
collection
.
find_one
(
course_query
,
fields
=
{
'_id'
:
True
})
is
not
None
def
has_item
(
self
,
usage_key
):
def
has_item
(
self
,
usage_key
):
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
c7bf96f0
...
@@ -15,6 +15,7 @@ from xmodule.errortracker import make_error_tracker
...
@@ -15,6 +15,7 @@ from xmodule.errortracker import make_error_tracker
from
.store_utilities
import
rewrite_nonportable_content_links
from
.store_utilities
import
rewrite_nonportable_content_links
import
xblock
import
xblock
from
xmodule.tabs
import
CourseTabList
from
xmodule.tabs
import
CourseTabList
from
xmodule.modulestore.exceptions
import
InvalidLocationError
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -165,6 +166,7 @@ def import_from_xml(
...
@@ -165,6 +166,7 @@ def import_from_xml(
dest_course_id
=
course_key
dest_course_id
=
course_key
if
create_new_course
:
if
create_new_course
:
# this tests if exactly this course (ignoring case) exists; so, it checks the run
if
store
.
has_course
(
dest_course_id
,
ignore_case
=
True
):
if
store
.
has_course
(
dest_course_id
,
ignore_case
=
True
):
log
.
debug
(
log
.
debug
(
"Skipping import of course with id, {0},"
"Skipping import of course with id, {0},"
...
@@ -172,7 +174,15 @@ def import_from_xml(
...
@@ -172,7 +174,15 @@ def import_from_xml(
)
)
continue
continue
else
:
else
:
try
:
store
.
create_course
(
dest_course_id
.
org
,
dest_course_id
.
offering
)
store
.
create_course
(
dest_course_id
.
org
,
dest_course_id
.
offering
)
except
InvalidLocationError
:
# course w/ same org and course exists and store is old mongo
log
.
debug
(
"Skipping import of course with id, {0},"
"since it collides with an existing one"
.
format
(
dest_course_id
)
)
continue
try
:
try
:
# turn off all write signalling while importing as this
# turn off all write signalling while importing as this
...
...
lms/djangoapps/bulk_email/forms.py
View file @
c7bf96f0
...
@@ -11,6 +11,8 @@ from bulk_email.models import CourseEmailTemplate, COURSE_EMAIL_MESSAGE_BODY_TAG
...
@@ -11,6 +11,8 @@ from bulk_email.models import CourseEmailTemplate, COURSE_EMAIL_MESSAGE_BODY_TAG
from
opaque_keys
import
InvalidKeyError
from
opaque_keys
import
InvalidKeyError
from
xmodule.modulestore
import
XML_MODULESTORE_TYPE
from
xmodule.modulestore
import
XML_MODULESTORE_TYPE
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
opaque_keys
import
InvalidKeyError
from
xmodule.modulestore.keys
import
CourseKey
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.locations
import
SlashSeparatedCourseKey
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -60,24 +62,27 @@ class CourseAuthorizationAdminForm(forms.ModelForm): # pylint: disable=R0924
...
@@ -60,24 +62,27 @@ class CourseAuthorizationAdminForm(forms.ModelForm): # pylint: disable=R0924
"""Validate the course id"""
"""Validate the course id"""
cleaned_id
=
self
.
cleaned_data
[
"course_id"
]
cleaned_id
=
self
.
cleaned_data
[
"course_id"
]
try
:
try
:
course_id
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
cleaned_id
)
course_key
=
CourseKey
.
from_string
(
cleaned_id
)
except
InvalidKeyError
:
try
:
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
cleaned_id
)
except
InvalidKeyError
:
except
InvalidKeyError
:
msg
=
u'Course id invalid.'
msg
=
u'Course id invalid.'
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
cleaned_id
)
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
cleaned_id
)
msg
+=
'Please recheck that you have supplied a valid course id.'
msg
+=
'Please recheck that you have supplied a valid course id.'
raise
forms
.
ValidationError
(
msg
)
raise
forms
.
ValidationError
(
msg
)
if
not
modulestore
()
.
has_course
(
course_
id
):
if
not
modulestore
()
.
has_course
(
course_
key
):
msg
=
u'COURSE NOT FOUND'
msg
=
u'COURSE NOT FOUND'
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
course_
id
.
to_deprecated_string
())
msg
+=
u' --- Entered course id was: "{0}". '
.
format
(
course_
key
.
to_deprecated_string
())
msg
+=
'Please recheck that you have supplied a valid course id.'
msg
+=
'Please recheck that you have supplied a valid course id.'
raise
forms
.
ValidationError
(
msg
)
raise
forms
.
ValidationError
(
msg
)
# Now, try and discern if it is a Studio course - HTML editor doesn't work with XML courses
# Now, try and discern if it is a Studio course - HTML editor doesn't work with XML courses
is_studio_course
=
modulestore
()
.
get_modulestore_type
(
course_
id
)
!=
XML_MODULESTORE_TYPE
is_studio_course
=
modulestore
()
.
get_modulestore_type
(
course_
key
)
!=
XML_MODULESTORE_TYPE
if
not
is_studio_course
:
if
not
is_studio_course
:
msg
=
"Course Email feature is only available for courses authored in Studio. "
msg
=
"Course Email feature is only available for courses authored in Studio. "
msg
+=
'"{0}" appears to be an XML backed course.'
.
format
(
course_
id
.
to_deprecated_string
())
msg
+=
'"{0}" appears to be an XML backed course.'
.
format
(
course_
key
.
to_deprecated_string
())
raise
forms
.
ValidationError
(
msg
)
raise
forms
.
ValidationError
(
msg
)
return
course_
id
.
to_deprecated_string
()
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