mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-24 02:21:04 +00:00
commit
243e998fbf
4 changed files with 25 additions and 3 deletions
19
bookwyrm/migrations/0038_auto_20210119_1534.py
Normal file
19
bookwyrm/migrations/0038_auto_20210119_1534.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.7 on 2021-01-19 15:34
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bookwyrm', '0037_auto_20210118_1954'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='annualgoal',
|
||||
name='goal',
|
||||
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1)]),
|
||||
),
|
||||
]
|
|
@ -4,6 +4,7 @@ from urllib.parse import urlparse
|
|||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.db import models
|
||||
from django.dispatch import receiver
|
||||
from django.utils import timezone
|
||||
|
@ -226,7 +227,9 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
|
|||
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()
|
||||
goal = models.IntegerField(
|
||||
validators=[MinValueValidator(1)]
|
||||
)
|
||||
year = models.IntegerField(default=timezone.now().year)
|
||||
privacy = models.CharField(
|
||||
max_length=255,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<label class="label" for="id_goal">Reading goal:</label>
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<input type="number" class="input" name="goal" id="id_goal" value="{% if goal %}{{ goal.goal }}{% else %}12{% endif %}">
|
||||
<input type="number" class="input" name="goal" min="1" id="id_goal" value="{% if goal %}{{ goal.goal }}{% else %}12{% endif %}">
|
||||
</div>
|
||||
<p class="button is-static" aria-hidden="true">books</p>
|
||||
</div>
|
||||
|
|
|
@ -52,7 +52,7 @@ class Goal(View):
|
|||
form = forms.GoalForm(request.POST, instance=goal)
|
||||
if not form.is_valid():
|
||||
data = {
|
||||
'title': '%s\'s %d Reading' % (goal.user.display_name, year),
|
||||
'title': '%s\'s %d Reading' % (request.user.display_name, year),
|
||||
'goal_form': form,
|
||||
'goal': goal,
|
||||
'year': year,
|
||||
|
|
Loading…
Reference in a new issue