From 6273280a0f335851376d5a99744e0f9a7712350f Mon Sep 17 00:00:00 2001 From: VineetBala-AOT <90332175+VineetBala-AOT@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:14:09 -0700 Subject: [PATCH] Updating publish engagement email (#2195) * Changes to show all survey results to superusers * removing hard coded values * fixing linting * splitting to seperate end points * fixing auth check * fixing linting * merging method in service * Handle no data error for graphs * adding new nodata component * adding new email for submission response * fixing linting and testing * Upgrades to Issue Tracking Table * removing try catch * email upgrades * reverting --- met-api/templates/publish_engagement.html | 2 +- met-cron/src/met_cron/services/mail_service.py | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/met-api/templates/publish_engagement.html b/met-api/templates/publish_engagement.html index 618cdd296..8ecd11fa5 100644 --- a/met-api/templates/publish_engagement.html +++ b/met-api/templates/publish_engagement.html @@ -1,4 +1,4 @@ -

A new engagement is now open {% if is_having_project %} for {% endif %} {% if is_not_having_project %} on {% endif %} {{ project_name }}.

+

A new engagement is now open for {{ project_name }}.


To learn more and provide your feedback during this public comment period, please click the link below:


diff --git a/met-cron/src/met_cron/services/mail_service.py b/met-cron/src/met_cron/services/mail_service.py index 5460eb8a8..9b7856056 100644 --- a/met-cron/src/met_cron/services/mail_service.py +++ b/met-cron/src/met_cron/services/mail_service.py @@ -54,23 +54,21 @@ def _render_email_template(engagement, participant, template): site_url = notification.get_tenant_site_url(engagement.tenant_id) tenant_name = EmailService._get_tenant_name(engagement.tenant_id) metadata_model: EngagementMetadataModel = EngagementMetadataModel.find_by_id(engagement.id) - project_name = metadata_model.project_metadata.get('project_name', None) - is_having_project = True if project_name else False - is_not_having_project = True if not project_name else False + project_name = None + if metadata_model and 'project_name' in metadata_model.project_metadata: + project_name = metadata_model.project_metadata.get('project_name') view_path = current_app.config.get('ENGAGEMENT_VIEW_PATH'). \ format(engagement_id=engagement.id) unsubscribe_url = current_app.config.get('UNSUBSCRIBE_PATH'). \ format(engagement_id=engagement.id, participant_id=participant.id) email_environment = current_app.config.get('EMAIL_ENVIRONMENT', '') args = { - 'project_name': project_name if project_name else tenant_name, + 'project_name': project_name if project_name else engagement.name, 'survey_url': f'{site_url}{view_path}', 'end_date': datetime.strftime(engagement.end_date, EmailVerificationService.full_date_format), 'tenant_name': tenant_name, 'email_environment': email_environment, 'unsubscribe_url': f'{site_url}{unsubscribe_url}', - 'is_having_project': is_having_project, - 'is_not_having_project': is_not_having_project, } body = template.render( project_name=args.get('project_name'), @@ -79,8 +77,6 @@ def _render_email_template(engagement, participant, template): tenant_name=args.get('tenant_name'), email_environment=args.get('email_environment'), unsubscribe_url=args.get('unsubscribe_url'), - is_having_project=args.get('is_having_project'), - is_not_having_project=args.get('is_not_having_project'), ) return body, args