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
91c8df9b
Commit
91c8df9b
authored
Feb 24, 2014
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2659 from edx/ned/more-pervasive-date-l10n
Make the i18n service available everywhere.
parents
0b2267df
28e9ae04
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
166 additions
and
43 deletions
+166
-43
cms/djangoapps/contentstore/views/preview.py
+4
-1
common/djangoapps/util/tests/test_date_utils.py
+11
-8
common/lib/xmodule/xmodule/course_module.py
+1
-1
common/lib/xmodule/xmodule/modulestore/django.py
+35
-2
common/lib/xmodule/xmodule/modulestore/mixed.py
+3
-2
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+13
-0
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+7
-0
common/lib/xmodule/xmodule/modulestore/xml.py
+11
-2
conf/locale/eo/LC_MESSAGES/django.po
+1
-1
conf/locale/eo/LC_MESSAGES/djangojs.po
+2
-2
lms/djangoapps/courseware/module_render.py
+1
-20
lms/djangoapps/courseware/tests/test_views.py
+61
-3
lms/djangoapps/open_ended_grading/open_ended_notifications.py
+8
-0
lms/djangoapps/open_ended_grading/staff_grading_service.py
+4
-0
lms/djangoapps/open_ended_grading/utils.py
+4
-1
No files found.
cms/djangoapps/contentstore/views/preview.py
View file @
91c8df9b
...
@@ -11,7 +11,7 @@ from edxmako.shortcuts import render_to_string
...
@@ -11,7 +11,7 @@ from edxmako.shortcuts import render_to_string
from
xmodule_modifiers
import
replace_static_urls
,
wrap_xblock
from
xmodule_modifiers
import
replace_static_urls
,
wrap_xblock
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.exceptions
import
NotFoundError
,
ProcessingError
from
xmodule.exceptions
import
NotFoundError
,
ProcessingError
from
xmodule.modulestore.django
import
modulestore
,
loc_mapper
from
xmodule.modulestore.django
import
modulestore
,
loc_mapper
,
ModuleI18nService
from
xmodule.modulestore.locator
import
Locator
from
xmodule.modulestore.locator
import
Locator
from
xmodule.x_module
import
ModuleSystem
from
xmodule.x_module
import
ModuleSystem
from
xblock.runtime
import
KvsFieldData
from
xblock.runtime
import
KvsFieldData
...
@@ -132,6 +132,9 @@ def _preview_module_system(request, descriptor):
...
@@ -132,6 +132,9 @@ def _preview_module_system(request, descriptor):
# If descriptor.location is a CourseLocator, course_id is unused.
# If descriptor.location is a CourseLocator, course_id is unused.
get_user_role
=
lambda
:
get_user_role
(
request
.
user
,
descriptor
.
location
,
course_id
),
get_user_role
=
lambda
:
get_user_role
(
request
.
user
,
descriptor
.
location
,
course_id
),
descriptor_runtime
=
descriptor
.
runtime
,
descriptor_runtime
=
descriptor
.
runtime
,
services
=
{
"i18n"
:
ModuleI18nService
(),
},
)
)
...
...
common/djangoapps/util/tests/test_date_utils.py
View file @
91c8df9b
...
@@ -4,7 +4,6 @@ Tests for util.date_utils
...
@@ -4,7 +4,6 @@ Tests for util.date_utils
"""
"""
from
datetime
import
datetime
,
timedelta
,
tzinfo
from
datetime
import
datetime
,
timedelta
,
tzinfo
from
functools
import
partial
import
unittest
import
unittest
import
ddt
import
ddt
...
@@ -118,18 +117,22 @@ def test_almost_same_datetime():
...
@@ -118,18 +117,22 @@ def test_almost_same_datetime():
)
)
def
fake_ugettext
(
t
ext
,
t
ranslations
):
def
fake_ugettext
(
translations
):
"""
"""
A
fake implementation of ugettext, for testing.
Create a
fake implementation of ugettext, for testing.
"""
"""
def
_ugettext
(
text
):
# pylint: disable=missing-docstring
return
translations
.
get
(
text
,
text
)
return
translations
.
get
(
text
,
text
)
return
_ugettext
def
fake_pgettext
(
context
,
text
,
translations
):
def
fake_pgettext
(
translations
):
"""
"""
A
fake implementation of pgettext, for testing.
Create a
fake implementation of pgettext, for testing.
"""
"""
def
_pgettext
(
context
,
text
):
# pylint: disable=missing-docstring
return
translations
.
get
((
context
,
text
),
text
)
return
translations
.
get
((
context
,
text
),
text
)
return
_pgettext
@ddt.ddt
@ddt.ddt
...
@@ -161,7 +164,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
...
@@ -161,7 +164,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
dtime
=
datetime
(
2013
,
02
,
14
,
16
,
41
,
17
)
dtime
=
datetime
(
2013
,
02
,
14
,
16
,
41
,
17
)
self
.
assertEqual
(
expected
,
strftime_localized
(
dtime
,
fmt
))
self
.
assertEqual
(
expected
,
strftime_localized
(
dtime
,
fmt
))
@patch
(
'util.date_utils.pgettext'
,
partial
(
fake_pgettext
,
translations
=
{
@patch
(
'util.date_utils.pgettext'
,
fake_pgettext
(
translations
=
{
(
"abbreviated month name"
,
"Feb"
):
"XXfebXX"
,
(
"abbreviated month name"
,
"Feb"
):
"XXfebXX"
,
(
"month name"
,
"February"
):
"XXfebruaryXX"
,
(
"month name"
,
"February"
):
"XXfebruaryXX"
,
(
"abbreviated weekday name"
,
"Thu"
):
"XXthuXX"
,
(
"abbreviated weekday name"
,
"Thu"
):
"XXthuXX"
,
...
@@ -179,7 +182,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
...
@@ -179,7 +182,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
dtime
=
datetime
(
2013
,
02
,
14
,
16
,
41
,
17
)
dtime
=
datetime
(
2013
,
02
,
14
,
16
,
41
,
17
)
self
.
assertEqual
(
expected
,
strftime_localized
(
dtime
,
fmt
))
self
.
assertEqual
(
expected
,
strftime_localized
(
dtime
,
fmt
))
@patch
(
'util.date_utils.ugettext'
,
partial
(
fake_ugettext
,
translations
=
{
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"date(
%
Y.
%
m.
%
d)"
,
"SHORT_DATE_FORMAT"
:
"date(
%
Y.
%
m.
%
d)"
,
"LONG_DATE_FORMAT"
:
"date(
%
A.
%
Y.
%
B.
%
d)"
,
"LONG_DATE_FORMAT"
:
"date(
%
A.
%
Y.
%
B.
%
d)"
,
"DATE_TIME_FORMAT"
:
"date(
%
Y.
%
m.
%
d@
%
H.
%
M)"
,
"DATE_TIME_FORMAT"
:
"date(
%
Y.
%
m.
%
d@
%
H.
%
M)"
,
...
@@ -198,7 +201,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
...
@@ -198,7 +201,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
dtime
=
datetime
(
2013
,
02
,
14
,
16
,
41
,
17
)
dtime
=
datetime
(
2013
,
02
,
14
,
16
,
41
,
17
)
self
.
assertEqual
(
expected
,
strftime_localized
(
dtime
,
fmt
))
self
.
assertEqual
(
expected
,
strftime_localized
(
dtime
,
fmt
))
@patch
(
'util.date_utils.ugettext'
,
partial
(
fake_ugettext
,
translations
=
{
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"oops date(
%
Y.
%
x.
%
d)"
,
"SHORT_DATE_FORMAT"
:
"oops date(
%
Y.
%
x.
%
d)"
,
"TIME_FORMAT"
:
"oops
%
Hh.
%
Xm.
%
Ss"
,
"TIME_FORMAT"
:
"oops
%
Hh.
%
Xm.
%
Ss"
,
}))
}))
...
...
common/lib/xmodule/xmodule/course_module.py
View file @
91c8df9b
...
@@ -408,7 +408,7 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
...
@@ -408,7 +408,7 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
# set the due_date_display_format to what would have been shown previously (with no timezone).
# set the due_date_display_format to what would have been shown previously (with no timezone).
# Then remove show_timezone so that if the user clears out the due_date_display_format,
# Then remove show_timezone so that if the user clears out the due_date_display_format,
# they get the default date display.
# they get the default date display.
self
.
due_date_display_format
=
u"
%
b
%
d,
%
Y at
%
H:
%
M
"
self
.
due_date_display_format
=
"DATE_TIME
"
delattr
(
self
,
'show_timezone'
)
delattr
(
self
,
'show_timezone'
)
# NOTE: relies on the modulestore to call set_grading_policy() right after
# NOTE: relies on the modulestore to call set_grading_policy() right after
...
...
common/lib/xmodule/xmodule/modulestore/django.py
View file @
91c8df9b
...
@@ -6,15 +6,17 @@ Passes settings.MODULESTORE as kwargs to MongoModuleStore
...
@@ -6,15 +6,17 @@ Passes settings.MODULESTORE as kwargs to MongoModuleStore
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
importlib
import
import_module
from
importlib
import
import_module
import
re
import
re
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.cache
import
get_cache
,
InvalidCacheBackendError
from
django.core.cache
import
get_cache
,
InvalidCacheBackendError
from
django.dispatch
import
Signal
from
django.dispatch
import
Signal
import
django.utils
from
xmodule.modulestore.loc_mapper_store
import
LocMapperStore
from
xmodule.modulestore.loc_mapper_store
import
LocMapperStore
from
xmodule.util.django
import
get_current_request_hostname
from
xmodule.util.django
import
get_current_request_hostname
# We may not always have the request_cache module available
# We may not always have the request_cache module available
try
:
try
:
from
request_cache.middleware
import
RequestCache
from
request_cache.middleware
import
RequestCache
...
@@ -38,7 +40,7 @@ def load_function(path):
...
@@ -38,7 +40,7 @@ def load_function(path):
return
getattr
(
import_module
(
module_path
),
name
)
return
getattr
(
import_module
(
module_path
),
name
)
def
create_modulestore_instance
(
engine
,
doc_store_config
,
options
):
def
create_modulestore_instance
(
engine
,
doc_store_config
,
options
,
i18n_service
=
None
):
"""
"""
This will return a new instance of a modulestore given an engine and options
This will return a new instance of a modulestore given an engine and options
"""
"""
...
@@ -68,6 +70,7 @@ def create_modulestore_instance(engine, doc_store_config, options):
...
@@ -68,6 +70,7 @@ def create_modulestore_instance(engine, doc_store_config, options):
xblock_mixins
=
getattr
(
settings
,
'XBLOCK_MIXINS'
,
()),
xblock_mixins
=
getattr
(
settings
,
'XBLOCK_MIXINS'
,
()),
xblock_select
=
getattr
(
settings
,
'XBLOCK_SELECT_FUNCTION'
,
None
),
xblock_select
=
getattr
(
settings
,
'XBLOCK_SELECT_FUNCTION'
,
None
),
doc_store_config
=
doc_store_config
,
doc_store_config
=
doc_store_config
,
i18n_service
=
i18n_service
or
ModuleI18nService
(),
**
_options
**
_options
)
)
...
@@ -186,3 +189,33 @@ def editable_modulestore(name='default'):
...
@@ -186,3 +189,33 @@ def editable_modulestore(name='default'):
else
:
else
:
return
None
return
None
class
ModuleI18nService
(
object
):
"""
Implement the XBlock runtime "i18n" service.
Mostly a pass-through to Django's translation module.
django.utils.translation implements the gettext.Translations interface (it
has ugettext, ungettext, etc), so we can use it directly as the runtime
i18n service.
"""
def
__getattr__
(
self
,
name
):
return
getattr
(
django
.
utils
.
translation
,
name
)
def
strftime
(
self
,
*
args
,
**
kwargs
):
"""
A locale-aware implementation of strftime.
"""
# This is the wrong place to import this function. I'm putting it here
# because the xmodule test suite can't import this module, because
# Django is not available in that suite. This function isn't called in
# that suite, so this hides the import so the test won't fail.
#
# As I said, this is wrong. But Cale says this code will soon be
# refactored to a place that will be right, and the code can be made
# right there. If you are reading this comment after April 1, 2014,
# then Cale was a liar.
from
util.date_utils
import
strftime_localized
return
strftime_localized
(
*
args
,
**
kwargs
)
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
91c8df9b
...
@@ -23,7 +23,7 @@ class MixedModuleStore(ModuleStoreWriteBase):
...
@@ -23,7 +23,7 @@ class MixedModuleStore(ModuleStoreWriteBase):
ModuleStore knows how to route requests to the right persistence ms and how to convert any
ModuleStore knows how to route requests to the right persistence ms and how to convert any
references in the xblocks to the type required by the app and the persistence layer.
references in the xblocks to the type required by the app and the persistence layer.
"""
"""
def
__init__
(
self
,
mappings
,
stores
,
reference_type
=
None
,
**
kwargs
):
def
__init__
(
self
,
mappings
,
stores
,
reference_type
=
None
,
i18n_service
=
None
,
**
kwargs
):
"""
"""
Initialize a MixedModuleStore. Here we look into our passed in kwargs which should be a
Initialize a MixedModuleStore. Here we look into our passed in kwargs which should be a
collection of other modulestore configuration informations
collection of other modulestore configuration informations
...
@@ -55,7 +55,8 @@ class MixedModuleStore(ModuleStoreWriteBase):
...
@@ -55,7 +55,8 @@ class MixedModuleStore(ModuleStoreWriteBase):
store
[
'ENGINE'
],
store
[
'ENGINE'
],
# XMLModuleStore's don't have doc store configs
# XMLModuleStore's don't have doc store configs
store
.
get
(
'DOC_STORE_CONFIG'
,
{}),
store
.
get
(
'DOC_STORE_CONFIG'
,
{}),
store
[
'OPTIONS'
]
store
[
'OPTIONS'
],
i18n_service
=
i18n_service
,
)
)
def
_get_modulestore_for_courseid
(
self
,
course_id
):
def
_get_modulestore_for_courseid
(
self
,
course_id
):
...
...
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
91c8df9b
...
@@ -263,6 +263,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -263,6 +263,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
def
__init__
(
self
,
doc_store_config
,
fs_root
,
render_template
,
def
__init__
(
self
,
doc_store_config
,
fs_root
,
render_template
,
default_class
=
None
,
default_class
=
None
,
error_tracker
=
null_error_tracker
,
error_tracker
=
null_error_tracker
,
i18n_service
=
None
,
**
kwargs
):
**
kwargs
):
"""
"""
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
...
@@ -312,6 +313,8 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -312,6 +313,8 @@ class MongoModuleStore(ModuleStoreWriteBase):
self
.
fs_root
=
path
(
fs_root
)
self
.
fs_root
=
path
(
fs_root
)
self
.
error_tracker
=
error_tracker
self
.
error_tracker
=
error_tracker
self
.
render_template
=
render_template
self
.
render_template
=
render_template
self
.
i18n_service
=
i18n_service
self
.
ignore_write_events_on_courses
=
[]
self
.
ignore_write_events_on_courses
=
[]
def
compute_metadata_inheritance_tree
(
self
,
location
):
def
compute_metadata_inheritance_tree
(
self
,
location
):
...
@@ -498,6 +501,10 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -498,6 +501,10 @@ class MongoModuleStore(ModuleStoreWriteBase):
if
apply_cached_metadata
:
if
apply_cached_metadata
:
cached_metadata
=
self
.
get_cached_metadata_inheritance_tree
(
location
)
cached_metadata
=
self
.
get_cached_metadata_inheritance_tree
(
location
)
services
=
{}
if
self
.
i18n_service
:
services
[
"i18n"
]
=
self
.
i18n_service
# TODO (cdodge): When the 'split module store' work has been completed, we should remove
# TODO (cdodge): When the 'split module store' work has been completed, we should remove
# the 'metadata_inheritance_tree' parameter
# the 'metadata_inheritance_tree' parameter
system
=
CachingDescriptorSystem
(
system
=
CachingDescriptorSystem
(
...
@@ -510,6 +517,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -510,6 +517,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
cached_metadata
=
cached_metadata
,
cached_metadata
=
cached_metadata
,
mixins
=
self
.
xblock_mixins
,
mixins
=
self
.
xblock_mixins
,
select
=
self
.
xblock_select
,
select
=
self
.
xblock_select
,
services
=
services
,
)
)
return
system
.
load_item
(
location
)
return
system
.
load_item
(
location
)
...
@@ -631,6 +639,10 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -631,6 +639,10 @@ class MongoModuleStore(ModuleStoreWriteBase):
if
metadata
is
None
:
if
metadata
is
None
:
metadata
=
{}
metadata
=
{}
if
system
is
None
:
if
system
is
None
:
services
=
{}
if
self
.
i18n_service
:
services
[
"i18n"
]
=
self
.
i18n_service
system
=
CachingDescriptorSystem
(
system
=
CachingDescriptorSystem
(
modulestore
=
self
,
modulestore
=
self
,
module_data
=
{},
module_data
=
{},
...
@@ -641,6 +653,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
...
@@ -641,6 +653,7 @@ class MongoModuleStore(ModuleStoreWriteBase):
cached_metadata
=
{},
cached_metadata
=
{},
mixins
=
self
.
xblock_mixins
,
mixins
=
self
.
xblock_mixins
,
select
=
self
.
xblock_select
,
select
=
self
.
xblock_select
,
services
=
services
,
)
)
xblock_class
=
system
.
load_block_type
(
location
.
category
)
xblock_class
=
system
.
load_block_type
(
location
.
category
)
if
definition_data
is
None
:
if
definition_data
is
None
:
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
91c8df9b
...
@@ -105,6 +105,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -105,6 +105,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
default_class
=
None
,
default_class
=
None
,
error_tracker
=
null_error_tracker
,
error_tracker
=
null_error_tracker
,
loc_mapper
=
None
,
loc_mapper
=
None
,
i18n_service
=
None
,
**
kwargs
):
**
kwargs
):
"""
"""
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
...
@@ -129,6 +130,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -129,6 +130,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
self
.
fs_root
=
path
(
fs_root
)
self
.
fs_root
=
path
(
fs_root
)
self
.
error_tracker
=
error_tracker
self
.
error_tracker
=
error_tracker
self
.
render_template
=
render_template
self
.
render_template
=
render_template
self
.
i18n_service
=
i18n_service
# TODO: Don't have a runtime just to generate the appropriate mixin classes (cpennington)
# TODO: Don't have a runtime just to generate the appropriate mixin classes (cpennington)
# This is only used by _partition_fields_by_scope, which is only needed because
# This is only used by _partition_fields_by_scope, which is only needed because
...
@@ -180,6 +182,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -180,6 +182,10 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
'''
'''
system
=
self
.
_get_cache
(
course_entry
[
'structure'
][
'_id'
])
system
=
self
.
_get_cache
(
course_entry
[
'structure'
][
'_id'
])
if
system
is
None
:
if
system
is
None
:
services
=
{}
if
self
.
i18n_service
:
services
[
"i18n"
]
=
self
.
i18n_service
system
=
CachingDescriptorSystem
(
system
=
CachingDescriptorSystem
(
modulestore
=
self
,
modulestore
=
self
,
course_entry
=
course_entry
,
course_entry
=
course_entry
,
...
@@ -191,6 +197,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
...
@@ -191,6 +197,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
resources_fs
=
None
,
resources_fs
=
None
,
mixins
=
self
.
xblock_mixins
,
mixins
=
self
.
xblock_mixins
,
select
=
self
.
xblock_select
,
select
=
self
.
xblock_select
,
services
=
services
,
)
)
self
.
_add_cache
(
course_entry
[
'structure'
][
'_id'
],
system
)
self
.
_add_cache
(
course_entry
[
'structure'
][
'_id'
],
system
)
self
.
cache_items
(
system
,
block_ids
,
depth
,
lazy
)
self
.
cache_items
(
system
,
block_ids
,
depth
,
lazy
)
...
...
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
91c8df9b
...
@@ -347,8 +347,10 @@ class XMLModuleStore(ModuleStoreReadBase):
...
@@ -347,8 +347,10 @@ class XMLModuleStore(ModuleStoreReadBase):
"""
"""
An XML backed ModuleStore
An XML backed ModuleStore
"""
"""
def
__init__
(
self
,
data_dir
,
default_class
=
None
,
course_dirs
=
None
,
course_ids
=
None
,
def
__init__
(
load_error_modules
=
True
,
**
kwargs
):
self
,
data_dir
,
default_class
=
None
,
course_dirs
=
None
,
course_ids
=
None
,
load_error_modules
=
True
,
i18n_service
=
None
,
**
kwargs
):
"""
"""
Initialize an XMLModuleStore from data_dir
Initialize an XMLModuleStore from data_dir
...
@@ -382,6 +384,8 @@ class XMLModuleStore(ModuleStoreReadBase):
...
@@ -382,6 +384,8 @@ class XMLModuleStore(ModuleStoreReadBase):
# All field data will be stored in an inheriting field data.
# All field data will be stored in an inheriting field data.
self
.
field_data
=
inheriting_field_data
(
kvs
=
DictKeyValueStore
())
self
.
field_data
=
inheriting_field_data
(
kvs
=
DictKeyValueStore
())
self
.
i18n_service
=
i18n_service
# If we are specifically asked for missing courses, that should
# If we are specifically asked for missing courses, that should
# be an error. If we are asked for "all" courses, find the ones
# be an error. If we are asked for "all" courses, find the ones
# that have a course.xml. We sort the dirs in alpha order so we always
# that have a course.xml. We sort the dirs in alpha order so we always
...
@@ -522,6 +526,10 @@ class XMLModuleStore(ModuleStoreReadBase):
...
@@ -522,6 +526,10 @@ class XMLModuleStore(ModuleStoreReadBase):
"""
"""
return
policy
.
get
(
policy_key
(
usage_id
),
{})
return
policy
.
get
(
policy_key
(
usage_id
),
{})
services
=
{}
if
self
.
i18n_service
:
services
[
'i18n'
]
=
self
.
i18n_service
system
=
ImportSystem
(
system
=
ImportSystem
(
xmlstore
=
self
,
xmlstore
=
self
,
course_id
=
course_id
,
course_id
=
course_id
,
...
@@ -534,6 +542,7 @@ class XMLModuleStore(ModuleStoreReadBase):
...
@@ -534,6 +542,7 @@ class XMLModuleStore(ModuleStoreReadBase):
default_class
=
self
.
default_class
,
default_class
=
self
.
default_class
,
select
=
self
.
xblock_select
,
select
=
self
.
xblock_select
,
field_data
=
self
.
field_data
,
field_data
=
self
.
field_data
,
services
=
services
,
)
)
course_descriptor
=
system
.
process_xml
(
etree
.
tostring
(
course_data
,
encoding
=
'unicode'
))
course_descriptor
=
system
.
process_xml
(
etree
.
tostring
(
course_data
,
encoding
=
'unicode'
))
...
...
conf/locale/eo/LC_MESSAGES/django.po
View file @
91c8df9b
...
@@ -37,7 +37,7 @@ msgid ""
...
@@ -37,7 +37,7 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2014-02-
19 15:39
-0500\n"
"POT-Creation-Date: 2014-02-
20 13:02
-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
conf/locale/eo/LC_MESSAGES/djangojs.po
View file @
91c8df9b
...
@@ -7,8 +7,8 @@ msgid ""
...
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: 0.1a\n"
"Project-Id-Version: 0.1a\n"
"Report-Msgid-Bugs-To: openedx-translation@googlegroups.com\n"
"Report-Msgid-Bugs-To: openedx-translation@googlegroups.com\n"
"POT-Creation-Date: 2014-02-
19 15:38
-0500\n"
"POT-Creation-Date: 2014-02-
20 13:01
-0500\n"
"PO-Revision-Date: 2014-02-
19 20:39:50.876422
\n"
"PO-Revision-Date: 2014-02-
20 18:02:05.375610
\n"
"Last-Translator: \n"
"Last-Translator: \n"
"Language-Team: openedx-translation <openedx-translation@googlegroups.com>\n"
"Language-Team: openedx-translation <openedx-translation@googlegroups.com>\n"
"MIME-Version: 1.0\n"
"MIME-Version: 1.0\n"
...
...
lms/djangoapps/courseware/module_render.py
View file @
91c8df9b
...
@@ -13,7 +13,6 @@ from django.core.cache import cache
...
@@ -13,7 +13,6 @@ from django.core.cache import cache
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
,
HttpResponse
from
django.http
import
Http404
,
HttpResponse
import
django.utils
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.csrf
import
csrf_exempt
from
capa.xqueue_interface
import
XQueueInterface
from
capa.xqueue_interface
import
XQueueInterface
...
@@ -33,14 +32,13 @@ from xblock.django.request import django_to_webob_request, webob_to_django_respo
...
@@ -33,14 +32,13 @@ from xblock.django.request import django_to_webob_request, webob_to_django_respo
from
xmodule.error_module
import
ErrorDescriptor
,
NonStaffErrorDescriptor
from
xmodule.error_module
import
ErrorDescriptor
,
NonStaffErrorDescriptor
from
xmodule.exceptions
import
NotFoundError
,
ProcessingError
from
xmodule.exceptions
import
NotFoundError
,
ProcessingError
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
,
ModuleI18nService
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.util.duedate
import
get_extended_due_date
from
xmodule.util.duedate
import
get_extended_due_date
from
xmodule_modifiers
import
replace_course_urls
,
replace_jump_to_id_urls
,
replace_static_urls
,
add_staff_debug_info
,
wrap_xblock
from
xmodule_modifiers
import
replace_course_urls
,
replace_jump_to_id_urls
,
replace_static_urls
,
add_staff_debug_info
,
wrap_xblock
from
xmodule.lti_module
import
LTIModule
from
xmodule.lti_module
import
LTIModule
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.x_module
import
XModuleDescriptor
from
util.date_utils
import
strftime_localized
from
util.json_request
import
JsonResponse
from
util.json_request
import
JsonResponse
from
util.sandboxing
import
can_execute_unsafe_code
from
util.sandboxing
import
can_execute_unsafe_code
...
@@ -651,20 +649,3 @@ def _check_files_limits(files):
...
@@ -651,20 +649,3 @@ def _check_files_limits(files):
return
msg
return
msg
return
None
return
None
class
ModuleI18nService
(
object
):
"""
Implement the XBlock runtime "i18n" service.
Mostly a pass-through to Django's translation module.
django.utils.translation implements the gettext.Translations interface (it
has ugettext, ungettext, etc), so we can use it directly as the runtime
i18n service.
"""
def
__getattr__
(
self
,
name
):
return
getattr
(
django
.
utils
.
translation
,
name
)
def
strftime
(
self
,
*
args
,
**
kwargs
):
return
strftime_localized
(
*
args
,
**
kwargs
)
lms/djangoapps/courseware/tests/test_views.py
View file @
91c8df9b
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
Tests courseware views.py
Tests courseware views.py
"""
"""
import
unittest
import
unittest
from
mock
import
MagicMock
,
patch
from
datetime
import
datetime
from
datetime
import
datetime
from
mock
import
MagicMock
,
patch
from
pytz
import
UTC
from
pytz
import
UTC
from
django.test
import
TestCase
from
django.test
import
TestCase
...
@@ -30,6 +31,8 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
...
@@ -30,6 +31,8 @@ from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
from
course_modes.models
import
CourseMode
from
course_modes.models
import
CourseMode
import
shoppingcart
import
shoppingcart
from
util.tests.test_date_utils
import
fake_ugettext
,
fake_pgettext
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
TestJumpTo
(
TestCase
):
class
TestJumpTo
(
TestCase
):
...
@@ -38,7 +41,6 @@ class TestJumpTo(TestCase):
...
@@ -38,7 +41,6 @@ class TestJumpTo(TestCase):
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
# Use toy course from XML
# Use toy course from XML
self
.
course_name
=
'edX/toy/2012_Fall'
self
.
course_name
=
'edX/toy/2012_Fall'
...
@@ -71,7 +73,9 @@ class TestJumpTo(TestCase):
...
@@ -71,7 +73,9 @@ class TestJumpTo(TestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
ViewsTestCase
(
TestCase
):
class
ViewsTestCase
(
TestCase
):
""" Tests for views.py methods. """
"""
Tests for views.py methods.
"""
def
setUp
(
self
):
def
setUp
(
self
):
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
email
=
'test@mit.edu'
)
email
=
'test@mit.edu'
)
...
@@ -366,3 +370,57 @@ class TestAccordionDueDate(BaseDueDateTests):
...
@@ -366,3 +370,57 @@ class TestAccordionDueDate(BaseDueDateTests):
return
views
.
render_accordion
(
return
views
.
render_accordion
(
self
.
request
,
course
,
course
.
get_children
()[
0
]
.
id
,
None
,
None
self
.
request
,
course
,
course
.
get_children
()[
0
]
.
id
,
None
,
None
)
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
StartDateTests
(
ModuleStoreTestCase
):
"""
Test that start dates are properly localized and displayed on the student
dashboard.
"""
def
setUp
(
self
):
self
.
request_factory
=
RequestFactory
()
self
.
user
=
UserFactory
.
create
()
self
.
request
=
self
.
request_factory
.
get
(
"foo"
)
self
.
request
.
user
=
self
.
user
def
set_up_course
(
self
):
"""
Create a stock course with a specific due date.
:param course_kwargs: All kwargs are passed to through to the :class:`CourseFactory`
"""
course
=
CourseFactory
(
start
=
datetime
(
2013
,
9
,
16
,
7
,
17
,
28
))
course
=
modulestore
()
.
get_instance
(
course
.
id
,
course
.
location
)
# pylint: disable=no-member
return
course
def
get_about_text
(
self
,
course_id
):
"""
Get the text of the /about page for the course.
"""
text
=
views
.
course_about
(
self
.
request
,
course_id
)
.
content
return
text
@patch
(
'util.date_utils.pgettext'
,
fake_pgettext
(
translations
=
{
(
"abbreviated month name"
,
"Sep"
):
"SEPTEMBER"
,
}))
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"
%
Y-
%
b-
%
d"
,
}))
def
test_format_localized_in_studio_course
(
self
):
course
=
self
.
set_up_course
()
text
=
self
.
get_about_text
(
course
.
id
)
# The start date is set in the set_up_course function above.
self
.
assertIn
(
"2013-SEPTEMBER-16"
,
text
)
@patch
(
'util.date_utils.pgettext'
,
fake_pgettext
(
translations
=
{
(
"abbreviated month name"
,
"Jul"
):
"JULY"
,
}))
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"
%
Y-
%
b-
%
d"
,
}))
def
test_format_localized_in_xml_course
(
self
):
text
=
self
.
get_about_text
(
'edX/toy/TT_2012_Fall'
)
# The start date is set in common/test/data/two_toys/policies/TT_2012_Fall/policy.json
self
.
assertIn
(
"2015-JULY-17"
,
text
)
lms/djangoapps/open_ended_grading/open_ended_notifications.py
View file @
91c8df9b
...
@@ -7,6 +7,8 @@ from django.conf import settings
...
@@ -7,6 +7,8 @@ from django.conf import settings
from
xmodule.open_ended_grading_classes
import
peer_grading_service
from
xmodule.open_ended_grading_classes
import
peer_grading_service
from
xmodule.open_ended_grading_classes.controller_query_service
import
ControllerQueryService
from
xmodule.open_ended_grading_classes.controller_query_service
import
ControllerQueryService
from
xmodule.modulestore.django
import
ModuleI18nService
from
courseware.access
import
has_access
from
courseware.access
import
has_access
from
lms.lib.xblock.runtime
import
LmsModuleSystem
from
lms.lib.xblock.runtime
import
LmsModuleSystem
from
edxmako.shortcuts
import
render_to_string
from
edxmako.shortcuts
import
render_to_string
...
@@ -70,6 +72,9 @@ def peer_grading_notifications(course, user):
...
@@ -70,6 +72,9 @@ def peer_grading_notifications(course, user):
render_template
=
render_to_string
,
render_template
=
render_to_string
,
replace_urls
=
None
,
replace_urls
=
None
,
descriptor_runtime
=
None
,
descriptor_runtime
=
None
,
services
=
{
'i18n'
:
ModuleI18nService
(),
},
)
)
peer_gs
=
peer_grading_service
.
PeerGradingService
(
settings
.
OPEN_ENDED_GRADING_INTERFACE
,
system
)
peer_gs
=
peer_grading_service
.
PeerGradingService
(
settings
.
OPEN_ENDED_GRADING_INTERFACE
,
system
)
pending_grading
=
False
pending_grading
=
False
...
@@ -131,6 +136,9 @@ def combined_notifications(course, user):
...
@@ -131,6 +136,9 @@ def combined_notifications(course, user):
render_template
=
render_to_string
,
render_template
=
render_to_string
,
replace_urls
=
None
,
replace_urls
=
None
,
descriptor_runtime
=
None
,
descriptor_runtime
=
None
,
services
=
{
'i18n'
:
ModuleI18nService
(),
},
)
)
#Initialize controller query service using our mock system
#Initialize controller query service using our mock system
controller_qs
=
ControllerQueryService
(
settings
.
OPEN_ENDED_GRADING_INTERFACE
,
system
)
controller_qs
=
ControllerQueryService
(
settings
.
OPEN_ENDED_GRADING_INTERFACE
,
system
)
...
...
lms/djangoapps/open_ended_grading/staff_grading_service.py
View file @
91c8df9b
...
@@ -11,6 +11,7 @@ from django.utils.translation import ugettext as _
...
@@ -11,6 +11,7 @@ from django.utils.translation import ugettext as _
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.open_ended_grading_classes.grading_service_module
import
GradingService
,
GradingServiceError
from
xmodule.open_ended_grading_classes.grading_service_module
import
GradingService
,
GradingServiceError
from
xmodule.modulestore.django
import
ModuleI18nService
from
courseware.access
import
has_access
from
courseware.access
import
has_access
from
lms.lib.xblock.runtime
import
LmsModuleSystem
from
lms.lib.xblock.runtime
import
LmsModuleSystem
...
@@ -84,6 +85,9 @@ class StaffGradingService(GradingService):
...
@@ -84,6 +85,9 @@ class StaffGradingService(GradingService):
render_template
=
render_to_string
,
render_template
=
render_to_string
,
replace_urls
=
None
,
replace_urls
=
None
,
descriptor_runtime
=
None
,
descriptor_runtime
=
None
,
services
=
{
'i18n'
:
ModuleI18nService
(),
},
)
)
super
(
StaffGradingService
,
self
)
.
__init__
(
config
)
super
(
StaffGradingService
,
self
)
.
__init__
(
config
)
self
.
url
=
config
[
'url'
]
+
config
[
'staff_grading'
]
self
.
url
=
config
[
'url'
]
+
config
[
'staff_grading'
]
...
...
lms/djangoapps/open_ended_grading/utils.py
View file @
91c8df9b
...
@@ -2,7 +2,7 @@ import json
...
@@ -2,7 +2,7 @@ import json
import
logging
import
logging
from
xmodule.modulestore
import
search
from
xmodule.modulestore
import
search
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
,
ModuleI18nService
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
NoPathToItem
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
NoPathToItem
from
xmodule.open_ended_grading_classes.controller_query_service
import
ControllerQueryService
from
xmodule.open_ended_grading_classes.controller_query_service
import
ControllerQueryService
from
xmodule.open_ended_grading_classes.grading_service_module
import
GradingServiceError
from
xmodule.open_ended_grading_classes.grading_service_module
import
GradingServiceError
...
@@ -34,6 +34,9 @@ SYSTEM = LmsModuleSystem(
...
@@ -34,6 +34,9 @@ SYSTEM = LmsModuleSystem(
render_template
=
render_to_string
,
render_template
=
render_to_string
,
replace_urls
=
None
,
replace_urls
=
None
,
descriptor_runtime
=
None
,
descriptor_runtime
=
None
,
services
=
{
'i18n'
:
ModuleI18nService
(),
},
)
)
...
...
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