Skip to content

Commit

Permalink
fix: addressbook roles fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Nov 13, 2024
1 parent ebb692b commit 6f3f641
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addressbook/api/v1/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def getAddressbook(
"profilo",
"ds_profilo",
"ds_profilo_breve",
"cd_ruolo",
"ds_ruolo_locale",
).order_by("cognome", "nome")
)

Expand Down Expand Up @@ -181,6 +183,16 @@ def getAddressbook(

roles.append(d_data)

if not roles:
roles = [{"matricola": q["matricola"],
"cd_ruolo": q["cd_ruolo"],
"ds_ruolo": q["ds_ruolo_locale"],
"priorita": 1,
"cd_uo_aff_org": None,
"ds_aff_org": None,
"cd_tipo_nodo": None,
"sede": None}]

roles.sort(key=lambda x: x["priorita"])
grouped[q["id_ab"]]["Roles"] = roles
final_query.append(grouped[q["id_ab"]])
Expand Down

0 comments on commit 6f3f641

Please sign in to comment.