phase3: add normalized domain schema, admin, services, and multistage docker build

This commit is contained in:
Alfredo Di Stasio
2026-03-10 10:39:45 +01:00
parent f47ffe6c15
commit fc7289a343
30 changed files with 1548 additions and 3 deletions

View File

View File

@ -0,0 +1,19 @@
from django.contrib.contenttypes.models import ContentType
from apps.providers.models import ExternalMapping
def upsert_external_mapping(*, provider_namespace: str, external_id: str, instance, raw_payload: dict | None = None) -> ExternalMapping:
"""Create or update a provider mapping for any internal model instance."""
content_type = ContentType.objects.get_for_model(instance.__class__)
mapping, _ = ExternalMapping.objects.update_or_create(
provider_namespace=provider_namespace,
content_type=content_type,
object_id=instance.pk,
defaults={
"external_id": external_id,
"raw_payload": raw_payload or {},
"is_active": True,
},
)
return mapping