SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 37b5fe05 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Prevent creation of PotFel for Profile if one already exists

parent 32b4f456
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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 %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment