diff --git a/flashcards/models.py b/flashcards/models.py index 1b79d9c..0fceff2 100644 --- a/flashcards/models.py +++ b/flashcards/models.py @@ -10,6 +10,7 @@ from django.core.mail import send_mail from django.db import IntegrityError from django.db.models import * from django.utils.timezone import now, make_aware +from flashy.settings import QUARTER_START from simple_email_confirmation import SimpleEmailConfirmationUserMixin from fields import MaskField from cached_property import cached_property @@ -188,6 +189,10 @@ class Flashcard(Model): # By default, order by most recently pushed ordering = ['-pushed'] + @property + def material_week_num(self): + return (self.material_date-QUARTER_START).days/7+1 + def is_hidden_from(self, user): """ A card can be hidden globally, but if a user has the card in their deck, diff --git a/flashcards/serializers.py b/flashcards/serializers.py index cdc8c4f..a476ce7 100644 --- a/flashcards/serializers.py +++ b/flashcards/serializers.py @@ -125,6 +125,7 @@ class FlashcardSerializer(ModelSerializer): is_hidden = SerializerMethodField() is_in_deck = SerializerMethodField() # hide_reason = CharField(read_only=True) + material_week_num = IntegerField(read_only=True) material_date = DateTimeField(default=now) mask = MaskFieldSerializer(allow_null=True) score = FloatField(read_only=True)