Commit bde7831c by Will Daly Committed by Chris Dodge

Upgrade django-rest-framework to v3.1

parent af95b2e7
"""Defines serializers used by the Proctoring API."""
from rest_framework import serializers
from rest_framework.fields import DateTimeField
from django.contrib.auth.models import User
from edx_proctoring.models import ProctoredExam, ProctoredExamStudentAttempt, ProctoredExamStudentAllowance
......@@ -10,6 +11,9 @@ class StrictBooleanField(serializers.BooleanField):
where required=True is ignored.
"""
def from_native(self, value):
"""
Convert representations of a boolean to a Python `boolean`.
"""
if value in ('true', 't', 'True', '1'):
return True
if value in ('false', 'f', 'False', '0'):
......@@ -70,6 +74,13 @@ class ProctoredExamStudentAttemptSerializer(serializers.ModelSerializer):
proctored_exam = ProctoredExamSerializer()
user = UserSerializer()
# Django Rest Framework v3 defaults to `settings.DATE_FORMAT` when serializing
# datetime fields. We need to specify `format=None` to maintain the old behavior
# of returning raw `datetime` objects instead of unicode.
started_at = DateTimeField(format=None)
completed_at = DateTimeField(format=None)
last_poll_timestamp = DateTimeField(format=None)
class Meta:
"""
Meta Class
......
......@@ -30,7 +30,7 @@ class TestProctoredExamSerializer(unittest.TestCase):
self.assertFalse(serializer.is_valid())
self.assertDictEqual(
{
'is_proctored': [u'This field is required.'],
'is_practice_exam': [u'This field is required.'],
'is_proctored': [u'"bla" is not a valid boolean.'],
'is_practice_exam': [u'"bla" is not a valid boolean.'],
}, serializer.errors
)
......@@ -2,7 +2,7 @@
django>=1.4.12,<=1.4.22
django-model-utils==2.3.1
South>=0.7.6
djangorestframework>=2.3.5,<=2.3.14
djangorestframework>=3.1,<3.2
django-ipware==1.1.0
pytz>=2012h
pycrypto>=2.6
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