SciPost Code Repository

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

Improve eligibility checks

parent b6d16e0f
No related branches found
No related tags found
No related merge requests found
......@@ -288,12 +288,9 @@ class PotentialFellowshipEventForm(forms.ModelForm):
class FellowshipNominationForm(forms.ModelForm):
#profile_id = forms.IntegerField()
class Meta:
model = FellowshipNomination
fields = [
#'profile_id',
'nominated_by', # hidden
'college', 'nominator_comments' # visible
]
......@@ -301,6 +298,9 @@ class FellowshipNominationForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.profile = kwargs.pop('profile')
super().__init__(*args, **kwargs)
self.fields['college'].queryset = College.objects.filter(
acad_field=self.profile.acad_field)
self.fields['college'].empty_label = None
self.fields['nominator_comments'].widget.attrs['rows'] = 4
self.helper = FormHelper()
self.helper.layout = Layout(
......
......@@ -2,7 +2,7 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from .models import Fellowship, FellowshipNomination
from .models import College, Fellowship, FellowshipNomination
def check_profile_eligibility_for_fellowship(profile):
......@@ -11,12 +11,20 @@ def check_profile_eligibility_for_fellowship(profile):
Requirements:
- Profile has a known acad_field
- There is an active College in the Profile's acad_field
- no current Fellowship exists
- no current FellowshipNomination exists
- no 'not elected' decision in last 2 years
- no invitation was turned down in the last 2 years
"""
blocks = []
if not profile.acad_field:
blocks.append('No academic field is specified for this profile. '
'Contact EdAdmin or techsupport.')
if not College.objects.filter(acad_field=profile.acad_field).exists():
blocks.append('There is currently no College in {profile.acad_field}. '
'Contact EdAdmin or techsupport to get one started.')
if Fellowship.objects.active().regular_or_senior().filter(
contributor__profile=profile).exists():
blocks.append('This Profile is associated to an active Fellowship.')
......
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