feat(profile): prevent deferrals of RD and rolling admissions

Those are impossible AFAIK
This commit is contained in:
Ethan Nguyen 2021-04-22 22:38:06 -04:00
parent ec8834ef83
commit 16f503edb8
No known key found for this signature in database
GPG Key ID: B4CA5339AF911920
2 changed files with 29 additions and 0 deletions

View File

@ -72,6 +72,11 @@ class DecisionForm(forms.ModelForm):
):
raise ValidationError("You cannot add a second entry for this college")
# Rolling and RD decisions cannot be deferred
if cleaned_data.get("decision_type") in [Decision.REGULAR_DECISION, Decision.ROLLING]:
if "DEFER" in cleaned_data.get("admission_status"):
raise ValidationError("Regular Decision and Rolling decisions cannot result in a deferral")
return cleaned_data

View File

@ -426,6 +426,30 @@ class ProfileTest(TJDestsTestCase):
self.assertEqual(200, response.status_code)
self.assertEqual(1, Decision.objects.filter(college=college, user=user).count())
# No deferrals for RD and rolling
Decision.objects.all().delete()
response = self.client.post(
reverse("profile:decision_add"),
data={
"college": college.id,
"decision_type": "RD",
"admission_status": "DEFER_WAITLIST_ADMIT",
},
)
self.assertEqual(200, response.status_code)
self.assertEqual(0, Decision.objects.filter(college=college, user=user).count())
response = self.client.post(
reverse("profile:decision_add"),
data={
"college": college.id,
"decision_type": "RD",
"admission_status": "WAITLIST",
},
)
self.assertEqual(302, response.status_code)
self.assertEqual(1, Decision.objects.filter(college=college, user=user, admission_status=Decision.WAITLIST).count())
def test_decision_update(self):
user = self.login(make_senior=True, make_student=True, accept_tos=True)