Skip to content

Commit

Permalink
fix: addressbook structure filter checks sede field
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Jul 15, 2024
1 parent 1f6346c commit b5720c9
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions ricerca_app/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,8 @@ def getAddressbook(
'cd_uo_aff_org',
'ds_aff_org',
'cd_uo_aff_org__cd_tipo_nodo',
'dt_rap_ini'
'dt_rap_ini',
'sede'
).distinct()

ruoli_dict = {}
Expand All @@ -3424,7 +3425,8 @@ def getAddressbook(
r['ds_ruolo'],
r['cd_uo_aff_org'],
r['ds_aff_org'],
r['cd_uo_aff_org__cd_tipo_nodo']]
r['cd_uo_aff_org__cd_tipo_nodo']],
r['sede']]
if full: l_data.append(r['dt_rap_ini'])

ruoli_dict[r['matricola']].append(l_data)
Expand Down Expand Up @@ -3483,6 +3485,7 @@ def getAddressbook(
'cd_uo_aff_org': r[2],
'ds_aff_org': r[3],
'cd_tipo_nodo': r[4],
'sede': r[5]
}
if full:
d_data['dt_rap_ini'] = r[5]
Expand Down Expand Up @@ -3539,8 +3542,8 @@ def getAddressbook(

for item in filtered3:
for r in item['Roles']:
if r['cd_uo_aff_org'] == structureid:
if r['cd_ruolo'] in role or item['profilo'] in role or not role:
if r['cd_uo_aff_org'] == structureid or r['sede'] == structureid:
if not role or r['cd_ruolo'] in role or item['profilo'] in role:
filtered4.append(item)
break
else:
Expand All @@ -3553,7 +3556,7 @@ def getAddressbook(
for item in filtered4:
if item['Roles'] and len(item['Roles']) != 0:
for r in item['Roles']:
if r['cd_uo_aff_org'] in query_structuretree:
if r['cd_uo_aff_org'] in query_structuretree or r['sede'] in query_structuretree:
if r['cd_ruolo'] in role or item['profilo'] in role or not role:
filtered5.append(item)
break
Expand Down Expand Up @@ -4713,22 +4716,14 @@ def getProjectInfrastructures():


class ServiceStructure:

@staticmethod
def getStructureChilds(structureid=None):

child = UnitaOrganizzativa.objects.filter(
uo_padre=structureid,
dt_fine_val__gte=datetime.datetime.today()).values_list("uo", flat=True)

result = [structureid]


for c in child:

structures_tree = ServiceStructure.getStructureChilds(c)
result.extend(structures_tree)

result.extend(child)

return result

0 comments on commit b5720c9

Please sign in to comment.