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