Skip to content

Commit

Permalink
Changes for email verification template (#1960)
Browse files Browse the repository at this point in the history
* updates on engagement publish

* update email template

* adding action drop down

* updated changes for User Management

* access user details page for users without a role

* updating variable name

* updating the schema

* updating as per review comments

* updating schema

* adding changes for clone and delete

* fixing linting

* update

* fix for report setting on analytics

* fixing lint

* Changes for email verification template

* fixing linting
  • Loading branch information
VineetBala-AOT authored Aug 3, 2023
1 parent 4f6723b commit dee225d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions met-api/src/met_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class _Config(): # pylint: disable=too-few-public-methods
SURVEY_PATH = os.getenv('SURVEY_PATH', '/surveys/submit/{survey_id}/{token}')
SUBSCRIBE_PATH = os.getenv('SUBSCRIBE_PATH', '/engagements/{engagement_id}/subscribe/{token}')
UNSUBSCRIBE_PATH = os.getenv('UNSUBSCRIBE_PATH', '/engagements/{engagement_id}/unsubscribe/{participant_id}')
ENGAGEMENT_PATH = os.getenv('ENGAGEMENT_PATH', '/engagements/{engagement_id}/view')
ENGAGEMENT_PATH_SLUG = os.getenv('ENGAGEMENT_PATH_SLUG', '/{slug}')
# engagement dashboard path is used to pass the survey result to the public user.
# The link is changed such that public user can access the comments page from the email and not the dashboard.
ENGAGEMENT_DASHBOARD_PATH = os.getenv('ENGAGEMENT_DASHBOARD_PATH', '/engagements/{engagement_id}/comments')
Expand Down
21 changes: 14 additions & 7 deletions met-api/src/met_api/services/email_verification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from met_api.models import Engagement as EngagementModel
from met_api.models import EngagementSlug as EngagementSlugModel
from met_api.models import Survey as SurveyModel
from met_api.models import Tenant as TenantModel
from met_api.models.email_verification import EmailVerification
from met_api.schemas.email_verification import EmailVerificationSchema
from met_api.services.participant_service import ParticipantService
Expand Down Expand Up @@ -157,32 +158,38 @@ def _render_survey_email_template(survey: SurveyModel, token):
subject_template = current_app.config.get('VERIFICATION_EMAIL_SUBJECT')
survey_path = current_app.config.get('SURVEY_PATH'). \
format(survey_id=survey.id, token=token)
dashboard_path = EmailVerificationService._get_dashboard_path(engagement)
engagement_path = EmailVerificationService._get_engagement_path(engagement)
site_url = notification.get_tenant_site_url(engagement.tenant_id)
tenant_name = EmailVerificationService._get_tenant_name(engagement.tenant_id)
args = {
'engagement_name': engagement_name,
'survey_url': f'{site_url}{survey_path}',
'engagement_url': f'{site_url}{dashboard_path}',
'end_date': datetime.strftime(engagement.end_date, EmailVerificationService.full_date_format),
'engagement_url': f'{site_url}{engagement_path}',
'tenant_name': tenant_name,
}
subject = subject_template.format(engagement_name=engagement_name)
body = template.render(
engagement_name=args.get('engagement_name'),
survey_url=args.get('survey_url'),
engagement_url=args.get('engagement_url'),
end_date=args.get('end_date'),
tenant_name=args.get('tenant_name'),
)
return subject, body, args, template_id

@staticmethod
def _get_dashboard_path(engagement: EngagementModel):
def _get_engagement_path(engagement: EngagementModel):
engagement_slug = EngagementSlugModel.find_by_engagement_id(engagement.id)
if engagement_slug:
return current_app.config.get('ENGAGEMENT_DASHBOARD_PATH_SLUG'). \
return current_app.config.get('ENGAGEMENT_PATH_SLUG'). \
format(slug=engagement_slug.slug)
return current_app.config.get('ENGAGEMENT_DASHBOARD_PATH'). \
return current_app.config.get('ENGAGEMENT_PATH'). \
format(engagement_id=engagement.id)

@staticmethod
def _get_tenant_name(tenant_id):
tenant = TenantModel.find_by_id(tenant_id)
return tenant.name

@staticmethod
def validate_email_verification(email_verification: EmailVerificationSchema):
"""Validate an email verification."""
Expand Down
11 changes: 4 additions & 7 deletions met-api/templates/email_verification.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<h1>Thank you for your interest in sharing your thoughts about {{ engagement_name }}.</h1>
<p>Please click the link below to access the survey and share your comments. <strong>This link will expire in 24 hours and is only valid once.</strong></p>
<h1>Share your feedback about {{ engagement_name }}.</h1>
<p>Please click the link below to provide your feedback. This link will expire in 24 hours and is only valid once. If the link has expired, you can request request access again by visiting <a href='{{ engagement_url }}'>{{ engagement_name }}</a>.</p>
<br />
<a href='{{ survey_url }}'>Access Survey</a>
<br />
<p>You can view the survey results anytime <a href='{{ engagement_url }}'>here</a>.<p>
<p>The comments will be available for viewing when the Engagement period is over, starting on {{ end_date }}.</p>
<p>Click <a href='{{ survey_url }}'>here</a> to provide your feedback.<p>
<br />
<p>Thank you,</p>
<br />
<p>The EAO Team</p>
<p>The {{ tenant_name }} Team</p>

0 comments on commit dee225d

Please sign in to comment.