Skip to content

Commit

Permalink
fixing update on submission (#1996)
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

* fixing update on submission

* fixing linting

* updating rejection email arguments
  • Loading branch information
VineetBala-AOT authored Aug 11, 2023
1 parent d916c88 commit 6f092fb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions met-api/src/met_api/services/submission_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,20 @@ def review_comment(cls, submission_id, staff_review_details: dict, external_user
rejection_review_note = StaffNote.get_staff_note_by_type(
submission_id, StaffNoteType.Review.name)
SubmissionService._trigger_email(
rejection_review_note[0].note, session, submission)
rejection_review_note[0].note, session, staff_review_details, submission)
session.commit()
return SubmissionSchema().dump(submission)

@staticmethod
def _trigger_email(review_note, session, submission):
def _trigger_email(review_note, session, staff_review_details: dict, submission):
email_verification = EmailVerificationService().create({
'participant_id': submission.participant_id,
'survey_id': submission.survey_id,
'submission_id': submission.id,
'type': EmailVerificationType.RejectedComment,
}, session)
SubmissionService._send_rejected_email(
submission, review_note, email_verification.get('verification_token'))
staff_review_details, submission, review_note, email_verification.get('verification_token'))

@classmethod
def validate_review(cls, values: dict, user, submission):
Expand Down Expand Up @@ -305,15 +305,15 @@ def get_paginated(
}

@staticmethod
def _send_rejected_email(submission: SubmissionModel, review_note, token) -> None:
def _send_rejected_email(staff_review_details: dict, submission: SubmissionModel, review_note, token) -> None:
"""Send an verification email.Throws error if fails."""
participant_id = submission.participant_id
participant = ParticipantModel.find_by_id(participant_id)

template_id = current_app.config.get(
'REJECTED_EMAIL_TEMPLATE_ID', None)
subject, body, args = SubmissionService._render_email_template(
submission, review_note, token)
staff_review_details, submission, review_note, token)
try:
notification.send_email(subject=subject,
email=ParticipantModel.decode_email(
Expand All @@ -329,7 +329,7 @@ def _send_rejected_email(submission: SubmissionModel, review_note, token) -> Non
status_code=HTTPStatus.INTERNAL_SERVER_ERROR) from exc

@staticmethod
def _render_email_template(submission: SubmissionModel, review_note, token):
def _render_email_template(staff_review_details: dict, submission: SubmissionModel, review_note, token):
template = Template.get_template('email_rejected_comment.html')
engagement: EngagementModel = EngagementModel.find_by_id(
submission.engagement_id)
Expand All @@ -348,10 +348,10 @@ def _render_email_template(submission: SubmissionModel, review_note, token):
args = {
'engagement_name': engagement_name,
'survey_name': survey_name,
'has_personal_info': 'yes' if submission.has_personal_info else '',
'has_profanity': 'yes' if submission.has_profanity else '',
'has_other_reason': 'yes' if submission.rejected_reason_other else '',
'other_reason': submission.rejected_reason_other,
'has_personal_info': 'yes' if staff_review_details.get('has_personal_info', None) else '',
'has_profanity': 'yes' if staff_review_details.get('has_profanity', None) else '',
'has_other_reason': 'yes' if staff_review_details.get('rejected_reason_other', None) else '',
'other_reason': staff_review_details.get('rejected_reason_other', None),
'submission_url': submission_url,
'review_note': review_note,
'end_date': datetime.strftime(engagement.end_date, EmailVerificationService.full_date_format),
Expand Down

0 comments on commit 6f092fb

Please sign in to comment.