Skip to content

Commit

Permalink
Revert "Cdodge/rdf 3.1 rebase2"
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisndodge committed Sep 17, 2015
1 parent e205568 commit 4719bc7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
27 changes: 16 additions & 11 deletions edx_proctoring/serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
"""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


class StrictBooleanField(serializers.BooleanField):
"""
Boolean field serializer to cater for a bug in DRF BooleanField serializer
where required=True is ignored.
"""
def from_native(self, value):
if value in ('true', 't', 'True', '1'):
return True
if value in ('false', 'f', 'False', '0'):
return False
return None


class ProctoredExamSerializer(serializers.ModelSerializer):
"""
Serializer for the ProctoredExam Model.
Expand All @@ -16,9 +28,9 @@ class ProctoredExamSerializer(serializers.ModelSerializer):
exam_name = serializers.CharField(required=True)
time_limit_mins = serializers.IntegerField(required=True)

is_active = serializers.BooleanField(required=True)
is_practice_exam = serializers.BooleanField(required=True)
is_proctored = serializers.BooleanField(required=True)
is_active = StrictBooleanField(required=True)
is_practice_exam = StrictBooleanField(required=True)
is_proctored = StrictBooleanField(required=True)

class Meta:
"""
Expand Down Expand Up @@ -58,13 +70,6 @@ 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
Expand Down
4 changes: 2 additions & 2 deletions edx_proctoring/tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_boolean_fields(self):
self.assertFalse(serializer.is_valid())
self.assertDictEqual(
{
'is_proctored': [u'"bla" is not a valid boolean.'],
'is_practice_exam': [u'"bla" is not a valid boolean.'],
'is_proctored': [u'This field is required.'],
'is_practice_exam': [u'This field is required.'],
}, serializer.errors
)
2 changes: 1 addition & 1 deletion local_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
django>=1.4.12,<=1.4.22
django-model-utils==2.3.1
South>=0.7.6
djangorestframework>=3.1,<3.2
djangorestframework>=2.3.5,<=2.3.14
django-ipware==1.1.0
pytz>=2012h
pycrypto>=2.6
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_requirements(*requirements_paths):

setup(
name='edx-proctoring',
version='0.9.8',
version='0.9.6',
description='Proctoring subsystem for Open edX',
long_description=open('README.md').read(),
author='edX',
Expand Down

0 comments on commit 4719bc7

Please sign in to comment.