From 1d825546cb3029854dbbe17adebf8694cfe1d94a Mon Sep 17 00:00:00 2001 From: IluaAir Date: Tue, 30 Sep 2025 18:41:22 +0300 Subject: [PATCH] role fix --- add_tenant_with_prefix.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/add_tenant_with_prefix.py b/add_tenant_with_prefix.py index 6f20d53..73124f6 100644 --- a/add_tenant_with_prefix.py +++ b/add_tenant_with_prefix.py @@ -205,7 +205,7 @@ class CreateTenant(Script): except Exception as e: self.log_failure(f"Ошибка при создании контакта: {e}") try: - role = data.get("contacts_role", ContactRole.objects.first()) + role = data.get("contacts_role") or ContactRole.objects.first() assignment = ContactAssignment( contact=contact, role=role, @@ -242,9 +242,10 @@ class CreateTenant(Script): email=data["contacts_email"], ) contact.full_clean() + role = data.get("contacts_role") or ContactRole.objects.first() assignment = ContactAssignment( contact=contact, - role=data.get("contacts_role", ContactRole.objects.first()), + role=role, object=tenant, ) assignment.full_clean()