From 508a2ecec64fcd3c1ce40ef598f00d6f673e1e5d Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Wed, 15 Jan 2025 09:45:36 +0100 Subject: [PATCH] fix: Addressbook already_taken_contacts --- addressbook/api/v1/services.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/addressbook/api/v1/services.py b/addressbook/api/v1/services.py index 365cea0e..b2bce7f7 100644 --- a/addressbook/api/v1/services.py +++ b/addressbook/api/v1/services.py @@ -118,7 +118,7 @@ def getAddressbook( for p in priorita_tmp: priorita.update({p["cd_ruolo"]: p["priorita"]}) - # already_taken_contacts = [] + already_taken_contacts = [] for q in query: if q["id_ab"] not in grouped: grouped[q["id_ab"]] = { @@ -153,15 +153,15 @@ def getAddressbook( ] if ( not bool(res) - # and q["personalecontatti__contatto"].lower() - # not in already_taken_contacts + and f'{q["personalecontatti__cd_tipo_cont__pk"].lower()}-{q["personalecontatti__contatto"].lower()}' + not in already_taken_contacts ): grouped[q["id_ab"]][ q["personalecontatti__cd_tipo_cont__descr_contatto"] ].append(q["personalecontatti__contatto"]) - # already_taken_contacts.append( - # q["personalecontatti__contatto"].lower() - # ) + already_taken_contacts.append( + f'{q["personalecontatti__cd_tipo_cont__pk"].lower()}-{q["personalecontatti__contatto"].lower()}' + ) if last_id == -1 or last_id != q["id_ab"]: last_id = q["id_ab"] @@ -495,7 +495,7 @@ def getPersonale(personale_id, full=False): roles.append(d_data) roles.sort(key=lambda x: x["priorita"]) - # already_taken_contacts = [] + already_taken_contacts = [] for q in query: for c in PERSON_CONTACTS_TO_TAKE: q[c] = [] @@ -509,15 +509,15 @@ def getPersonale(personale_id, full=False): ] if ( not bool(res) - # and c["personalecontatti__contatto"].lower() - # not in already_taken_contacts + and f'{c["personalecontatti__cd_tipo_cont__pk"].lower()}-{c["personalecontatti__contatto"].lower()}' + not in already_taken_contacts ): q[c["personalecontatti__cd_tipo_cont__descr_contatto"]].append( c["personalecontatti__contatto"] ) - # already_taken_contacts.append( - # c["personalecontatti__contatto"].lower() - # ) + already_taken_contacts.append( + f'{c["personalecontatti__cd_tipo_cont__pk"].lower()}-{c["personalecontatti__contatto"].lower()}' + ) if len(functions) == 0: q["Functions"] = None