feat(lighthouse): auto-create tenant config on PATCH

This commit is contained in:
Chandrapal Badshah
2025-10-07 12:39:25 +05:30
parent 0f06ec2593
commit 774211df2b
+6 -2
View File
@@ -4415,8 +4415,12 @@ class LighthouseTenantConfigViewSet(BaseRLSViewSet):
return Response(serializer.data)
def partial_update(self, request, *args, **kwargs):
"""PATCH endpoint for singleton - no pk required."""
instance = self.get_object()
"""PATCH endpoint for singleton - no pk required. Auto-creates if not exists."""
# Auto-create tenant config if it doesn't exist (upsert semantics)
instance, created = LighthouseTenantConfiguration.objects.get_or_create(
tenant_id=self.request.tenant_id,
defaults={},
)
# Extract attributes from JSON:API payload
try: