fix(db-router): allow relation between prowler_user and the rest

This commit is contained in:
Víctor Fernández Poyatos
2025-05-21 12:36:32 +02:00
parent 75db2ace1b
commit 6ab6099afc
+3 -1
View File
@@ -4,9 +4,11 @@ ALLOWED_APPS = ("django", "socialaccount", "account", "authtoken", "silk")
class MainRouter:
default_db = "default"
default_read = "default_read"
prowler_user = "prowler_user"
admin_db = "admin"
admin_read = "admin_read"
def db_for_read(self, model, **hints): # noqa: F841
model_table_name = model._meta.db_table
if any(model_table_name.startswith(f"{app}_") for app in ALLOWED_APPS):
@@ -24,7 +26,7 @@ class MainRouter:
def allow_relation(self, obj1, obj2, **hints): # noqa: F841
# Allow relations if both objects are using one of our defined connectors
allowed = {self.default_db, self.default_read, self.admin_db, self.admin_read}
allowed = {self.default_db, self.default_read, self.admin_db, self.admin_read, self.prowler_user}
if {obj1._state.db, obj2._state.db} <= allowed:
return True
return None