diff --git a/bookwyrm/migrations/0053_auto_20210319_1913.py b/bookwyrm/migrations/0053_auto_20210319_1913.py new file mode 100644 index 00000000..be086cd2 --- /dev/null +++ b/bookwyrm/migrations/0053_auto_20210319_1913.py @@ -0,0 +1,20 @@ +# 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)]), + ), + ] diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index 1bdc6c45..247c6aca 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -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 """ diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 0e18dc1b..09a7c4ec 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -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