Merge branch 'main' into portuguese

This commit is contained in:
Mouse Reeve 2022-01-04 13:28:19 -08:00
commit 10792125ae
2 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 3.2.5 on 2022-01-04 18:59
import bookwyrm.models.user
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0121_user_summary_keys"),
]
operations = [
migrations.AlterField(
model_name="annualgoal",
name="year",
field=models.IntegerField(default=bookwyrm.models.user.get_current_year),
),
]

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
)