fix notifications on analyst action

This commit is contained in:
matthewswspence 2024-10-11 14:56:24 -05:00
parent 84c30f69ee
commit bc80c13bd3
No known key found for this signature in database
GPG key ID: FB458202A7852BA4

View file

@ -174,16 +174,20 @@ class DomainFormBaseView(DomainBaseView, FormMixin):
}
is_analyst_action = ("analyst_action" in self.session and "analyst_action_location" in self.session)
should_notify=False
if form.__class__ in form_label_dict and not is_analyst_action:
# these types of forms can cause notifications
should_notify = True
if form.__class__ in check_for_portfolio:
# some forms shouldn't cause notifications if they are in a portfolio
info = self.get_domain_info_from_domain()
if not info or info.portfolio:
logger.debug("No notification sent: Domain is part of a portfolio")
should_notify = False
if form.__class__ in form_label_dict:
if is_analyst_action:
logger.debug("No notification sent: Action was conducted by an analyst")
else:
# these types of forms can cause notifications
should_notify = True
if form.__class__ in check_for_portfolio:
# some forms shouldn't cause notifications if they are in a portfolio
info = self.get_domain_info_from_domain()
if not info or info.portfolio:
logger.debug("No notification sent: Domain is part of a portfolio")
should_notify = False
else:
# don't notify for any other types of forms
should_notify = False
@ -202,7 +206,7 @@ class DomainFormBaseView(DomainBaseView, FormMixin):
)
else:
logger.info(
f"Not notifying for {form.__class__}, form changes: {form.has_changed()}, force_send: {force_send}"
f"No notification sent for {form.__class__}. form changes: {form.has_changed()}, force_send: {force_send}"
)
def email_domain_managers(self, domain: Domain, template: str, subject_template: str, context={}):