From d723825b12d0b60e99388bc030329d01f76f3068 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Wed, 2 Oct 2024 19:17:11 -0400 Subject: [PATCH] cleanup --- src/registrar/admin.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 321014949..dcd7bee99 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -2014,21 +2014,14 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): return (obj, should_proceed) obj_is_not_approved = obj.status != models.DomainRequest.DomainRequestStatus.APPROVED - original_obj_is_not_approved = original_obj.status != models.DomainRequest.DomainRequestStatus.APPROVED if obj_is_not_approved and not obj.domain_is_not_active(): - # If an admin tried to set an approved domain request to - # another status and the related domain is already - # active (READY), shortcut the action and throw a friendly - # error message. This action would still not go through - # shortcut or not as the rules are duplicated on the model, - # but the error would be an ugly Django error screen. - error_message = "This action is not permitted. The domain is already active." - if original_obj_is_not_approved and Domain.objects.filter(name=original_obj.requested_domain.name).exists(): - # REDUNDANT CHECK: - # This action (approving a request when the domain is active) - # would still not go through check or not as the rules are + # REDUNDANT CHECK / ERROR SCREEN AVOIDANCE: + # This action (moving a request from approved to + # another status when the domain is already active (READY), + # would still not go through even without this check as the rules are # duplicated in the model and the error is raised from the model. - error_message = FSMDomainRequestError.get_error_message(FSMErrorCodes.APPROVE_DOMAIN_IN_USE) + # This avoids an ugly Django error screen. + error_message = "This action is not permitted. The domain is already active." elif obj.status == models.DomainRequest.DomainRequestStatus.REJECTED and not obj.rejection_reason: # This condition should never be triggered. # The opposite of this condition is acceptable (rejected -> other status and rejection_reason)