mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 02:36:02 +02:00
cleanup admin code
This commit is contained in:
parent
d73d611cab
commit
6162a26ee9
4 changed files with 1040 additions and 1091 deletions
|
@ -2009,18 +2009,17 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
# If the status is not mapped properly, saving could cause
|
# If the status is not mapped properly, saving could cause
|
||||||
# weird issues down the line. Instead, we should block this.
|
# weird issues down the line. Instead, we should block this.
|
||||||
|
# NEEDS A UNIT TEST
|
||||||
should_proceed = False
|
should_proceed = False
|
||||||
return should_proceed
|
return (obj, should_proceed)
|
||||||
|
|
||||||
request_is_not_approved = obj.status != models.DomainRequest.DomainRequestStatus.APPROVED
|
request_is_not_approved = original_obj.status != models.DomainRequest.DomainRequestStatus.APPROVED
|
||||||
if request_is_not_approved and not obj.domain_is_not_active():
|
if request_is_not_approved and Domain.objects.filter(name=original_obj.requested_domain.name).exists():
|
||||||
# If an admin tried to set an approved domain request to
|
# REDUNDANT CHECK:
|
||||||
# another status and the related domain is already
|
# This action (approving a request when the domain is active)
|
||||||
# active, shortcut the action and throw a friendly
|
# would still not go through check or not as the rules are
|
||||||
# error message. This action would still not go through
|
# duplicated in the model and the error is raised from the model.
|
||||||
# shortcut or not as the rules are duplicated on the model,
|
error_message = FSMDomainRequestError.get_error_message(FSMErrorCodes.APPROVE_DOMAIN_IN_USE)
|
||||||
# but the error would be 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:
|
elif obj.status == models.DomainRequest.DomainRequestStatus.REJECTED and not obj.rejection_reason:
|
||||||
# This condition should never be triggered.
|
# This condition should never be triggered.
|
||||||
# The opposite of this condition is acceptable (rejected -> other status and rejection_reason)
|
# The opposite of this condition is acceptable (rejected -> other status and rejection_reason)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
1030
src/registrar/tests/test_models_requests.py
Normal file
1030
src/registrar/tests/test_models_requests.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -95,7 +95,7 @@ class FSMDomainRequestError(Exception):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_error_mapping = {
|
_error_mapping = {
|
||||||
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: ("Cannot approve. Requested domain is already in use."),
|
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: ("The domain name for this request is already in use. The name will need to be updated before this request can be approved."),
|
||||||
FSMErrorCodes.NO_INVESTIGATOR: ("Investigator is required for this status."),
|
FSMErrorCodes.NO_INVESTIGATOR: ("Investigator is required for this status."),
|
||||||
FSMErrorCodes.INVESTIGATOR_NOT_STAFF: ("Investigator is not a staff user."),
|
FSMErrorCodes.INVESTIGATOR_NOT_STAFF: ("Investigator is not a staff user."),
|
||||||
FSMErrorCodes.NO_REJECTION_REASON: ("A reason is required for this status."),
|
FSMErrorCodes.NO_REJECTION_REASON: ("A reason is required for this status."),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue