From 665950cd8e2f15ae29a43ed5f62d184d5956a2ab Mon Sep 17 00:00:00 2001 From: "Eunsoo Shin (esinx)" Date: Sat, 23 Sep 2023 23:52:09 -0400 Subject: [PATCH 1/3] fix(ApplicationsCard): add option to explicitly switch between external and internal application --- .../ClubEditPage/ApplicationsCard.tsx | 77 +++++++++++++------ 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/frontend/components/ClubEditPage/ApplicationsCard.tsx b/frontend/components/ClubEditPage/ApplicationsCard.tsx index 1702c39a5..6ab1a3beb 100644 --- a/frontend/components/ClubEditPage/ApplicationsCard.tsx +++ b/frontend/components/ClubEditPage/ApplicationsCard.tsx @@ -9,7 +9,7 @@ import { OBJECT_NAME_SINGULAR, OBJECT_NAME_TITLE_SINGULAR, } from '../../utils/branding' -import { Icon, Modal, Text } from '../common' +import { Checkbox, CheckboxLabel, Icon, Modal, Text } from '../common' import { ApplicationUpdateTextField, CheckboxField, @@ -203,6 +203,7 @@ export default function ApplicationsCard({ club }: Props): ReactElement { const [show, setShow] = useState(false) const showModal = () => setShow(true) const hideModal = () => setShow(false) + const [isExternal, setIsExternal] = useState(false) const [applicationName, setApplicationName] = useState('') const [committees, setCommittees] = useState<{ label: string @@ -346,34 +347,64 @@ export default function ApplicationsCard({ club }: Props): ReactElement { club.is_wharton ? 'Read-only.' : '' }`} /> - -

Congratulations {{ name }}! You've been accepted to {{ committee }} because {{reason}}!

" - } - helpText={`Acceptance email for your ${OBJECT_NAME_SINGULAR}.`} - /> -

Sorry {{ name }}, You've been rejected because {{ reason }}!

" - } - helpText={`Rejection email for your ${OBJECT_NAME_SINGULAR}.`} - /> + +
+
+ +
+
+
+
+ setIsExternal(!isExternal)} + /> + + Make this an external application + +
+
+
+
+ {isExternal ? ( + + ) : ( + <> +

Congratulations {{ name }}! You've been accepted to {{ committee }} because {{reason}}!

" + } + helpText={`Acceptance email for your ${OBJECT_NAME_SINGULAR}.`} + /> +

Sorry {{ name }}, You've been rejected because {{ reason }}!

" + } + helpText={`Rejection email for your ${OBJECT_NAME_SINGULAR}.`} + /> + + )} } confirmDeletion={true} From 8f3d74e21e271be42ba47abf533ee17b1e34cf1d Mon Sep 17 00:00:00 2001 From: Rohan Moniz Date: Sun, 24 Sep 2023 00:47:27 -0400 Subject: [PATCH 2/3] add empty template check when no external url is set --- backend/clubs/serializers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/clubs/serializers.py b/backend/clubs/serializers.py index 2a303bb47..4bbc51df9 100644 --- a/backend/clubs/serializers.py +++ b/backend/clubs/serializers.py @@ -2644,6 +2644,12 @@ def get_image_url(self, obj): def validate(self, data): acceptance_template = data.get("acceptance_email", "") rejection_template = data.get("rejection_email", "") + external_url = self.context["request"].data.get("external_url") + + if not external_url and not (acceptance_template and rejection_template): + raise serializers.ValidationError( + "Your application email templates cannot be empty!" + ) if not ClubApplication.validate_template( acceptance_template From dda5705fab324c527edd7207bbb076eedc64cf4f Mon Sep 17 00:00:00 2001 From: Rohan Moniz Date: Sun, 24 Sep 2023 03:23:02 -0400 Subject: [PATCH 3/3] temp fix for saving external url --- backend/clubs/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/clubs/serializers.py b/backend/clubs/serializers.py index 4bbc51df9..aeb35dada 100644 --- a/backend/clubs/serializers.py +++ b/backend/clubs/serializers.py @@ -2607,8 +2607,9 @@ class ClubApplicationSerializer(ClubRouteMixin, serializers.ModelSerializer): active = serializers.SerializerMethodField("get_active", read_only=True) def get_external_url(self, obj): + ext_url = self.context["request"].data.get("external_url") default_url = f"https://pennclubs.com/club/{obj.club.code}/application/{obj.pk}" - return obj.external_url if obj.external_url else default_url + return ext_url if ext_url else default_url def get_cycle(self, obj): return obj.application_cycle.name if obj.application_cycle else obj.season