Uses function to get current year for annual goal default

This commit is contained in:
Mouse Reeve
2022-01-04 11:00:21 -08:00
parent cccd28cb74
commit aa1a7189ae
2 changed files with 25 additions and 1 deletions

View File

@ -415,12 +415,17 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
return activity_object
def get_current_year():
"""sets default year for annual goal to this year"""
return timezone.now().year
class AnnualGoal(BookWyrmModel):
"""set a goal for how many books you read in a year"""
user = models.ForeignKey("User", on_delete=models.PROTECT)
goal = models.IntegerField(validators=[MinValueValidator(1)])
year = models.IntegerField(default=timezone.now().year)
year = models.IntegerField(default=get_current_year)
privacy = models.CharField(
max_length=255, default="public", choices=fields.PrivacyLevels.choices
)