Commit c1f4d3dea43e05668fd8b98934aa775a4e2db19d
1 parent
c2b6dc8528
Exists in
master
Fix section flashcard list; added default datetimes
Showing 3 changed files with 6 additions and 4 deletions Side-by-side Diff
flashcards/models.py
View file @
c1f4d3d
... | ... | @@ -84,7 +84,7 @@ |
84 | 84 | text = CharField(max_length=255, help_text='The text on the card') |
85 | 85 | section = ForeignKey('Section', help_text='The section with which the card is associated') |
86 | 86 | pushed = DateTimeField(auto_now_add=True, help_text="When the card was first pushed") |
87 | - material_date = DateTimeField(help_text="The date with which the card is associated") | |
87 | + material_date = DateTimeField(default=now, help_text="The date with which the card is associated") | |
88 | 88 | previous = ForeignKey('Flashcard', null=True, blank=True, |
89 | 89 | help_text="The previous version of this card, if one exists") |
90 | 90 | author = ForeignKey(User) |
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | An event of a user being quizzed on a flashcard. |
122 | 122 | """ |
123 | 123 | user_flashcard = ForeignKey(UserFlashcard) |
124 | - when = DateTimeField() | |
124 | + when = DateTimeField(auto_now=True) | |
125 | 125 | blanked_word = CharField(max_length=8, blank=True, help_text="The character range which was blanked") |
126 | 126 | response = CharField(max_length=255, blank=True, null=True, help_text="The user's response") |
127 | 127 | correct = NullBooleanField(help_text="The user's self-evaluation of their response") |
flashcards/serializers.py
View file @
c1f4d3d
1 | 1 | from django.utils.datetime_safe import datetime |
2 | +from django.utils.timezone import now | |
2 | 3 | import pytz |
3 | 4 | from flashcards.models import Section, LecturePeriod, User, Flashcard |
4 | 5 | from flashcards.validators import FlashcardMask, OverlapIntervalException |
5 | 6 | from rest_framework import serializers |
6 | -from rest_framework.fields import EmailField, BooleanField, CharField, IntegerField | |
7 | +from rest_framework.fields import EmailField, BooleanField, CharField, IntegerField, DateTimeField | |
7 | 8 | from rest_framework.relations import HyperlinkedRelatedField |
8 | 9 | from rest_framework.serializers import ModelSerializer, Serializer |
9 | 10 | from rest_framework.validators import UniqueValidator |
... | ... | @@ -114,6 +115,7 @@ |
114 | 115 | class FlashcardSerializer(ModelSerializer): |
115 | 116 | is_hidden = BooleanField(read_only=True) |
116 | 117 | hide_reason = CharField(read_only=True) |
118 | + material_date = DateTimeField(default=now) | |
117 | 119 | mask = MaskFieldSerializer() |
118 | 120 | |
119 | 121 | def validate_material_date(self, value): |
flashcards/views.py
View file @
c1f4d3d
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | flashcards = Flashcard.cards_visible_to(request.user).filter( \ |
34 | 34 | section=self.get_object(), is_hidden=False).all() |
35 | 35 | |
36 | - return Response(FlashcardSerializer(flashcards, many=True)) | |
36 | + return Response(FlashcardSerializer(flashcards, many=True).data) | |
37 | 37 | |
38 | 38 | @detail_route(methods=['post'], permission_classes=[IsAuthenticated]) |
39 | 39 | def enroll(self, request, pk): |