Formatting

This commit is contained in:
Mouse Reeve 2021-03-20 17:39:05 -07:00
parent dd15e87073
commit 2a612f7278
4 changed files with 36 additions and 10 deletions

View file

@ -76,7 +76,16 @@ class ReviewForm(CustomForm):
class CommentForm(CustomForm):
class Meta:
model = models.Comment
fields = ["user", "book", "content", "content_warning", "sensitive", "privacy", "progress", "mode"]
fields = [
"user",
"book",
"content",
"content_warning",
"sensitive",
"privacy",
"progress",
"mode",
]
class QuotationForm(CustomForm):

View file

@ -7,18 +7,28 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0054_auto_20210319_1942'),
("bookwyrm", "0054_auto_20210319_1942"),
]
operations = [
migrations.AddField(
model_name='comment',
name='mode',
field=models.CharField(blank=True, choices=[('PG', 'page'), ('PCT', 'percent')], default='PG', max_length=3, null=True),
model_name="comment",
name="mode",
field=models.CharField(
blank=True,
choices=[("PG", "page"), ("PCT", "percent")],
default="PG",
max_length=3,
null=True,
),
),
migrations.AddField(
model_name='comment',
name='progress',
field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)]),
model_name="comment",
name="progress",
field=models.IntegerField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(0)],
),
),
]

View file

@ -8,6 +8,7 @@ from .base_model import BookWyrmModel
class ProgressMode(models.TextChoices):
""" types of prgress available """
PAGE = "PG", "page"
PERCENT = "PCT", "percent"

View file

@ -232,9 +232,15 @@ class Comment(Status):
# this is it's own field instead of a foreign key to the progress update
# so that the update can be deleted without impacting the status
progress = models.IntegerField(validators=[MinValueValidator(0)], null=True, blank=True)
progress = models.IntegerField(
validators=[MinValueValidator(0)], null=True, blank=True
)
mode = models.CharField(
max_length=3, choices=ProgressMode.choices, default=ProgressMode.PAGE, null=True, blank=True
max_length=3,
choices=ProgressMode.choices,
default=ProgressMode.PAGE,
null=True,
blank=True,
)
@property