Skip to content

Commit

Permalink
feat(apis_entities): update create_default_uri to use generic uri
Browse files Browse the repository at this point in the history
The Uri model now uses a generic foreign key instead of the direct
foreign key to the RootObject. This commit updates all occurences
of `root_object` to use the generic foreign key instead.
  • Loading branch information
b1rger committed Dec 20, 2024
1 parent c9b050b commit e86399f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apis_core/apis_entities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re

from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.urls import NoReverseMatch, reverse
Expand Down Expand Up @@ -102,4 +103,9 @@ def create_default_uri(sender, instance, created, raw, using, update_fields, **k
"apis_core:GetEntityGeneric", kwargs={"pk": instance.pk}
)
uri = f"{base}{route}"
Uri.objects.create(uri=uri, root_object=instance)
content_type = ContentType.objects.get_for_model(instance)
Uri.objects.create(
uri=uri,
content_type=content_type,
object_id=instance.id,
)

0 comments on commit e86399f

Please sign in to comment.