Link to email settings profile when viewing email attempt

This commit is contained in:
Lance Edgar 2022-03-07 10:53:12 -06:00
parent 7c4e9b56c7
commit 511e185f33
3 changed files with 17 additions and 12 deletions

View file

@ -425,6 +425,9 @@ class EmailAttemptView(MasterView):
def configure_form(self, f):
super(EmailAttemptView, self).configure_form(f)
# key
f.set_renderer('key', self.render_email_key)
# status_code
f.set_enum('status_code', self.enum.EMAIL_ATTEMPT)

View file

@ -911,6 +911,20 @@ class MasterView(View):
url = self.request.route_url('customers.view', uuid=customer.uuid)
return tags.link_to(text, url)
def render_email_key(self, obj, field):
if hasattr(obj, field):
email_key = getattr(obj, field)
else:
email_key = obj[field]
if not email_key:
return
if self.request.has_perm('emailprofiles.view'):
url = self.request.route_url('emailprofiles.view', key=email_key)
return tags.link_to(email_key, url)
return email_key
def before_create_flush(self, obj, form):
pass

View file

@ -652,18 +652,6 @@ class ProblemReportView(MasterView):
f.set_renderer('email_key', self.render_email_key)
f.set_renderer('email_recipients', self.render_email_recipients)
def render_email_key(self, report_info, field):
email_key = report_info[field]
if not email_key:
return
if self.request.has_perm('emailprofiles.view'):
text = email_key
url = self.request.route_url('emailprofiles.view', key=email_key)
return tags.link_to(text, url)
return email_key
def render_email_recipients(self, report_info, field):
recips = report_info['email_recipients']
return ', '.join(recips)