Skip to content

Commit

Permalink
brand will be update by c1 sync only if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Nov 27, 2024
1 parent 8194dba commit 0e7c042
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

UPDATE_FIELDS = [
# "name", # what happens to the slug if the name is updated?
"brand",
# "brand", # see UPDATE_FIELDS_IF_EMPTY
# "kind"
"siret",
"siret_is_valid",
Expand All @@ -39,6 +39,8 @@
"c1_last_sync_date",
]

UPDATE_FIELDS_IF_EMPTY = ["brand"]

C1_EXTRA_KEYS = ["convention_is_active", "convention_asp_id"]


Expand Down Expand Up @@ -272,5 +274,10 @@ def c4_update_siae(self, c1_siae, c4_siae, dry_run):
if key in c1_siae:
c1_siae_filtered[key] = c1_siae[key]

# update fields only if empty
for key in UPDATE_FIELDS_IF_EMPTY:
if key in c1_siae and not c4_siae[key]:
c1_siae_filtered[key] = c1_siae[key]

Siae.objects.filter(c1_id=c4_siae.c1_id).update(**c1_siae_filtered) # avoid updated_at change
# self.stdout_info(f"Siae updated / {c4_siae.id} / {c4_siae.siret}")

0 comments on commit 0e7c042

Please sign in to comment.