Commit bbf9b618 by Eric Fischer

Loosen requirements versions for installation

Also, removes dependency on django-extensions
parent e57b6755
dogapi==1.2.1 dogapi>=1.2.1,<2.0.0
django-extensions==1.5.9 django-model-utils>=2.3.1,<3.0.0
django-model-utils==2.3.1
# Use the same DRF version as edx-platform # Use the same DRF version as edx-platform
git+https://github.com/edx/django-rest-framework.git@1ceda7c086fddffd1c440cc86856441bbf0bd9cb#egg=djangorestframework==3.6.3 git+https://github.com/edx/django-rest-framework.git@1ceda7c086fddffd1c440cc86856441bbf0bd9cb#egg=djangorestframework==3.6.3
jsonfield==1.0.3 jsonfield>=1.0.3,<2.0.0
pytz pytz
...@@ -52,9 +52,6 @@ INSTALLED_APPS = ( ...@@ -52,9 +52,6 @@ INSTALLED_APPS = (
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.admindocs', 'django.contrib.admindocs',
# Third party
'django_extensions',
# Test # Test
'django_nose', 'django_nose',
......
...@@ -33,7 +33,7 @@ def load_requirements(*requirements_paths): ...@@ -33,7 +33,7 @@ def load_requirements(*requirements_paths):
setup( setup(
name='edx-submissions', name='edx-submissions',
version='2.0.5', version='2.0.6',
author='edX', author='edX',
description='An API for creating submissions and scores.', description='An API for creating submissions and scores.',
url='http://github.com/edx/edx-submissions.git', url='http://github.com/edx/edx-submissions.git',
......
...@@ -7,6 +7,7 @@ import itertools ...@@ -7,6 +7,7 @@ import itertools
import logging import logging
import operator import operator
import json import json
from uuid import UUID
from django.conf import settings from django.conf import settings
from django.core.cache import cache from django.core.cache import cache
...@@ -222,9 +223,12 @@ def get_submission(submission_uuid, read_replica=False): ...@@ -222,9 +223,12 @@ def get_submission(submission_uuid, read_replica=False):
""" """
if not isinstance(submission_uuid, basestring): if not isinstance(submission_uuid, basestring):
raise SubmissionRequestError( if isinstance(submission_uuid, UUID):
msg="submission_uuid ({!r}) must be a string type".format(submission_uuid) submission_uuid = unicode(submission_uuid)
) else:
raise SubmissionRequestError(
msg="submission_uuid ({!r}) must be serializable".format(submission_uuid)
)
cache_key = Submission.get_cache_key(submission_uuid) cache_key = Submission.get_cache_key(submission_uuid)
try: try:
......
...@@ -4,7 +4,6 @@ from __future__ import unicode_literals ...@@ -4,7 +4,6 @@ from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
import jsonfield.fields import jsonfield.fields
import django.utils.timezone import django.utils.timezone
import django_extensions.db.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):
...@@ -48,7 +47,7 @@ class Migration(migrations.Migration): ...@@ -48,7 +47,7 @@ class Migration(migrations.Migration):
name='Submission', name='Submission',
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('uuid', django_extensions.db.fields.UUIDField(db_index=True, version=1, editable=False, blank=True)), ('uuid', models.UUIDField(db_index=True, editable=False, blank=True)),
('attempt_number', models.PositiveIntegerField()), ('attempt_number', models.PositiveIntegerField()),
('submitted_at', models.DateTimeField(default=django.utils.timezone.now, db_index=True)), ('submitted_at', models.DateTimeField(default=django.utils.timezone.now, db_index=True)),
('created_at', models.DateTimeField(default=django.utils.timezone.now, editable=False, db_index=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now, editable=False, db_index=True)),
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('submissions', '0003_submission_status'),
]
operations = [
migrations.AlterField(
model_name='submission',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, db_index=True),
),
]
...@@ -10,12 +10,12 @@ need to then generate a matching migration for it using: ...@@ -10,12 +10,12 @@ need to then generate a matching migration for it using:
""" """
import logging import logging
from uuid import uuid4
from django.db import models, DatabaseError from django.db import models, DatabaseError
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver, Signal from django.dispatch import receiver, Signal
from django.utils.timezone import now from django.utils.timezone import now
from django_extensions.db.fields import UUIDField
from jsonfield import JSONField from jsonfield import JSONField
...@@ -101,7 +101,7 @@ class Submission(models.Model): ...@@ -101,7 +101,7 @@ class Submission(models.Model):
""" """
MAXSIZE = 1024*100 # 100KB MAXSIZE = 1024*100 # 100KB
uuid = UUIDField(version=1, db_index=True) uuid = models.UUIDField(db_index=True, default=uuid4)
student_item = models.ForeignKey(StudentItem) student_item = models.ForeignKey(StudentItem)
...@@ -196,7 +196,7 @@ class Score(models.Model): ...@@ -196,7 +196,7 @@ class Score(models.Model):
""" """
if self.submission is not None: if self.submission is not None:
return self.submission.uuid return unicode(self.submission.uuid)
else: else:
return None return None
......
...@@ -48,6 +48,7 @@ class TestSubmissionsApi(TestCase): ...@@ -48,6 +48,7 @@ class TestSubmissionsApi(TestCase):
""" """
Clear the cache. Clear the cache.
""" """
super(TestSubmissionsApi, self).setUp()
cache.clear() cache.clear()
@ddt.data(ANSWER_ONE, ANSWER_DICT) @ddt.data(ANSWER_ONE, ANSWER_DICT)
...@@ -67,10 +68,14 @@ class TestSubmissionsApi(TestCase): ...@@ -67,10 +68,14 @@ class TestSubmissionsApi(TestCase):
retrieved = api.get_submission_and_student(submission['uuid']) retrieved = api.get_submission_and_student(submission['uuid'])
self.assertItemsEqual(submission, retrieved) self.assertItemsEqual(submission, retrieved)
# Should raise an exception if the student item does not exist # Should raise an exception if uuid is malformed
with self.assertRaises(api.SubmissionNotFoundError): with self.assertRaises(api.SubmissionInternalError):
api.get_submission_and_student(u'no such uuid') api.get_submission_and_student(u'no such uuid')
# Should raise a different exception if the student item does not exist
with self.assertRaises(api.SubmissionNotFoundError):
api.get_submission_and_student(u'deadbeef-1234-5678-9100-1234deadbeef')
def test_get_submissions(self): def test_get_submissions(self):
api.create_submission(STUDENT_ITEM, ANSWER_ONE) api.create_submission(STUDENT_ITEM, ANSWER_ONE)
api.create_submission(STUDENT_ITEM, ANSWER_TWO) api.create_submission(STUDENT_ITEM, ANSWER_TWO)
...@@ -161,9 +166,7 @@ class TestSubmissionsApi(TestCase): ...@@ -161,9 +166,7 @@ class TestSubmissionsApi(TestCase):
# Test not found # Test not found
with self.assertRaises(api.SubmissionNotFoundError): with self.assertRaises(api.SubmissionNotFoundError):
api.get_submission("notarealuuid") api.get_submission("deadbeef-1234-5678-9100-1234deadbeef")
with self.assertRaises(api.SubmissionNotFoundError):
api.get_submission("0" * 50) # This is bigger than our field size
@patch.object(Submission.objects, 'get') @patch.object(Submission.objects, 'get')
@raises(api.SubmissionInternalError) @raises(api.SubmissionInternalError)
......
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