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..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' @@ -222,7 +223,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 +231,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, ) @@ -274,6 +275,23 @@ const NotificationModal = (props: { label="Dry Run" helpText="If selected, will return the number of emails the script would have sent out" /> + { + 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 + + } + />