diff --git a/backend/clubs/serializers.py b/backend/clubs/serializers.py index 2a303bb47..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 @@ -2644,6 +2645,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 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}