Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
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-val
Commits
35cac655
Commit
35cac655
authored
Aug 27, 2014
by
Dave St.Germain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deny anonymous reading.
parent
d2ee2430
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
edxval/tests/test_views.py
+5
-3
edxval/views.py
+5
-5
No files found.
edxval/tests/test_views.py
View file @
35cac655
...
...
@@ -24,7 +24,7 @@ class VideoDetail(APIAuthTestCase):
# Tests for successful PUT requests.
def
test_anonymous_
readonly
(
self
):
def
test_anonymous_
denied
(
self
):
"""
Tests that writing checks model permissions.
"""
...
...
@@ -32,6 +32,8 @@ class VideoDetail(APIAuthTestCase):
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
VIDEO_DICT_ANIMAL
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_no_perms
(
self
):
"""
...
...
@@ -42,6 +44,8 @@ class VideoDetail(APIAuthTestCase):
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
VIDEO_DICT_ANIMAL
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_update_video
(
self
):
"""
...
...
@@ -330,8 +334,6 @@ class VideoListTest(APIAuthTestCase):
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
)
# we can log out here, to test read-only
self
.
_logout
()
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
video
=
self
.
client
.
get
(
"/edxval/video/"
)
.
data
self
.
assertEqual
(
len
(
video
),
1
)
...
...
edxval/views.py
View file @
35cac655
...
...
@@ -3,7 +3,7 @@ Views file for django app edxval.
"""
from
rest_framework
import
generics
from
rest_framework.permissions
import
DjangoModelPermissions
OrAnonReadOnly
from
rest_framework.permissions
import
DjangoModelPermissions
from
django.http
import
HttpResponse
from
django.shortcuts
import
get_object_or_404
from
django.views.decorators.http
import
last_modified
...
...
@@ -33,7 +33,7 @@ class VideoList(generics.ListCreateAPIView):
"""
GETs or POST video objects
"""
permission_classes
=
(
DjangoModelPermissions
OrAnonReadOnly
,)
permission_classes
=
(
DjangoModelPermissions
,)
queryset
=
Video
.
objects
.
all
()
.
prefetch_related
(
"encoded_videos"
)
lookup_field
=
"edx_video_id"
serializer_class
=
VideoSerializer
...
...
@@ -43,7 +43,7 @@ class ProfileList(generics.ListCreateAPIView):
"""
GETs or POST video objects
"""
permission_classes
=
(
DjangoModelPermissions
OrAnonReadOnly
,)
permission_classes
=
(
DjangoModelPermissions
,)
queryset
=
Profile
.
objects
.
all
()
lookup_field
=
"profile_name"
serializer_class
=
ProfileSerializer
...
...
@@ -53,7 +53,7 @@ class VideoDetail(generics.RetrieveUpdateDestroyAPIView):
"""
Gets a video instance given its edx_video_id
"""
permission_classes
=
(
DjangoModelPermissions
OrAnonReadOnly
,)
permission_classes
=
(
DjangoModelPermissions
,)
lookup_field
=
"edx_video_id"
queryset
=
Video
.
objects
.
all
()
serializer_class
=
VideoSerializer
...
...
@@ -63,7 +63,7 @@ class SubtitleDetail(MultipleFieldLookupMixin, generics.RetrieveUpdateDestroyAPI
"""
Gets a subtitle instance given its id
"""
permission_classes
=
(
DjangoModelPermissions
OrAnonReadOnly
,)
permission_classes
=
(
DjangoModelPermissions
,)
lookup_fields
=
(
"video__edx_video_id"
,
"language"
)
queryset
=
Subtitle
.
objects
.
all
()
serializer_class
=
SubtitleSerializer
...
...
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