fix: add missing RoleService import and improve admin buttons layout

- Fixed UnboundLocalError by importing RoleService before use
- Changed action buttons to vertical stack layout to prevent overlap
- Buttons now use flexbox column layout with proper spacing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-01 22:20:14 +03:00
parent 4da6d6922e
commit 4404bebba7

View File

@@ -144,8 +144,10 @@ class TenantRegistrationAdmin(admin.ModelAdmin):
if obj.status == TenantRegistration.STATUS_PENDING: if obj.status == TenantRegistration.STATUS_PENDING:
approve_url = reverse('admin:tenants_tenantregistration_change', args=[obj.pk]) approve_url = reverse('admin:tenants_tenantregistration_change', args=[obj.pk])
return format_html( return format_html(
'<a class="button" href="{}?approve=1" style="background: #417690; color: white; padding: 5px 10px; text-decoration: none; border-radius: 3px; margin-right: 5px;">Активировать</a> ' '<div style="display: flex; flex-direction: column; gap: 5px; min-width: 140px;">'
'<a class="button" href="{}?reject=1" style="background: #ba2121; color: white; padding: 5px 10px; text-decoration: none; border-radius: 3px;">Отклонить</a>', '<a class="button" href="{}?approve=1" style="background: #417690; color: white; padding: 5px 10px; text-decoration: none; border-radius: 3px; text-align: center; display: block; white-space: nowrap;">Активировать</a>'
'<a class="button" href="{}?reject=1" style="background: #ba2121; color: white; padding: 5px 10px; text-decoration: none; border-radius: 3px; text-align: center; display: block; white-space: nowrap;">Отклонить</a>'
'</div>',
approve_url, approve_url approve_url, approve_url
) )
elif obj.status == TenantRegistration.STATUS_APPROVED: elif obj.status == TenantRegistration.STATUS_APPROVED:
@@ -350,6 +352,7 @@ class TenantRegistrationAdmin(admin.ModelAdmin):
# Назначаем роль owner владельцу # Назначаем роль owner владельцу
try: try:
from user_roles.models import Role from user_roles.models import Role
from user_roles.services import RoleService
RoleService.assign_role_to_user(owner, Role.OWNER, created_by=None) RoleService.assign_role_to_user(owner, Role.OWNER, created_by=None)
logger.info(f"Роль owner назначена владельцу {owner.email}") logger.info(f"Роль owner назначена владельцу {owner.email}")
except Exception as e: except Exception as e: