Merge pull request #766 from mouse-reeve/decimal-ratings

Make rating a decimal field
This commit is contained in:
Mouse Reeve 2021-03-19 12:42:07 -07:00 committed by GitHub
commit 08327b3a0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View file

@ -0,0 +1,30 @@
# Generated by Django 3.1.6 on 2021-03-19 19:13
import bookwyrm.models.fields
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0052_user_show_goal"),
]
operations = [
migrations.AlterField(
model_name="review",
name="rating",
field=bookwyrm.models.fields.DecimalField(
blank=True,
decimal_places=2,
default=None,
max_digits=3,
null=True,
validators=[
django.core.validators.MinValueValidator(1),
django.core.validators.MaxValueValidator(5),
],
),
),
]

View file

@ -444,3 +444,7 @@ class BooleanField(ActivitypubFieldMixin, models.BooleanField):
class IntegerField(ActivitypubFieldMixin, models.IntegerField):
""" activitypub-aware boolean field """
class DecimalField(ActivitypubFieldMixin, models.DecimalField):
""" activitypub-aware boolean field """

View file

@ -273,11 +273,13 @@ class Review(Status):
book = fields.ForeignKey(
"Edition", on_delete=models.PROTECT, activitypub_field="inReplyToBook"
)
rating = fields.IntegerField(
rating = fields.DecimalField(
default=None,
null=True,
blank=True,
validators=[MinValueValidator(1), MaxValueValidator(5)],
decimal_places=2,
max_digits=3,
)
@property