merged in main again

This commit is contained in:
David Kennedy 2024-02-26 19:22:44 -05:00
commit af849adbea
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
8 changed files with 655 additions and 100 deletions

View file

@ -902,7 +902,7 @@ class DomainApplicationAdmin(ListHeaderAdmin):
custom_election_board.short_description = "Election office" # type: ignore
# Filters
list_filter = ("status", "organization_type", "federal_type", ElectionOfficeFilter, InvestigatorFilter)
list_filter = ("status", "organization_type", "federal_type", ElectionOfficeFilter, "rejection_reason", InvestigatorFilter)
# Search
search_fields = [
@ -916,7 +916,7 @@ class DomainApplicationAdmin(ListHeaderAdmin):
# Detail view
form = DomainApplicationAdminForm
fieldsets = [
(None, {"fields": ["status", "investigator", "creator", "approved_domain", "notes"]}),
(None, {"fields": ["status", "rejection_reason", "investigator", "creator", "approved_domain", "notes"]}),
(
"Type of organization",
{
@ -1017,6 +1017,23 @@ class DomainApplicationAdmin(ListHeaderAdmin):
"This action is not permitted. The domain is already active.",
)
elif (
obj
and obj.status == models.DomainApplication.ApplicationStatus.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)
# because we clean up the rejection reason in the transition in the model.
# Clear the success message
messages.set_level(request, messages.ERROR)
messages.error(
request,
"A rejection reason is required.",
)
else:
if obj.status != original_obj.status:
status_method_mapping = {