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 20, 2025
1 parent 577c932 commit 1ba0403
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
4 changes: 1 addition & 3 deletions apis_core/apis_metainfo/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
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 1ba0403

Please sign in to comment.