mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
basic logic
This commit is contained in:
parent
3b002e41c1
commit
1cbd9234be
3 changed files with 14 additions and 12 deletions
|
@ -1606,7 +1606,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
"is_election_board",
|
"is_election_board",
|
||||||
"federal_agency",
|
"federal_agency",
|
||||||
"status_history",
|
"status_history",
|
||||||
"action_needed_reason_email",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Read only that we'll leverage for CISA Analysts
|
# Read only that we'll leverage for CISA Analysts
|
||||||
|
@ -1705,7 +1704,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
return super().save_model(request, obj, form, change)
|
return super().save_model(request, obj, form, change)
|
||||||
|
|
||||||
# == Handle non-status changes == #
|
# == Handle non-status changes == #
|
||||||
if obj.action_needed_reason and not self.action_needed_reason_email:
|
if obj.action_needed_reason and not obj.action_needed_reason_email:
|
||||||
self._handle_action_needed_reason_email(obj)
|
self._handle_action_needed_reason_email(obj)
|
||||||
should_save = True
|
should_save = True
|
||||||
|
|
||||||
|
@ -1933,13 +1932,14 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
emails = {}
|
emails = {}
|
||||||
for action_needed_reason in domain_request.ActionNeededReasons:
|
for action_needed_reason in domain_request.ActionNeededReasons:
|
||||||
enum_value = action_needed_reason.value
|
enum_value = action_needed_reason.value
|
||||||
|
custom_text = None
|
||||||
if domain_request.action_needed_reason == enum_value and domain_request.action_needed_reason_email:
|
if domain_request.action_needed_reason == enum_value and domain_request.action_needed_reason_email:
|
||||||
emails[enum_value] = domain_request.action_needed_reason_email
|
custom_text = domain_request.action_needed_reason_email
|
||||||
else:
|
|
||||||
emails[enum_value] = self._get_action_needed_reason_default_email_text(domain_request, enum_value)
|
emails[enum_value] = self._get_action_needed_reason_default_email_text(domain_request, enum_value, custom_text)
|
||||||
return json.dumps(emails)
|
return json.dumps(emails)
|
||||||
|
|
||||||
def _get_action_needed_reason_default_email_text(self, domain_request, action_needed_reason: str):
|
def _get_action_needed_reason_default_email_text(self, domain_request, action_needed_reason: str, custom_text=None):
|
||||||
"""Returns the default email associated with the given action needed reason"""
|
"""Returns the default email associated with the given action needed reason"""
|
||||||
if action_needed_reason is None or action_needed_reason == domain_request.ActionNeededReasons.OTHER:
|
if action_needed_reason is None or action_needed_reason == domain_request.ActionNeededReasons.OTHER:
|
||||||
return {
|
return {
|
||||||
|
@ -1961,7 +1961,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"subject_text": subject_template.render(context=context),
|
"subject_text": subject_template.render(context=context),
|
||||||
"email_body_text": template.render(context=context),
|
"email_body_text": template.render(context=context) if not custom_text else custom_text,
|
||||||
}
|
}
|
||||||
|
|
||||||
def process_log_entry(self, log_entry):
|
def process_log_entry(self, log_entry):
|
||||||
|
|
|
@ -525,7 +525,7 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function () {
|
||||||
let actionNeededReasonDropdown = document.querySelector("#id_action_needed_reason");
|
let actionNeededReasonDropdown = document.querySelector("#id_action_needed_reason");
|
||||||
let actionNeededEmail = document.querySelector("#action_needed_reason_email_view_more");
|
let actionNeededEmail = document.querySelector("#id_action_needed_reason_email");
|
||||||
if(actionNeededReasonDropdown && actionNeededEmail) {
|
if(actionNeededReasonDropdown && actionNeededEmail) {
|
||||||
// Add a change listener to the action needed reason dropdown
|
// Add a change listener to the action needed reason dropdown
|
||||||
handleChangeActionNeededEmail(actionNeededReasonDropdown, actionNeededEmail);
|
handleChangeActionNeededEmail(actionNeededReasonDropdown, actionNeededEmail);
|
||||||
|
@ -546,6 +546,7 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
let actionNeededEmails = JSON.parse(document.getElementById('action-needed-emails-data').textContent)
|
let actionNeededEmails = JSON.parse(document.getElementById('action-needed-emails-data').textContent)
|
||||||
let emailData = actionNeededEmails[reason];
|
let emailData = actionNeededEmails[reason];
|
||||||
if (emailData) {
|
if (emailData) {
|
||||||
|
// TODO: do we need a revert to default button?
|
||||||
let emailBody = emailData.email_body_text
|
let emailBody = emailData.email_body_text
|
||||||
if (emailBody) {
|
if (emailBody) {
|
||||||
actionNeededEmail.value = emailBody
|
actionNeededEmail.value = emailBody
|
||||||
|
|
|
@ -785,8 +785,8 @@ class DomainRequest(TimeStampedModel):
|
||||||
"submission confirmation",
|
"submission confirmation",
|
||||||
"emails/submission_confirmation.txt",
|
"emails/submission_confirmation.txt",
|
||||||
"emails/submission_confirmation_subject.txt",
|
"emails/submission_confirmation_subject.txt",
|
||||||
True,
|
send_email=True,
|
||||||
bcc_address,
|
bcc_address=bcc_address,
|
||||||
)
|
)
|
||||||
|
|
||||||
@transition(
|
@transition(
|
||||||
|
@ -856,7 +856,8 @@ class DomainRequest(TimeStampedModel):
|
||||||
|
|
||||||
# Send out an email if an action needed reason exists
|
# Send out an email if an action needed reason exists
|
||||||
if self.action_needed_reason and self.action_needed_reason != self.ActionNeededReasons.OTHER:
|
if self.action_needed_reason and self.action_needed_reason != self.ActionNeededReasons.OTHER:
|
||||||
self._send_action_needed_reason_email(send_email)
|
custom_email_content = self.action_needed_reason_email
|
||||||
|
self._send_action_needed_reason_email(send_email, custom_email_content)
|
||||||
|
|
||||||
def _send_action_needed_reason_email(self, send_email=True, custom_email_content=None):
|
def _send_action_needed_reason_email(self, send_email=True, custom_email_content=None):
|
||||||
"""Sends out an automatic email for each valid action needed reason provided"""
|
"""Sends out an automatic email for each valid action needed reason provided"""
|
||||||
|
@ -951,7 +952,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
"domain request approved",
|
"domain request approved",
|
||||||
"emails/status_change_approved.txt",
|
"emails/status_change_approved.txt",
|
||||||
"emails/status_change_approved_subject.txt",
|
"emails/status_change_approved_subject.txt",
|
||||||
send_email,
|
send_email=send_email,
|
||||||
)
|
)
|
||||||
|
|
||||||
@transition(
|
@transition(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue