mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
Merge remote-tracking branch 'origin/main' into rjm/680-admin-workshop
This commit is contained in:
commit
0ee7e71fc1
11 changed files with 428 additions and 98 deletions
|
@ -214,16 +214,26 @@ class DomainApplicationAdmin(ListHeaderAdmin):
|
|||
# Get the original application from the database
|
||||
original_obj = models.DomainApplication.objects.get(pk=obj.pk)
|
||||
|
||||
if (
|
||||
obj.status != original_obj.status
|
||||
and obj.status == models.DomainApplication.INVESTIGATING
|
||||
):
|
||||
# This is a transition annotated method in model which will throw an
|
||||
# error if the condition is violated. To make this work, we need to
|
||||
# call it on the original object which has the right status value,
|
||||
# but pass the current object which contains the up-to-date data
|
||||
# for the email.
|
||||
original_obj.in_review(obj)
|
||||
if obj.status != original_obj.status:
|
||||
if obj.status == models.DomainApplication.STARTED:
|
||||
# No conditions
|
||||
pass
|
||||
elif obj.status == models.DomainApplication.SUBMITTED:
|
||||
# This is an fsm in model which will throw an error if the
|
||||
# transition condition is violated, so we call it on the
|
||||
# original object which has the right status value, and pass
|
||||
# the updated object which contains the up-to-date data
|
||||
# for the side effects (like an email send). Same
|
||||
# comment applies to original_obj method calls below.
|
||||
original_obj.submit(updated_domain_application=obj)
|
||||
elif obj.status == models.DomainApplication.INVESTIGATING:
|
||||
original_obj.in_review(updated_domain_application=obj)
|
||||
elif obj.status == models.DomainApplication.APPROVED:
|
||||
original_obj.approve(updated_domain_application=obj)
|
||||
elif obj.status == models.DomainApplication.WITHDRAWN:
|
||||
original_obj.withdraw()
|
||||
else:
|
||||
logger.warning("Unknown status selected in django admin")
|
||||
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue