Skip to content

Commit

Permalink
fix: forms for DidatticaSsd
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Nov 21, 2023
1 parent e8005b1 commit abf5981
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions crud/phd/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import requests

from ckeditor.widgets import CKEditorWidget

from django import forms
Expand All @@ -10,18 +8,16 @@
from ricerca_app.models import (DidatticaDottoratoAttivitaFormativa,
DidatticaDottoratoAttivitaFormativaAltriDocenti,
DidatticaDottoratoAttivitaFormativaDocente,
DidatticaSsd,
UnitaOrganizzativa)

from .. utils.settings import (ALLOWED_STRUCTURE_TYPES,
CMS_STORAGE_ROOT_API,
STRUCTURES_FATHER)
from .. utils.utils import _clean_teacher_dates


ALLOWED_STRUCTURE_TYPES = getattr(
settings, 'ALLOWED_STRUCTURE_TYPES', ALLOWED_STRUCTURE_TYPES)
CMS_STORAGE_ROOT_API = getattr(
settings, 'CMS_STORAGE_ROOT_API', CMS_STORAGE_ROOT_API)
STRUCTURES_FATHER = getattr(
settings, 'STRUCTURES_FATHER', STRUCTURES_FATHER)

Expand All @@ -48,11 +44,11 @@ class DidatticaDottoratoAttivitaFormativaForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


ssd_url = f'{CMS_STORAGE_ROOT_API}{reverse("ricerca:phd-ssd-list")}?page_size=1000'
ssd_api = requests.get(ssd_url)
ssd = ssd_api.json()['results']
lista_ssd = [('Non classificabile', 'Non classificabile')]
ssd_list = DidatticaSsd.objects.all()
for ssd in ssd_list:
lista_ssd.append((f'{ssd.ssd_id} {ssd.ssd_des}',
f'{ssd.ssd_id} {ssd.ssd_des}'))

structures = UnitaOrganizzativa.objects.filter(uo_padre=STRUCTURES_FATHER,
cd_tipo_nodo__in=ALLOWED_STRUCTURE_TYPES)
Expand All @@ -71,9 +67,7 @@ def __init__(self, *args, **kwargs):

for q in query:
lista_rif_dott.append((q['rif_dottorato'], q['rif_dottorato']))
for s in ssd:
if s['SSD'] != 'Non classificabile':
lista_ssd.append((s['SSD'], s['SSD']))


self.fields['id_struttura_proponente'] = forms.ModelChoiceField(
label=_('Central Structure'),
Expand Down

0 comments on commit abf5981

Please sign in to comment.