SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 17ea1bc0 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add preexisting options in appraisal form

parent ab11c767
No related branches found
No related tags found
No related merge requests found
...@@ -109,7 +109,33 @@ class RadioAppraisalForm(forms.Form): ...@@ -109,7 +109,33 @@ class RadioAppraisalForm(forms.Form):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.submission = kwargs.pop("submission") self.submission = kwargs.pop("submission")
self.fellow = kwargs.pop("fellow") self.fellow = kwargs.pop("fellow")
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Add any pre-existing choices to the form
qualification = Qualification.objects.filter(
submission=self.submission, fellow=self.fellow
).first()
if qualification and qualification.expertise_level not in dict(
self.fields["expertise_level"].choices
):
self.fields["expertise_level"].choices += (
(
qualification.expertise_level,
qualification.get_expertise_level_display(),
),
)
self.initial["expertise_level"] = qualification.expertise_level
readiness = Readiness.objects.filter(
submission=self.submission, fellow=self.fellow
).first()
if readiness and readiness.status not in dict(self.fields["readiness"].choices):
self.fields["readiness"].choices += (
(readiness.status, readiness.get_status_display()),
)
self.initial["readiness"] = readiness.status
self.helper = FormHelper() self.helper = FormHelper()
self.helper.layout = Layout( self.helper.layout = Layout(
Div( Div(
......
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