diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 6776b8834..57b86394c 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1637,6 +1637,10 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): return super().save_model(request, obj, form, change) # == Handle non-status changes == # + # Change this in #1901. Add a check on "not self.action_needed_reason_email" + if obj.action_needed_reason: + self._handle_action_needed_reason_email(obj) + should_save = True # Get the original domain request from the database. original_obj = models.DomainRequest.objects.get(pk=obj.pk) @@ -1645,14 +1649,17 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): return super().save_model(request, obj, form, change) # == Handle status changes == # - # Run some checks on the current object for invalid status changes obj, should_save = self._handle_status_change(request, obj, original_obj) - # We should only save if we don't display any errors in the step above. + # We should only save if we don't display any errors in the steps above. if should_save: return super().save_model(request, obj, form, change) + def _handle_action_needed_reason_email(self, obj): + text = self._get_action_needed_reason_default_email_text(obj, obj.action_needed_reason) + obj.action_needed_reason_email = text.get("email_body_text") + def _handle_status_change(self, request, obj, original_obj): """ Checks for various conditions when a status change is triggered. diff --git a/src/registrar/migrations/0105_domainrequest_action_needed_reason_email.py b/src/registrar/migrations/0105_domainrequest_action_needed_reason_email.py deleted file mode 100644 index b58e837f7..000000000 --- a/src/registrar/migrations/0105_domainrequest_action_needed_reason_email.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.10 on 2024-06-20 18:04 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("registrar", "0104_create_groups_v13"), - ] - - operations = [ - migrations.AddField( - model_name="domainrequest", - name="action_needed_reason_email", - field=models.TextField(blank=True, null=True), - ), - ] diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index b44ceb678..2190810bb 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -597,10 +597,8 @@ class DomainRequest(TimeStampedModel): def save(self, *args, **kwargs): """Save override for custom properties""" - self.sync_organization_type() self.sync_yes_no_form_fields() - self.sync_action_needed_reason_email() super().save(*args, **kwargs) @@ -611,13 +609,6 @@ class DomainRequest(TimeStampedModel): # Update the cached values after saving self._cache_status_and_action_needed_reason() - def sync_action_needed_reason_email(self): - """If no action_needed_reason_email is defined, add a default one""" - # Change this in #1901. Add a check on "not self.action_needed_reason_email" - if self.action_needed_reason: - text = self.get_action_needed_reason_default_email_text(self.action_needed_reason) - self.action_needed_reason_email = text.get("email_body_text") - def sync_action_needed_reason(self): """Checks if we need to send another action needed email""" was_already_action_needed = self._cached_status == self.DomainRequestStatus.ACTION_NEEDED @@ -851,7 +842,6 @@ class DomainRequest(TimeStampedModel): # Unknown and other are default cases - do nothing can_send_email = False - # TODO - replace this logic with self.action_needed_reason_email in #1901. # Assumes that the template name matches the action needed reason if nothing is specified. # This is so you can override if you need, or have this taken care of for you. if not email_template_name and not email_template_subject_name: