many fixes of backeend and fronteend

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-06 16:41:35 +00:00
parent a0eee0df42
commit bfb07947ea
19 changed files with 638 additions and 19 deletions

View File

@@ -181,7 +181,26 @@ class AccountModelViewSet(viewsets.ModelViewSet):
"""
try:
instance = self.get_object()
self.perform_destroy(instance)
# Protect system account
if hasattr(instance, 'slug') and getattr(instance, 'slug', '') == 'aws-admin':
from django.core.exceptions import PermissionDenied
raise PermissionDenied("System account cannot be deleted.")
if hasattr(instance, 'soft_delete'):
user = getattr(request, 'user', None)
retention_days = None
account = getattr(instance, 'account', None)
if account and hasattr(account, 'deletion_retention_days'):
retention_days = account.deletion_retention_days
elif hasattr(instance, 'deletion_retention_days'):
retention_days = getattr(instance, 'deletion_retention_days', None)
instance.soft_delete(
user=user if getattr(user, 'is_authenticated', False) else None,
retention_days=retention_days,
reason='api_delete'
)
else:
self.perform_destroy(instance)
return success_response(
data=None,
message='Deleted successfully',