Skip to content

Commit

Permalink
Skip the PURL fields in update_from_data #45
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed May 28, 2024
1 parent ae1e2d4 commit c255f58
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dje/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
" either nexB master reference data or installation-specific data."
)

# PackageURL._fields
PURL_FIELDS = ("type", "namespace", "name", "version", "qualifiers", "subpath")


def is_dataspace_related(model_class):
"""
Expand Down Expand Up @@ -759,7 +762,12 @@ def update_from_data(self, user, data, override=False):
updated_fields = []

for field_name, value in data.items():
if value in EMPTY_VALUES or field_name not in model_fields:
skip_reasons = [
value in EMPTY_VALUES,
field_name not in model_fields,
field_name in PURL_FIELDS,
]
if any(skip_reasons):
continue

current_value = getattr(self, field_name, None)
Expand All @@ -769,7 +777,7 @@ def update_from_data(self, user, data, override=False):

if updated_fields:
self.last_modified_by = user
self.save()
self.save(update_fields=updated_fields)

return updated_fields

Expand Down

0 comments on commit c255f58

Please sign in to comment.