From 4055f81e7c46791440003d593671bdda304aa215 Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Wed, 13 Nov 2024 12:03:19 +0100 Subject: [PATCH] fix: docenti --- addressbook/api/v1/services.py | 28 ++++++++++++++++++++-------- cds/api/v1/services.py | 3 +-- teachers/api/v1/services.py | 20 +++++++++----------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/addressbook/api/v1/services.py b/addressbook/api/v1/services.py index 86254a25..f90eb61a 100644 --- a/addressbook/api/v1/services.py +++ b/addressbook/api/v1/services.py @@ -46,11 +46,13 @@ def getAddressbook( query = ( Personale.objects.filter( query_search, - flg_cessato=0, + # flg_cessato=0, # cd_uo_aff_org__isnull=False, + Q(flg_cessato=0) | + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) & ~Q(didatticacopertura__stato_coper_cod='R') | + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1) & ~Q(didatticacopertura__stato_coper_cod='R'), dt_rap_fin__gte=datetime.datetime.today(), - ) - .values( + ).values( "nome", "middle_name", "cognome", @@ -68,8 +70,7 @@ def getAddressbook( "profilo", "ds_profilo", "ds_profilo_breve", - ) - .order_by("cognome", "nome") + ).order_by("cognome", "nome") ) grouped = {} @@ -345,11 +346,20 @@ def getStructureFunctions(): def getPersonale(personale_id, full=False): if full: query = Personale.objects.filter( - Q(matricola=personale_id) | Q(cod_fis=personale_id), flg_cessato=0 + Q(matricola=personale_id) | + Q(cod_fis=personale_id), + Q(flg_cessato=0) | + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) & ~Q(didatticacopertura__stato_coper_cod='R') | + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1) & ~Q(didatticacopertura__stato_coper_cod='R') ) else: personale_id = get_personale_matricola(personale_id) - query = Personale.objects.filter(matricola=personale_id, flg_cessato=0) + query = Personale.objects.filter( + Q(flg_cessato=0) | + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) & ~Q(didatticacopertura__stato_coper_cod='R') | + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1) & ~Q(didatticacopertura__stato_coper_cod='R'), + matricola=personale_id, + ) if not query: raise Http404 @@ -649,7 +659,9 @@ def getPersonnelCfs(roles): query_roles = Q(cd_ruolo__in=roles) query = Personale.objects.filter( - query_roles, flg_cessato=0, dt_rap_fin__gte=datetime.datetime.today() + query_roles, + flg_cessato=0, + dt_rap_fin__gte=datetime.datetime.today() ) query = query.values( diff --git a/cds/api/v1/services.py b/cds/api/v1/services.py index 85ffa964..b5f5ba34 100644 --- a/cds/api/v1/services.py +++ b/cds/api/v1/services.py @@ -426,10 +426,9 @@ def getContacts(cdscod): years = [last_year, current_year] query = ( DidatticaCopertura.objects.filter( + Q(personale__flg_cessato=0, personale__fl_docente=1) | Q(coper_cod!='R'), cds_cod=cdscod, aa_off_id__in=years, - personale__flg_cessato=0, - personale__fl_docente=1, ) .values( "personale__nome", diff --git a/teachers/api/v1/services.py b/teachers/api/v1/services.py index fac6d560..aaec2c74 100644 --- a/teachers/api/v1/services.py +++ b/teachers/api/v1/services.py @@ -602,7 +602,7 @@ def teachersList(search, regdid, dip, role, cds, year): query = ( Personale.objects.filter( - Q(fl_docente=1) | Q(didatticacopertura__af__isnull=False), + Q(fl_docente=1) | (Q(didatticacopertura__af__isnull=False) & ~Q(didatticacopertura__stato_coper_cod='R')), query_search, query_cds, query_regdid, @@ -637,10 +637,9 @@ def teachersList(search, regdid, dip, role, cds, year): # altrimenti solo quelli attivi if not regdid and not cds: query = query.filter( - Q(fl_docente=1) - | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) - | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1), - flg_cessato=0, + Q(fl_docente=1, flg_cessato=0), + Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) & ~Q(didatticacopertura__stato_coper_cod='R') + | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1) & ~Q(didatticacopertura__stato_coper_cod!='R') ) if dip: @@ -717,9 +716,9 @@ def teachingCoveragesList(search, regdid, dip, role, cds, year): query_regdid, query_roles, query_year, - didatticacopertura__af__isnull=False, - flg_cessato=0, + didatticacopertura__af__isnull=False ) + .exclude(didatticacopertura__stato_coper_cod='R') .values( "id_ab", "matricola", @@ -867,10 +866,9 @@ def getDocenteInfo(teacher, use_this_id=False): teacher = get_personale_matricola(teacher) query = Personale.objects.filter( - Q(fl_docente=1) - | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) - | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1), - flg_cessato=0, + Q(fl_docente=1, flg_cessato=0) + | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year) & ~Q(didatticacopertura__stato_coper_cod='R') + | Q(didatticacopertura__aa_off_id=datetime.datetime.now().year - 1) & ~Q(didatticacopertura__stato_coper_cod='R'), matricola=teacher, ).distinct()