unit tests

This commit is contained in:
Rachid Mrad 2024-10-02 18:12:40 -04:00
parent 4df509c4f7
commit 0ea37d7113
No known key found for this signature in database
2 changed files with 21 additions and 27 deletions

View file

@ -2013,8 +2013,17 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
should_proceed = False
return (obj, should_proceed)
request_is_not_approved = original_obj.status != models.DomainRequest.DomainRequestStatus.APPROVED
if request_is_not_approved and Domain.objects.filter(name=original_obj.requested_domain.name).exists():
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