Skip to content

Commit

Permalink
fix: UP filter by af_cod
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Oct 3, 2024
1 parent edb4e35 commit 529dda3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions ricerca_app/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ def get(self, obj, **kwargs):
impegni_json = upImpegniSerializer(impegni=impegni,
year=year,
af_name=af_name,
af_cod=af_cod,
search=search,
show_past=show_past)

Expand Down
1 change: 1 addition & 0 deletions ricerca_app/esse3/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def esse3AppelliSerializer(appelli, year=None, af_id=None, search={}, show_past=
new_ora = f"{ora[0]}:{ora[1]}"
appello_dict = {
"insegnamento": appello['adDes'],
"codice_insegnamento": appello['adCod'],
"dataInizio": new_data,
"dataFine": None,
"orarioInizio": new_ora,
Expand Down
12 changes: 7 additions & 5 deletions ricerca_app/up/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
from django.utils import timezone


def upImpegniSerializer(impegni, year=None, af_name=None, search={}, show_past=False): # pragma: no cover
def upImpegniSerializer(impegni, year=None, af_name=None, af_cod=None, search={}, show_past=False): # pragma: no cover
impegni_up = []
search_teacher = search.get('search_teacher', '')
search_location = search.get('search_location', '')

for impegno in impegni:
# if year and impegno['evento']['dettagliDidattici'][0]['annoCorso'] != year:
# continue
code = impegno['evento']['dettagliDidattici'][0].get('codice')
name = impegno['evento']['dettagliDidattici'][0].get('nome')

# if af_name and impegno['evento']['dettagliDidattici'][0]['nome'].lower() != af_name.lower():
if af_name and not impegno['evento']['dettagliDidattici'][0]['nome'].lower().startswith(af_name.lower()):
if code and af_cod and code != af_cod:
continue
if not code and af_name and not name.lower().startswith(af_name.lower()):
continue

dataInizio = impegno['dataInizio'][0:10]
Expand Down Expand Up @@ -60,6 +61,7 @@ def upImpegniSerializer(impegni, year=None, af_name=None, search={}, show_past=F

impegno_dict = {
"insegnamento": insegnamento,
"codice_insegnamento": impegno['evento']['dettagliDidattici'][0]['codice'],
"dataInizio": dataInizio,
"dataFine": dataFine,
"orarioInizio": orarioInizio,
Expand Down
3 changes: 2 additions & 1 deletion ricerca_app/up/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def getData(request, url, cds_cod, body): # pragma: no cover


def getUPImpegni(request, cds_cod, aa, year=1, date_month='', date_year='', types=[], af_cod='', filter_by_af_cod=True): # pragma: no cover
# filter_by_af_cod: UP non ritorna risultati se si filtrano gli esami per codAF
url = settings.URL_UP_API + 'Impegni/getImpegniByAnnoAccademico'

try:
Expand Down Expand Up @@ -96,6 +97,6 @@ def getUPImpegni(request, cds_cod, aa, year=1, date_month='', date_year='', type
"codTipiEvento": types,
"dataInizio": start_up,
"dataFine": end_up,
"codAF": af_cod if filter_by_af_cod else ''
"codAF": af_cod if filter_by_af_cod else '' # UP non ritorna risultati se si filtrano gli esami per codAF
}
return getData(request, url, cds_cod, body)

0 comments on commit 529dda3

Please sign in to comment.