From 252ebf8ce73dd1b6c9d68b789552384adb5fc081 Mon Sep 17 00:00:00 2001 From: petitminion Date: Sun, 23 Jan 2022 10:52:41 +0000 Subject: [PATCH] Remove usage of deprecated Model and Serializer fields (#1663) --- api/config/settings/common.py | 3 +++ api/funkwhale_api/audio/models.py | 2 +- api/funkwhale_api/common/models.py | 6 +++--- api/funkwhale_api/federation/models.py | 6 +++--- api/funkwhale_api/federation/serializers.py | 4 +++- api/funkwhale_api/moderation/models.py | 2 +- api/funkwhale_api/music/models.py | 2 +- api/funkwhale_api/radios/models.py | 2 +- api/funkwhale_api/users/models.py | 2 +- changes/changelog.d/1663-bugfix | 1 + 10 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 changes/changelog.d/1663-bugfix diff --git a/api/config/settings/common.py b/api/config/settings/common.py index d9b2df10c..179c01be4 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -381,6 +381,9 @@ MIGRATION_MODULES = { "sites": "funkwhale_api.contrib.sites.migrations", } +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" +# see https://docs.djangoproject.com/en/4.0/releases/3.2/ + # GENERAL CONFIGURATION # ------------------------------------------------------------------------------ # Local time zone for this installation. Choices can be found here: diff --git a/api/funkwhale_api/audio/models.py b/api/funkwhale_api/audio/models.py index 15e40f4d9..2955bc3fa 100644 --- a/api/funkwhale_api/audio/models.py +++ b/api/funkwhale_api/audio/models.py @@ -2,7 +2,7 @@ import uuid from django.contrib.contenttypes.fields import GenericRelation -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.core.serializers.json import DjangoJSONEncoder from django.db import models from django.urls import reverse diff --git a/api/funkwhale_api/common/models.py b/api/funkwhale_api/common/models.py index 3107fd583..9dd19c2ec 100644 --- a/api/funkwhale_api/common/models.py +++ b/api/funkwhale_api/common/models.py @@ -2,7 +2,7 @@ import uuid import magic import mimetypes -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.conf import settings @@ -116,10 +116,10 @@ class Mutation(models.Model): type = models.CharField(max_length=100, db_index=True) # None = no choice, True = approved, False = refused - is_approved = models.NullBooleanField(default=None) + is_approved = models.BooleanField(default=None, null=True) # None = not applied, True = applied, False = failed - is_applied = models.NullBooleanField(default=None) + is_applied = models.BooleanField(default=None, null=True) creation_date = models.DateTimeField(default=timezone.now, db_index=True) applied_date = models.DateTimeField(null=True, blank=True, db_index=True) summary = models.TextField(max_length=2000, null=True, blank=True) diff --git a/api/funkwhale_api/federation/models.py b/api/funkwhale_api/federation/models.py index c3868d737..d9ea20180 100644 --- a/api/funkwhale_api/federation/models.py +++ b/api/funkwhale_api/federation/models.py @@ -3,7 +3,7 @@ import urllib.parse import uuid from django.conf import settings -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist @@ -198,7 +198,7 @@ class Actor(models.Model): private_key = models.TextField(max_length=5000, null=True, blank=True) creation_date = models.DateTimeField(default=timezone.now) last_fetch_date = models.DateTimeField(default=timezone.now) - manually_approves_followers = models.NullBooleanField(default=None) + manually_approves_followers = models.BooleanField(default=None, null=True) followers = models.ManyToManyField( to="self", symmetrical=False, @@ -488,7 +488,7 @@ class AbstractFollow(models.Model): uuid = models.UUIDField(default=uuid.uuid4, unique=True) creation_date = models.DateTimeField(default=timezone.now) modification_date = models.DateTimeField(auto_now=True) - approved = models.NullBooleanField(default=None) + approved = models.BooleanField(default=None, null=True) class Meta: abstract = True diff --git a/api/funkwhale_api/federation/serializers.py b/api/funkwhale_api/federation/serializers.py index d86dc6ff0..d3263507b 100644 --- a/api/funkwhale_api/federation/serializers.py +++ b/api/funkwhale_api/federation/serializers.py @@ -237,7 +237,9 @@ class ActorSerializer(jsonld.JsonLdSerializer): choices=[getattr(contexts.AS, c[0]) for c in models.TYPE_CHOICES] ) preferredUsername = serializers.CharField() - manuallyApprovesFollowers = serializers.NullBooleanField(required=False) + manuallyApprovesFollowers = serializers.BooleanField( + required=False, allow_null=True + ) name = serializers.CharField( required=False, max_length=200, allow_blank=True, allow_null=True ) diff --git a/api/funkwhale_api/moderation/models.py b/api/funkwhale_api/moderation/models.py index 7e59729e9..86086393c 100644 --- a/api/funkwhale_api/moderation/models.py +++ b/api/funkwhale_api/moderation/models.py @@ -3,7 +3,7 @@ import uuid from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.db import models from django.db.models.signals import pre_save from django.dispatch import receiver diff --git a/api/funkwhale_api/music/models.py b/api/funkwhale_api/music/models.py index 563f41792..82464e40a 100644 --- a/api/funkwhale_api/music/models.py +++ b/api/funkwhale_api/music/models.py @@ -12,7 +12,7 @@ import arrow import pydub from django.conf import settings from django.contrib.contenttypes.fields import GenericRelation -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.contrib.postgres.search import SearchVectorField from django.contrib.postgres.indexes import GinIndex from django.core.exceptions import ObjectDoesNotExist diff --git a/api/funkwhale_api/radios/models.py b/api/funkwhale_api/radios/models.py index d0c3d1716..8cb56cb92 100644 --- a/api/funkwhale_api/radios/models.py +++ b/api/funkwhale_api/radios/models.py @@ -1,6 +1,6 @@ from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.core.serializers.json import DjangoJSONEncoder from django.db import models from django.utils import timezone diff --git a/api/funkwhale_api/users/models.py b/api/funkwhale_api/users/models.py index a07b92efa..cb431e1aa 100644 --- a/api/funkwhale_api/users/models.py +++ b/api/funkwhale_api/users/models.py @@ -9,7 +9,7 @@ import uuid from django.conf import settings from django.contrib.auth.models import AbstractUser, UserManager as BaseUserManager -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.db import models, transaction from django.dispatch import receiver from django.urls import reverse diff --git a/changes/changelog.d/1663-bugfix b/changes/changelog.d/1663-bugfix new file mode 100644 index 000000000..705938dff --- /dev/null +++ b/changes/changelog.d/1663-bugfix @@ -0,0 +1 @@ +Remove usage of deprecated Model and Serializer fields (#1663)