diff --git a/colleges/forms.py b/colleges/forms.py index c7035df09779916d1216ab5f87f8aaa049724747..7099a0c4707f9e58c2dba62ca943e569939ef03a 100644 --- a/colleges/forms.py +++ b/colleges/forms.py @@ -225,6 +225,15 @@ class PotentialFellowshipForm(RequestFormMixin, forms.ModelForm): model = PotentialFellowship fields = ['college', 'profile'] + def clean_profile(self): + """Check that no preexisting PotentialFellowship exists.""" + cleaned_profile = self.cleaned_data['profile'] + if cleaned_profile.potentialfellowship_set.all(): + self.add_error( + 'profile', + 'This profile already has a PotentialFellowship. Update that instead.') + return cleaned_profile + def save(self): """ The default status is IDENTIFIED, which is appropriate diff --git a/colleges/templates/colleges/potentialfellowship_list.html b/colleges/templates/colleges/potentialfellowship_list.html index 08bcceb896acbf845acc676c99583e81f30f8f86..346b92d93c5df3fb93e8b19dc22ee8669b0b7e7e 100644 --- a/colleges/templates/colleges/potentialfellowship_list.html +++ b/colleges/templates/colleges/potentialfellowship_list.html @@ -116,7 +116,7 @@ <div class="row"> <div class="col-12"> - {% if view.kwargs.acad_field or request.GET.status %} + {% if view.kwargs.acad_field or request.GET.status or request.GET.text %} <h3>Potential Fellowships {% if view.kwargs.acad_field %}in {{ view.kwargs.acad_field }} {% if view.kwargs.specialty %}, {{ view.kwargs.specialty }}{% endif %}