From 0b3b58838a61e26cd404900837a8e6858bbc4814 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Mon, 13 Jan 2025 12:13:26 +0100 Subject: [PATCH] chore(apis_metainfo): drop unused field classes The InheritanceForeignKey was previously used by the Uri model instead of a foreign key. After refactoring the Uri to use a generic foreign key, this can be dropped. --- apis_core/apis_metainfo/migrations/0001_initial.py | 4 +--- apis_core/apis_metainfo/models.py | 12 ------------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/apis_core/apis_metainfo/migrations/0001_initial.py b/apis_core/apis_metainfo/migrations/0001_initial.py index fa77246e3..568e14ad4 100644 --- a/apis_core/apis_metainfo/migrations/0001_initial.py +++ b/apis_core/apis_metainfo/migrations/0001_initial.py @@ -3,8 +3,6 @@ import django.db.models.deletion from django.db import migrations, models -import apis_core.apis_metainfo.models - class Migration(migrations.Migration): initial = True @@ -126,7 +124,7 @@ class Migration(migrations.Migration): ("loaded_time", models.DateTimeField(blank=True, null=True)), ( "root_object", - apis_core.apis_metainfo.models.InheritanceForeignKey( + models.ForeignKey( blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, diff --git a/apis_core/apis_metainfo/models.py b/apis_core/apis_metainfo/models.py index 0dfcb6219..a81abdd8f 100644 --- a/apis_core/apis_metainfo/models.py +++ b/apis_core/apis_metainfo/models.py @@ -4,7 +4,6 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models -from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor from model_utils.managers import InheritanceManager from apis_core.generic.abc import GenericModel @@ -37,17 +36,6 @@ def save(self, *args, **kwargs): super().save(*args, **kwargs) -class InheritanceForwardManyToOneDescriptor(ForwardManyToOneDescriptor): - def get_queryset(self, **hints): - return self.field.remote_field.model.objects_inheritance.db_manager( - hints=hints - ).select_subclasses() - - -class InheritanceForeignKey(models.ForeignKey): - forward_related_accessor_class = InheritanceForwardManyToOneDescriptor - - # Uri model # We use a custom UriManager, so we can override the queryset `get` # method. This way we can normalize the uri field.