From f85cadf5be726fe24b41c0e0c72fb3e60e10af4f Mon Sep 17 00:00:00 2001 From: aviupadhyayula Date: Tue, 26 Sep 2023 00:24:14 -0400 Subject: [PATCH 1/4] Allow resend of acceptance/rejection emails --- backend/clubs/views.py | 8 +++++++- frontend/components/ClubEditPage/ApplicationsPage.tsx | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/clubs/views.py b/backend/clubs/views.py index 2d5d8d560..0390b7b63 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -4665,6 +4665,8 @@ def send_emails(self, *args, **kwargs): Send out acceptance/rejection emails for a particular application Dry run will validate that all emails have nonempty variables + + Allow resend will renotify submissions that have already been emailed --- requestBody: content: @@ -4672,6 +4674,8 @@ def send_emails(self, *args, **kwargs): schema: type: object properties: + allow_resend: + type: boolean dry_run: type: boolean email_type: @@ -4728,13 +4732,15 @@ def send_emails(self, *args, **kwargs): subject = f"Application Update for {app.name}" n, skip = 0, 0 + allow_resend = self.request.data.get("allow_resend") + acceptance_template = Template(app.acceptance_email) rejection_template = Template(app.rejection_email) mass_emails = [] for submission in submissions: if ( - submission.notified + (not allow_resend and submission.notified) or submission.status == ApplicationSubmission.PENDING or not (submission.reason and submission.user.email) ): diff --git a/frontend/components/ClubEditPage/ApplicationsPage.tsx b/frontend/components/ClubEditPage/ApplicationsPage.tsx index a364e964b..0a801cab1 100644 --- a/frontend/components/ClubEditPage/ApplicationsPage.tsx +++ b/frontend/components/ClubEditPage/ApplicationsPage.tsx @@ -274,6 +274,16 @@ const NotificationModal = (props: { label="Dry Run" helpText="If selected, will return the number of emails the script would have sent out" /> + + If selected, will resend notifications to all applicants + + } + /> From febeea37bfcdc0760e5f1d0c0f11dcf5a6fb618d Mon Sep 17 00:00:00 2001 From: aviupadhyayula Date: Tue, 26 Sep 2023 00:53:21 -0400 Subject: [PATCH 2/4] Change logic for frontend submission collection --- frontend/components/ClubEditPage/ApplicationsPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/components/ClubEditPage/ApplicationsPage.tsx b/frontend/components/ClubEditPage/ApplicationsPage.tsx index 0a801cab1..9dfbb32a4 100644 --- a/frontend/components/ClubEditPage/ApplicationsPage.tsx +++ b/frontend/components/ClubEditPage/ApplicationsPage.tsx @@ -222,7 +222,7 @@ const NotificationModal = (props: { if (data.email_type.id === 'acceptance' && !data.dry_run) { const relevant = submissions.filter( (sub) => - sub.notified === false && + (data.allow_resend || !sub.notified) && sub.status === 'Accepted' && sub.reason, ) @@ -230,7 +230,7 @@ const NotificationModal = (props: { } else if (data.email_type.id === 'rejection' && !data.dry_run) { const relevant = submissions.filter( (sub) => - sub.notified === false && + (data.allow_resend || !sub.notified) && sub.status.startsWith('Rejected') && sub.reason, ) From 20aca6a58c9b442f2cce5a3f49de1a0433b7b331 Mon Sep 17 00:00:00 2001 From: Julian Weng Date: Sun, 1 Oct 2023 13:37:57 -0400 Subject: [PATCH 3/4] Fix bug in pre-commit frontend lint Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b44b78b77..64a465e47 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: args: [--config, backend/setup.cfg] - id: frontend name: Yarn Linter - entry: yarn --cwd frontend lint + entry: bash -c "cd frontend && yarn lint" language: system files: ^frontend/ require_serial: false From 7bd4be13093ea6e317260ae86cc63b3bda33202c Mon Sep 17 00:00:00 2001 From: Julian Weng Date: Sun, 1 Oct 2023 13:40:09 -0400 Subject: [PATCH 4/4] Add toast warning to resend checkbox --- frontend/components/ClubEditPage/ApplicationsPage.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/components/ClubEditPage/ApplicationsPage.tsx b/frontend/components/ClubEditPage/ApplicationsPage.tsx index 9dfbb32a4..b3c7aec89 100644 --- a/frontend/components/ClubEditPage/ApplicationsPage.tsx +++ b/frontend/components/ClubEditPage/ApplicationsPage.tsx @@ -2,6 +2,7 @@ import { Field, Form, Formik } from 'formik' import moment from 'moment-timezone' import React, { ReactElement, useEffect, useMemo, useState } from 'react' import Select from 'react-select' +import { toast } from 'react-toastify' import styled from 'styled-components' import { ALLBIRDS_GRAY, CLUBS_BLUE, MD, mediaMaxWidth, SNOW } from '~/constants' @@ -278,6 +279,13 @@ const NotificationModal = (props: { name="allow_resend" as={CheckboxField} label="Resend Emails" + onClick={(e) => { + if (e.target.checked) { + toast.warning( + 'Resending emails will send emails to all applicants, even if they have already been notified.', + ) + } + }} helpText={ If selected, will resend notifications to all applicants