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
c9b472d2
Commit
c9b472d2
authored
Jun 17, 2016
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Model imports down into methods which use the models, since
Django 1.9 no longer allows model imports during app init.
parent
7f2d20cd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
23 deletions
+24
-23
cms/lib/xblock/tagging/tagging.py
+1
-1
common/djangoapps/static_replace/__init__.py
+2
-3
common/djangoapps/xblock_django/user_service.py
+3
-2
common/lib/xmodule/xmodule/modulestore/django.py
+16
-15
openedx/core/djangoapps/content/course_structures/signals.py
+2
-2
No files found.
cms/lib/xblock/tagging/tagging.py
View file @
c9b472d2
...
...
@@ -11,7 +11,6 @@ from xmodule.capa_module import CapaModule
from
edxmako.shortcuts
import
render_to_string
from
django.conf
import
settings
from
webob
import
Response
from
.models
import
TagCategories
_
=
lambda
text
:
text
...
...
@@ -29,6 +28,7 @@ class StructuredTagsAside(XBlockAside):
"""
Return available tags
"""
from
.models
import
TagCategories
return
TagCategories
.
objects
.
all
()
def
_get_studio_resource_url
(
self
,
relative_url
):
...
...
common/djangoapps/static_replace/__init__.py
View file @
c9b472d2
...
...
@@ -5,9 +5,6 @@ from django.contrib.staticfiles.storage import staticfiles_storage
from
django.contrib.staticfiles
import
finders
from
django.conf
import
settings
from
static_replace.models
import
AssetBaseUrlConfig
,
AssetExcludedExtensionsConfig
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.contentstore.content
import
StaticContent
from
opaque_keys.edx.locator
import
AssetLocator
...
...
@@ -177,6 +174,8 @@ def replace_static_urls(text, data_directory=None, course_id=None, static_asset_
if
exists_in_staticfiles_storage
:
url
=
staticfiles_storage
.
url
(
rest
)
else
:
# Import here because models can't be imported at top of module __init__.py.
from
static_replace.models
import
AssetBaseUrlConfig
,
AssetExcludedExtensionsConfig
# if not, then assume it's courseware specific content and then look in the
# Mongo-backed database
base_url
=
AssetBaseUrlConfig
.
get_base_url
()
...
...
common/djangoapps/xblock_django/user_service.py
View file @
c9b472d2
"""
Support for converting a django user to an XBlock user
"""
from
django.contrib.auth.models
import
User
from
opaque_keys.edx.keys
import
CourseKey
from
xblock.reference.user_service
import
XBlockUser
,
UserService
from
xblock.reference.user_service
import
UserService
from
student.models
import
anonymous_id_for_user
,
get_user_by_username_or_email
ATTR_KEY_IS_AUTHENTICATED
=
'edx-platform.is_authenticated'
...
...
@@ -43,6 +42,7 @@ class DjangoXBlockUserService(UserService):
if
not
self
.
get_current_user
()
.
opt_attrs
.
get
(
ATTR_KEY_USER_IS_STAFF
):
return
None
from
django.contrib.auth.models
import
User
try
:
user
=
get_user_by_username_or_email
(
username_or_email
=
username
)
except
User
.
DoesNotExist
:
...
...
@@ -55,6 +55,7 @@ class DjangoXBlockUserService(UserService):
"""
A function that returns an XBlockUser from the current Django request.user
"""
from
xblock.reference.user_service
import
XBlockUser
xblock_user
=
XBlockUser
(
is_current_user
=
True
)
if
django_user
is
not
None
and
django_user
.
is_authenticated
():
...
...
common/lib/xmodule/xmodule/modulestore/django.py
View file @
c9b472d2
...
...
@@ -29,7 +29,6 @@ from xmodule.contentstore.django import contentstore
from
xmodule.modulestore.draft_and_published
import
BranchSettingMixin
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.util.django
import
get_current_request_hostname
import
xblock.reference.plugins
try
:
# We may not always have the request_cache module available
...
...
@@ -39,20 +38,6 @@ try:
except
ImportError
:
HAS_REQUEST_CACHE
=
False
# We also may not always have the current request user (crum) module available
try
:
from
xblock_django.user_service
import
DjangoXBlockUserService
from
crum
import
get_current_user
HAS_USER_SERVICE
=
True
except
ImportError
:
HAS_USER_SERVICE
=
False
try
:
from
xblock_django.models
import
XBlockDisableConfig
except
ImportError
:
XBlockDisableConfig
=
None
log
=
logging
.
getLogger
(
__name__
)
ASSET_IGNORE_REGEX
=
getattr
(
settings
,
"ASSET_IGNORE_REGEX"
,
r"(^\._.*$)|(^\.DS_Store$)|(^.*~$)"
)
...
...
@@ -180,6 +165,15 @@ def create_modulestore_instance(
if
issubclass
(
class_
,
BranchSettingMixin
):
_options
[
'branch_setting_func'
]
=
_get_modulestore_branch_setting
# We also may not always have the current request user (crum) module available
try
:
from
xblock_django.user_service
import
DjangoXBlockUserService
from
crum
import
get_current_user
HAS_USER_SERVICE
=
True
except
ImportError
:
HAS_USER_SERVICE
=
False
if
HAS_USER_SERVICE
and
not
user_service
:
xb_user_service
=
DjangoXBlockUserService
(
get_current_user
())
else
:
...
...
@@ -188,6 +182,11 @@ def create_modulestore_instance(
if
'read_preference'
in
doc_store_config
:
doc_store_config
[
'read_preference'
]
=
getattr
(
ReadPreference
,
doc_store_config
[
'read_preference'
])
try
:
from
xblock_django.models
import
XBlockDisableConfig
except
ImportError
:
XBlockDisableConfig
=
None
if
XBlockDisableConfig
and
settings
.
FEATURES
.
get
(
'ENABLE_DISABLING_XBLOCK_TYPES'
,
False
):
disabled_xblock_types
=
XBlockDisableConfig
.
disabled_block_types
()
else
:
...
...
@@ -195,6 +194,8 @@ def create_modulestore_instance(
xblock_field_data_wrappers
=
[
load_function
(
path
)
for
path
in
settings
.
XBLOCK_FIELD_DATA_WRAPPERS
]
import
xblock.reference.plugins
return
class_
(
contentstore
=
content_store
,
metadata_inheritance_cache_subsystem
=
metadata_inheritance_cache
,
...
...
openedx/core/djangoapps/content/course_structures/signals.py
View file @
c9b472d2
...
...
@@ -5,8 +5,6 @@ from django.dispatch.dispatcher import receiver
from
xmodule.modulestore.django
import
SignalHandler
from
.models
import
CourseStructure
@receiver
(
SignalHandler
.
course_published
)
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
...
...
@@ -16,6 +14,8 @@ def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable=
# Import tasks here to avoid a circular import.
from
.tasks
import
update_course_structure
from
.models
import
CourseStructure
# Delete the existing discussion id map cache to avoid inconsistencies
try
:
structure
=
CourseStructure
.
objects
.
get
(
course_id
=
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