Skip to content

Commit

Permalink
fix: docenti
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Nov 13, 2024
1 parent 8677032 commit b7415ac
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
28 changes: 20 additions & 8 deletions addressbook/api/v1/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ def getAddressbook(
query = (
Personale.objects.filter(
query_search,
flg_cessato=0,
# flg_cessato=0,
# cd_uo_aff_org__isnull=False,
dt_rap_fin__gte=datetime.datetime.today(),
)
.values(
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')
).values(
"nome",
"middle_name",
"cognome",
Expand All @@ -68,8 +70,7 @@ def getAddressbook(
"profilo",
"ds_profilo",
"ds_profilo_breve",
)
.order_by("cognome", "nome")
).order_by("cognome", "nome")
)

grouped = {}
Expand Down Expand Up @@ -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(
matricola=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')
)
if not query:
raise Http404

Expand Down Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions cds/api/v1/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ def getContacts(cdscod):
DidatticaCopertura.objects.filter(
cds_cod=cdscod,
aa_off_id__in=years,
personale__flg_cessato=0,
personale__fl_docente=1,
Q(personale__flg_cessato=0, personale__fl_docente=1) | Q(coper_cod!='R'),
)
.values(
"personale__nome",
Expand Down
20 changes: 9 additions & 11 deletions teachers/api/v1/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit b7415ac

Please sign in to comment.