Revert "Merge DRF 3.1 in to master"
This commit is contained in:
@@ -11,11 +11,11 @@ class CourseSerializer(serializers.Serializer):
|
||||
id = serializers.CharField() # pylint: disable=invalid-name
|
||||
name = serializers.CharField(source='display_name')
|
||||
category = serializers.CharField()
|
||||
org = serializers.SerializerMethodField()
|
||||
run = serializers.SerializerMethodField()
|
||||
course = serializers.SerializerMethodField()
|
||||
uri = serializers.SerializerMethodField()
|
||||
image_url = serializers.SerializerMethodField()
|
||||
org = serializers.SerializerMethodField('get_org')
|
||||
run = serializers.SerializerMethodField('get_run')
|
||||
course = serializers.SerializerMethodField('get_course')
|
||||
uri = serializers.SerializerMethodField('get_uri')
|
||||
image_url = serializers.SerializerMethodField('get_image_url')
|
||||
start = serializers.DateTimeField()
|
||||
end = serializers.DateTimeField()
|
||||
|
||||
|
||||
@@ -36,23 +36,6 @@ class CourseViewTestsMixin(object):
|
||||
"""
|
||||
view = None
|
||||
|
||||
raw_grader = [
|
||||
{
|
||||
"min_count": 24,
|
||||
"weight": 0.2,
|
||||
"type": "Homework",
|
||||
"drop_count": 0,
|
||||
"short_label": "HW"
|
||||
},
|
||||
{
|
||||
"min_count": 4,
|
||||
"weight": 0.8,
|
||||
"type": "Exam",
|
||||
"drop_count": 0,
|
||||
"short_label": "Exam"
|
||||
}
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
super(CourseViewTestsMixin, self).setUp()
|
||||
self.create_user_and_access_token()
|
||||
@@ -68,7 +51,22 @@ class CourseViewTestsMixin(object):
|
||||
@classmethod
|
||||
def create_course_data(cls):
|
||||
cls.invalid_course_id = 'foo/bar/baz'
|
||||
cls.course = CourseFactory.create(display_name='An Introduction to API Testing', raw_grader=cls.raw_grader)
|
||||
cls.course = CourseFactory.create(display_name='An Introduction to API Testing', raw_grader=[
|
||||
{
|
||||
"min_count": 24,
|
||||
"weight": 0.2,
|
||||
"type": "Homework",
|
||||
"drop_count": 0,
|
||||
"short_label": "HW"
|
||||
},
|
||||
{
|
||||
"min_count": 4,
|
||||
"weight": 0.8,
|
||||
"type": "Exam",
|
||||
"drop_count": 0,
|
||||
"short_label": "Exam"
|
||||
}
|
||||
])
|
||||
cls.course_id = unicode(cls.course.id)
|
||||
with cls.store.bulk_operations(cls.course.id, emit_signals=False):
|
||||
cls.sequential = ItemFactory.create(
|
||||
@@ -410,55 +408,6 @@ class CourseGradingPolicyTests(CourseDetailTestMixin, CourseViewTestsMixin, Shar
|
||||
self.assertListEqual(response.data, expected)
|
||||
|
||||
|
||||
class CourseGradingPolicyMissingFieldsTests(CourseDetailTestMixin, CourseViewTestsMixin, SharedModuleStoreTestCase):
|
||||
view = 'course_structure_api:v0:grading_policy'
|
||||
|
||||
# Update the raw grader to have missing keys
|
||||
raw_grader = [
|
||||
{
|
||||
"min_count": 24,
|
||||
"weight": 0.2,
|
||||
"type": "Homework",
|
||||
"drop_count": 0,
|
||||
"short_label": "HW"
|
||||
},
|
||||
{
|
||||
# Deleted "min_count" key
|
||||
"weight": 0.8,
|
||||
"type": "Exam",
|
||||
"drop_count": 0,
|
||||
"short_label": "Exam"
|
||||
}
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(CourseGradingPolicyMissingFieldsTests, cls).setUpClass()
|
||||
cls.create_course_data()
|
||||
|
||||
def test_get(self):
|
||||
"""
|
||||
The view should return grading policy for a course.
|
||||
"""
|
||||
response = super(CourseGradingPolicyMissingFieldsTests, self).test_get()
|
||||
|
||||
expected = [
|
||||
{
|
||||
"count": 24,
|
||||
"weight": 0.2,
|
||||
"assignment_type": "Homework",
|
||||
"dropped": 0
|
||||
},
|
||||
{
|
||||
"count": None,
|
||||
"weight": 0.8,
|
||||
"assignment_type": "Exam",
|
||||
"dropped": 0
|
||||
}
|
||||
]
|
||||
self.assertListEqual(response.data, expected)
|
||||
|
||||
|
||||
#####################################################################################
|
||||
#
|
||||
# The following Mixins/Classes collectively test the CourseBlocksAndNavigation view.
|
||||
|
||||
@@ -6,8 +6,7 @@ import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import Http404
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
from rest_framework_oauth.authentication import OAuth2Authentication
|
||||
from rest_framework.authentication import OAuth2Authentication, SessionAuthentication
|
||||
from rest_framework.exceptions import AuthenticationFailed, ParseError
|
||||
from rest_framework.generics import RetrieveAPIView, ListAPIView
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
@@ -22,6 +21,7 @@ from courseware.access import has_access
|
||||
from courseware.model_data import FieldDataCache
|
||||
from courseware.module_render import get_module_for_descriptor
|
||||
from openedx.core.lib.api.view_utils import view_course_access, view_auth_classes
|
||||
from openedx.core.lib.api.serializers import PaginationSerializer
|
||||
from openedx.core.djangoapps.content.course_structures.api.v0 import api, errors
|
||||
from student.roles import CourseInstructorRole, CourseStaffRole
|
||||
from util.module_utils import get_dynamic_descriptor_children
|
||||
@@ -157,6 +157,9 @@ class CourseList(CourseViewMixin, ListAPIView):
|
||||
* end: The course end date. If course end date is not specified, the
|
||||
value is null.
|
||||
"""
|
||||
paginate_by = 10
|
||||
paginate_by_param = 'page_size'
|
||||
pagination_serializer_class = PaginationSerializer
|
||||
serializer_class = serializers.CourseSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
Reference in New Issue
Block a user