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
684aec87
Commit
684aec87
authored
Oct 07, 2016
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move contentserver to openedx/core
parent
9fa126df
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
39 additions
and
38 deletions
+39
-38
cms/djangoapps/contentstore/tests/test_core_caching.py
+4
-2
cms/djangoapps/contentstore/views/assets.py
+11
-14
cms/djangoapps/contentstore/views/tests/test_transcripts.py
+2
-2
cms/envs/common.py
+2
-2
lms/djangoapps/courseware/tests/test_video_handlers.py
+5
-6
lms/envs/common.py
+2
-2
openedx/core/djangoapps/contentserver/__init__.py
+0
-0
openedx/core/djangoapps/contentserver/admin.py
+0
-0
openedx/core/djangoapps/contentserver/caching.py
+0
-0
openedx/core/djangoapps/contentserver/middleware.py
+4
-2
openedx/core/djangoapps/contentserver/migrations/0001_initial.py
+0
-0
openedx/core/djangoapps/contentserver/migrations/0002_cdnuseragentsconfig.py
+0
-0
openedx/core/djangoapps/contentserver/migrations/__init__.py
+0
-0
openedx/core/djangoapps/contentserver/models.py
+0
-0
openedx/core/djangoapps/contentserver/test/__init__.py
+0
-0
openedx/core/djangoapps/contentserver/test/test_contentserver.py
+9
-8
No files found.
cms/djangoapps/contentstore/tests/test_core_caching.py
View file @
684aec87
"""
Tests core caching facilities.
"""
from
contentserver.caching
import
get_cached_content
,
set_cached_content
,
del_cached_content
from
opaque_keys.edx.locations
import
Location
from
django.test
import
TestCase
from
opaque_keys.edx.locations
import
Location
from
openedx.core.djangoapps.contentserver.caching
import
get_cached_content
,
set_cached_content
,
del_cached_content
class
Content
(
object
):
"""
...
...
cms/djangoapps/contentstore/views/assets.py
View file @
684aec87
...
...
@@ -2,31 +2,28 @@ import logging
from
functools
import
partial
import
math
import
json
from
pymongo
import
ASCENDING
,
DESCENDING
from
django.
http
import
HttpResponseBadRequest
from
django.
conf
import
settings
from
django.contrib.auth.decorators
import
login_required
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
HttpResponseBadRequest
,
HttpResponseNotFound
from
django.utils.translation
import
ugettext
as
_
from
django.views.decorators.csrf
import
ensure_csrf_cookie
from
django.views.decorators.http
import
require_http_methods
,
require_POST
from
django.conf
import
settings
from
edxmako.shortcuts
import
render_to_response
from
contentserver.caching
import
del_cached_content
from
contentstore.utils
import
reverse_course_url
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.exceptions
import
NotFoundError
from
contentstore.views.exception
import
AssetNotFoundException
from
django.core.exceptions
import
PermissionDenied
from
opaque_keys.edx.keys
import
CourseKey
,
AssetKey
from
openedx.core.djangoapps.contentserver.caching
import
del_cached_content
from
student.auth
import
has_course_author_access
from
util.date_utils
import
get_default_time_display
from
util.json_request
import
JsonResponse
from
django.http
import
HttpResponseNotFound
from
django.utils.translation
import
ugettext
as
_
from
pymongo
import
ASCENDING
,
DESCENDING
from
student.auth
import
has_course_author_access
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.django
import
contentstore
from
xmodule.exceptions
import
NotFoundError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
__all__
=
[
'assets_handler'
]
...
...
cms/djangoapps/contentstore/views/tests/test_transcripts.py
View file @
684aec87
...
...
@@ -13,12 +13,12 @@ from django.test.utils import override_settings
from
django.conf
import
settings
from
contentstore.tests.utils
import
CourseTestCase
,
mock_requests_get
from
contentserver.caching
import
del_cached_content
from
opaque_keys.edx.keys
import
UsageKey
from
openedx.core.djangoapps.contentserver.caching
import
del_cached_content
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.exceptions
import
NotFoundError
from
opaque_keys.edx.keys
import
UsageKey
from
xmodule.video_module
import
transcripts_utils
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
...
...
cms/envs/common.py
View file @
684aec87
...
...
@@ -354,7 +354,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.SessionAuthenticationMiddleware'
,
'student.middleware.UserStandingMiddleware'
,
'contentserver.middleware.StaticContentServer'
,
'
openedx.core.djangoapps.
contentserver.middleware.StaticContentServer'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'track.middleware.TrackMiddleware'
,
...
...
@@ -816,7 +816,7 @@ INSTALLED_APPS = (
# For CMS
'contentstore'
,
'contentserver'
,
'
openedx.core.djangoapps.
contentserver'
,
'course_creators'
,
'openedx.core.djangoapps.external_auth'
,
'student'
,
# misleading name due to sharing with lms
...
...
lms/djangoapps/courseware/tests/test_video_handlers.py
View file @
684aec87
...
...
@@ -8,26 +8,25 @@ import textwrap
import
json
import
ddt
from
nose.plugins.attrib
import
attr
from
datetime
import
timedelta
,
datetime
from
webob
import
Request
from
mock
import
MagicMock
,
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
webob
import
Request
from
openedx.core.djangoapps.contentserver.caching
import
del_cached_content
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.x_module
import
STUDENT_VIEW
from
.
import
BaseTestXmodule
from
.test_video_xml
import
SOURCE_XML
from
contentserver.caching
import
del_cached_content
from
xmodule.exceptions
import
NotFoundError
from
xmodule.video_module.transcripts_utils
import
(
TranscriptException
,
TranscriptsGenerationException
,
)
from
.
import
BaseTestXmodule
from
.test_video_xml
import
SOURCE_XML
TRANSCRIPT
=
{
"start"
:
[
10
],
"end"
:
[
100
],
"text"
:
[
"Hi, welcome to Edx."
]}
BUMPER_TRANSCRIPT
=
{
"start"
:
[
1
],
"end"
:
[
10
],
"text"
:
[
"A bumper"
]}
...
...
lms/envs/common.py
View file @
684aec87
...
...
@@ -1109,7 +1109,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.SessionAuthenticationMiddleware'
,
'student.middleware.UserStandingMiddleware'
,
'contentserver.middleware.StaticContentServer'
,
'
openedx.core.djangoapps.
contentserver.middleware.StaticContentServer'
,
# Adds user tags to tracking events
# Must go before TrackMiddleware, to get the context set up
...
...
@@ -1892,7 +1892,7 @@ INSTALLED_APPS = (
'static_replace'
,
# For content serving
'contentserver'
,
'
openedx.core.djangoapps.
contentserver'
,
# Theming
'openedx.core.djangoapps.theming'
,
...
...
common
/djangoapps/contentserver/__init__.py
→
openedx/core
/djangoapps/contentserver/__init__.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/admin.py
→
openedx/core
/djangoapps/contentserver/admin.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/caching.py
→
openedx/core
/djangoapps/contentserver/caching.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/middleware.py
→
openedx/core
/djangoapps/contentserver/middleware.py
View file @
684aec87
...
...
@@ -9,7 +9,6 @@ from django.http import (
HttpResponse
,
HttpResponseNotModified
,
HttpResponseForbidden
,
HttpResponseBadRequest
,
HttpResponseNotFound
,
HttpResponsePermanentRedirect
)
from
student.models
import
CourseEnrollment
from
contentserver.models
import
CourseAssetCacheTtlConfig
,
CdnUserAgentsConfig
from
header_control
import
force_header_for_response
from
xmodule.assetstore.assetmgr
import
AssetManager
...
...
@@ -21,6 +20,8 @@ from .caching import get_cached_content, set_cached_content
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.exceptions
import
NotFoundError
from
.models
import
CourseAssetCacheTtlConfig
,
CdnUserAgentsConfig
# TODO: Soon as we have a reasonable way to serialize/deserialize AssetKeys, we need
# to change this file so instead of using course_id_partial, we're just using asset keys
...
...
@@ -42,6 +43,7 @@ class StaticContentServer(object):
StaticContent
.
is_versioned_asset_path
(
request
.
path
)
)
# pylint: disable=too-many-statements
def
process_request
(
self
,
request
):
"""Process the given request"""
asset_path
=
request
.
path
...
...
@@ -117,7 +119,7 @@ class StaticContentServer(object):
response
=
None
if
request
.
META
.
get
(
'HTTP_RANGE'
):
# If we have a StaticContent, get a StaticContentStream. Can't manipulate the bytes otherwise.
if
type
(
content
)
==
StaticContent
:
if
isinstance
(
content
,
StaticContent
)
:
content
=
AssetManager
.
find
(
loc
,
as_stream
=
True
)
header_value
=
request
.
META
[
'HTTP_RANGE'
]
...
...
common
/djangoapps/contentserver/migrations/0001_initial.py
→
openedx/core
/djangoapps/contentserver/migrations/0001_initial.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/migrations/0002_cdnuseragentsconfig.py
→
openedx/core
/djangoapps/contentserver/migrations/0002_cdnuseragentsconfig.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/migrations/__init__.py
→
openedx/core
/djangoapps/contentserver/migrations/__init__.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/models.py
→
openedx/core
/djangoapps/contentserver/models.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/test/__init__.py
→
openedx/core
/djangoapps/contentserver/test/__init__.py
View file @
684aec87
File moved
common
/djangoapps/contentserver/test/test_contentserver.py
→
openedx/core
/djangoapps/contentserver/test/test_contentserver.py
View file @
684aec87
...
...
@@ -24,10 +24,11 @@ from xmodule.assetstore.assetmgr import AssetManager
from
opaque_keys
import
InvalidKeyError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
contentserver.middleware
import
parse_range_header
,
HTTP_DATE_FORMAT
,
StaticContentServer
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
,
AdminFactory
from
..middleware
import
parse_range_header
,
HTTP_DATE_FORMAT
,
StaticContentServer
log
=
logging
.
getLogger
(
__name__
)
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
...
...
@@ -293,7 +294,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEquals
(
'Origin'
,
resp
[
'Vary'
])
@patch
(
'contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
def
test_cache_headers_with_ttl_unlocked
(
self
,
mock_get_cache_ttl
):
"""
Tests that when a cache TTL is set, an unlocked asset will be sent back with
...
...
@@ -306,7 +307,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
self
.
assertIn
(
'Expires'
,
resp
)
self
.
assertEquals
(
'public, max-age=10, s-maxage=10'
,
resp
[
'Cache-Control'
])
@patch
(
'contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
def
test_cache_headers_with_ttl_locked
(
self
,
mock_get_cache_ttl
):
"""
Tests that when a cache TTL is set, a locked asset will be sent back without
...
...
@@ -323,7 +324,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
self
.
assertNotIn
(
'Expires'
,
resp
)
self
.
assertEquals
(
'private, no-cache, no-store'
,
resp
[
'Cache-Control'
])
@patch
(
'contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
def
test_cache_headers_without_ttl_unlocked
(
self
,
mock_get_cache_ttl
):
"""
Tests that when a cache TTL is not set, an unlocked asset will be sent back without
...
...
@@ -336,7 +337,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
self
.
assertNotIn
(
'Expires'
,
resp
)
self
.
assertNotIn
(
'Cache-Control'
,
resp
)
@patch
(
'contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CourseAssetCacheTtlConfig.get_cache_ttl'
)
def
test_cache_headers_without_ttl_locked
(
self
,
mock_get_cache_ttl
):
"""
Tests that when a cache TTL is not set, a locked asset will be sent back with a
...
...
@@ -358,7 +359,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
near_expire_dt
=
StaticContentServer
.
get_expiration_value
(
start_dt
,
55
)
self
.
assertEqual
(
"Thu, 01 Dec 1983 20:00:55 GMT"
,
near_expire_dt
)
@patch
(
'contentserver.models.CdnUserAgentsConfig.get_cdn_user_agents'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CdnUserAgentsConfig.get_cdn_user_agents'
)
def
test_cache_is_cdn_with_normal_request
(
self
,
mock_get_cdn_user_agents
):
"""
Tests that when a normal request is made -- i.e. from an end user with their
...
...
@@ -372,7 +373,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
is_from_cdn
=
StaticContentServer
.
is_cdn_request
(
browser_request
)
self
.
assertEqual
(
is_from_cdn
,
False
)
@patch
(
'contentserver.models.CdnUserAgentsConfig.get_cdn_user_agents'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CdnUserAgentsConfig.get_cdn_user_agents'
)
def
test_cache_is_cdn_with_cdn_request
(
self
,
mock_get_cdn_user_agents
):
"""
Tests that when a CDN request is made -- i.e. from an edge node back to the
...
...
@@ -386,7 +387,7 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
is_from_cdn
=
StaticContentServer
.
is_cdn_request
(
browser_request
)
self
.
assertEqual
(
is_from_cdn
,
True
)
@patch
(
'contentserver.models.CdnUserAgentsConfig.get_cdn_user_agents'
)
@patch
(
'
openedx.core.djangoapps.
contentserver.models.CdnUserAgentsConfig.get_cdn_user_agents'
)
def
test_cache_is_cdn_with_cdn_request_multiple_user_agents
(
self
,
mock_get_cdn_user_agents
):
"""
Tests that when a CDN request is made -- i.e. from an edge node back to the
...
...
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