mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-18 07:33:57 +00:00
Make rating a decimal field
This commit is contained in:
parent
5f1bed3d78
commit
266c6fe777
3 changed files with 27 additions and 1 deletions
20
bookwyrm/migrations/0053_auto_20210319_1913.py
Normal file
20
bookwyrm/migrations/0053_auto_20210319_1913.py
Normal file
|
@ -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)]),
|
||||
),
|
||||
]
|
|
@ -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 """
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue