Skip to content

Commit

Permalink
chore(apis_metainfo): drop unused field classes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
b1rger committed Jan 13, 2025
1 parent 577c932 commit dd5aec8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
10 changes: 1 addition & 9 deletions apis_core/apis_metainfo/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,7 @@ class Migration(migrations.Migration):
("rdf_link", models.URLField(blank=True)),
("loaded", models.BooleanField(default=False)),
("loaded_time", models.DateTimeField(blank=True, null=True)),
(
"root_object",
apis_core.apis_metainfo.models.InheritanceForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="apis_metainfo.rootobject",
),
),
("root_object", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="apis_metainfo.rootobject")),
],
),
]
12 changes: 0 additions & 12 deletions apis_core/apis_metainfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit dd5aec8

Please sign in to comment.