Commit 84753740 by Nimisha Asthagiri

Merge pull request #8570 from edx/mobile/video-upload-MA-844

MA-844 Video Upload: remove dependency on AssetMetaDataStore.
parents 8a112868 26d4a15d
...@@ -16,11 +16,9 @@ from mock import Mock, patch ...@@ -16,11 +16,9 @@ from mock import Mock, patch
from edxval.api import create_profile, create_video, get_video_info from edxval.api import create_profile, create_video, get_video_info
from contentstore.models import VideoUploadConfig from contentstore.models import VideoUploadConfig
from contentstore.views.videos import KEY_EXPIRATION_IN_SECONDS, VIDEO_ASSET_TYPE, StatusDisplayStrings from contentstore.views.videos import KEY_EXPIRATION_IN_SECONDS, StatusDisplayStrings
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from xmodule.assetstore import AssetMetadata
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
...@@ -47,6 +45,7 @@ class VideoUploadTestMixin(object): ...@@ -47,6 +45,7 @@ class VideoUploadTestMixin(object):
"client_video_id": "test1.mp4", "client_video_id": "test1.mp4",
"duration": 42.0, "duration": 42.0,
"status": "upload", "status": "upload",
"courses": [unicode(self.course.id)],
"encoded_videos": [], "encoded_videos": [],
}, },
{ {
...@@ -54,6 +53,7 @@ class VideoUploadTestMixin(object): ...@@ -54,6 +53,7 @@ class VideoUploadTestMixin(object):
"client_video_id": "test2.mp4", "client_video_id": "test2.mp4",
"duration": 128.0, "duration": 128.0,
"status": "file_complete", "status": "file_complete",
"courses": [unicode(self.course.id)],
"encoded_videos": [ "encoded_videos": [
{ {
"profile": "profile1", "profile": "profile1",
...@@ -74,6 +74,7 @@ class VideoUploadTestMixin(object): ...@@ -74,6 +74,7 @@ class VideoUploadTestMixin(object):
"client_video_id": u"nón-ascii-näme.mp4", "client_video_id": u"nón-ascii-näme.mp4",
"duration": 256.0, "duration": 256.0,
"status": "transcode_active", "status": "transcode_active",
"courses": [unicode(self.course.id)],
"encoded_videos": [ "encoded_videos": [
{ {
"profile": "profile1", "profile": "profile1",
...@@ -91,6 +92,7 @@ class VideoUploadTestMixin(object): ...@@ -91,6 +92,7 @@ class VideoUploadTestMixin(object):
"client_video_id": "status_test.mp4", "client_video_id": "status_test.mp4",
"duration": 3.14, "duration": 3.14,
"status": status, "status": status,
"courses": [unicode(self.course.id)],
"encoded_videos": [], "encoded_videos": [],
} }
for status in ( for status in (
...@@ -102,12 +104,6 @@ class VideoUploadTestMixin(object): ...@@ -102,12 +104,6 @@ class VideoUploadTestMixin(object):
create_profile(profile) create_profile(profile)
for video in self.previous_uploads: for video in self.previous_uploads:
create_video(video) create_video(video)
modulestore().save_asset_metadata(
AssetMetadata(
self.course.id.make_asset_key(VIDEO_ASSET_TYPE, video["edx_video_id"])
),
self.user.id
)
def _get_previous_upload(self, edx_video_id): def _get_previous_upload(self, edx_video_id):
"""Returns the previous upload with the given video id.""" """Returns the previous upload with the given video id."""
...@@ -289,13 +285,6 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase): ...@@ -289,13 +285,6 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
headers={"Content-Type": file_info["content_type"]} headers={"Content-Type": file_info["content_type"]}
) )
# Ensure asset store was updated and the created_by field was set
asset_metadata = modulestore().find_asset_metadata(
self.course.id.make_asset_key(VIDEO_ASSET_TYPE, video_id)
)
self.assertIsNotNone(asset_metadata)
self.assertEquals(asset_metadata.created_by, self.user.id)
# Ensure VAL was updated # Ensure VAL was updated
val_info = get_video_info(video_id) val_info = get_video_info(video_id)
self.assertEqual(val_info["status"], "upload") self.assertEqual(val_info["status"], "upload")
......
...@@ -12,15 +12,13 @@ from django.utils.translation import ugettext as _, ugettext_noop ...@@ -12,15 +12,13 @@ from django.utils.translation import ugettext as _, ugettext_noop
from django.views.decorators.http import require_GET, require_http_methods from django.views.decorators.http import require_GET, require_http_methods
import rfc6266 import rfc6266
from edxval.api import create_video, get_videos_for_ids, SortDirection, VideoSortField from edxval.api import create_video, get_videos_for_course, SortDirection, VideoSortField
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from contentstore.models import VideoUploadConfig from contentstore.models import VideoUploadConfig
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from util.json_request import expect_json, JsonResponse from util.json_request import expect_json, JsonResponse
from xmodule.assetstore import AssetMetadata
from xmodule.modulestore.django import modulestore
from .course import get_course_and_check_access from .course import get_course_and_check_access
...@@ -28,9 +26,6 @@ from .course import get_course_and_check_access ...@@ -28,9 +26,6 @@ from .course import get_course_and_check_access
__all__ = ["videos_handler", "video_encodings_download"] __all__ = ["videos_handler", "video_encodings_download"]
# String constant used in asset keys to identify video assets.
VIDEO_ASSET_TYPE = "video"
# Default expiration, in seconds, of one-time URLs used for uploading videos. # Default expiration, in seconds, of one-time URLs used for uploading videos.
KEY_EXPIRATION_IN_SECONDS = 86400 KEY_EXPIRATION_IN_SECONDS = 86400
...@@ -217,15 +212,9 @@ def _get_and_validate_course(course_key_string, user): ...@@ -217,15 +212,9 @@ def _get_and_validate_course(course_key_string, user):
def _get_videos(course): def _get_videos(course):
""" """
Retrieves the list of videos from VAL corresponding to the videos listed in Retrieves the list of videos from VAL corresponding to this course.
the asset metadata store.
""" """
edx_videos_ids = [ videos = list(get_videos_for_course(course.id, VideoSortField.created, SortDirection.desc))
v.asset_id.path
for v in modulestore().get_all_asset_metadata(course.id, VIDEO_ASSET_TYPE)
]
videos = list(get_videos_for_ids(edx_videos_ids, VideoSortField.created, SortDirection.desc))
# convert VAL's status to studio's Video Upload feature status. # convert VAL's status to studio's Video Upload feature status.
for video in videos: for video in videos:
...@@ -333,11 +322,6 @@ def videos_post(course, request): ...@@ -333,11 +322,6 @@ def videos_post(course, request):
headers={"Content-Type": req_file["content_type"]} headers={"Content-Type": req_file["content_type"]}
) )
# persist edx_video_id as uploaded through this course
user_id = request.user.id
video_meta_data = AssetMetadata(course.id.make_asset_key(VIDEO_ASSET_TYPE, edx_video_id), created_by=user_id)
modulestore().save_asset_metadata(video_meta_data, user_id)
# persist edx_video_id in VAL # persist edx_video_id in VAL
create_video({ create_video({
"edx_video_id": edx_video_id, "edx_video_id": edx_video_id,
......
...@@ -45,7 +45,7 @@ git+https://github.com/hmarr/django-debug-toolbar-mongo.git@b0686a76f1ce3532088c ...@@ -45,7 +45,7 @@ git+https://github.com/hmarr/django-debug-toolbar-mongo.git@b0686a76f1ce3532088c
-e git+https://github.com/edx/ease.git@b67d2928a26fe497826b6ea359b9a3d0371548a7#egg=ease==0.1.3 -e git+https://github.com/edx/ease.git@b67d2928a26fe497826b6ea359b9a3d0371548a7#egg=ease==0.1.3
-e git+https://github.com/edx/i18n-tools.git@3478455a2cc59a734432264e409b8eade1e4b167#egg=i18n-tools -e git+https://github.com/edx/i18n-tools.git@3478455a2cc59a734432264e409b8eade1e4b167#egg=i18n-tools
-e git+https://github.com/edx/edx-oauth2-provider.git@0.5.1#egg=oauth2-provider -e git+https://github.com/edx/edx-oauth2-provider.git@0.5.1#egg=oauth2-provider
-e git+https://github.com/edx/edx-val.git@b1e11c9af3233bc06a17acbb33179f46d43c3b87#egg=edx-val -e git+https://github.com/edx/edx-val.git@v0.0.5#egg=edx-val
-e git+https://github.com/pmitros/RecommenderXBlock.git@518234bc354edbfc2651b9e534ddb54f96080779#egg=recommender-xblock -e git+https://github.com/pmitros/RecommenderXBlock.git@518234bc354edbfc2651b9e534ddb54f96080779#egg=recommender-xblock
-e git+https://github.com/edx/edx-search.git@release-2015-06-16#egg=edx-search -e git+https://github.com/edx/edx-search.git@release-2015-06-16#egg=edx-search
-e git+https://github.com/edx/edx-milestones.git@release-2015-06-17#egg=edx-milestones -e git+https://github.com/edx/edx-milestones.git@release-2015-06-17#egg=edx-milestones
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment