Commit 57eff5b6 by Oleg Marshev

Allow text field be blank.

parent 37b20911
...@@ -11,7 +11,7 @@ class Note(models.Model): ...@@ -11,7 +11,7 @@ class Note(models.Model):
course_id = models.CharField(max_length=255, db_index=True) course_id = models.CharField(max_length=255, db_index=True)
usage_id = models.CharField(max_length=255, help_text="ID of XBlock where the text comes from") usage_id = models.CharField(max_length=255, help_text="ID of XBlock where the text comes from")
quote = models.TextField(default="") quote = models.TextField(default="")
text = models.TextField(default="", help_text="Student's thoughts on the quote") text = models.TextField(default="", blank=True, help_text="Student's thoughts on the quote")
ranges = models.TextField(help_text="JSON, describes position of quote in the source text") ranges = models.TextField(help_text="JSON, describes position of quote in the source text")
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)
......
...@@ -104,6 +104,16 @@ class AnnotationListViewTests(BaseAnnotationViewTests): ...@@ -104,6 +104,16 @@ class AnnotationListViewTests(BaseAnnotationViewTests):
self.assertEqual(response.data['user'], TEST_USER) self.assertEqual(response.data['user'], TEST_USER)
def test_create_blank_text(self):
"""
Ensure we can create a new note with empty text field.
"""
url = reverse('api:v1:annotations')
self.payload['text'] = ''
response = self.client.post(url, self.payload, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.data['text'], '')
def test_create_ignore_created(self): def test_create_ignore_created(self):
""" """
Test if annotation 'created' field is not used by API. Test if annotation 'created' field is not used by API.
......
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