Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip-feature: Allow resend of acceptance/rejection emails #592

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4665,13 +4665,17 @@ 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:
application/json:
schema:
type: object
properties:
allow_resend:
type: boolean
dry_run:
type: boolean
email_type:
Expand Down Expand Up @@ -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)
):
Expand Down
22 changes: 20 additions & 2 deletions frontend/components/ClubEditPage/ApplicationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -222,15 +223,15 @@ 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,
)
updateSubmissions(relevant)
} 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,
)
Expand Down Expand Up @@ -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"
/>
<Field
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={
<strong>
If selected, will resend notifications to all applicants
</strong>
}
/>
<button type="submit" className="button">
Submit
</button>
Expand Down
Loading