Skip to content

Commit

Permalink
Finish feature/OFS-99
Browse files Browse the repository at this point in the history
OFS-99: django-dirty-fields bug - applied additional param in 'is_dirty'
  • Loading branch information
dragos-dobre committed Dec 2, 2020
2 parents fa8a8ba + 1a41c98 commit 3ad0cba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/models.py
Expand Up @@ -591,7 +591,7 @@ def save(self, *args, **kwargs):
self.date_created = now
self.date_updated = now
return super(HistoryModel, self).save()
if self.is_dirty():
if self.is_dirty(check_relationship=True):
self.date_updated = now
self.user_updated = user
self.version = self.version + 1
Expand All @@ -604,7 +604,7 @@ def delete_history(self):

def delete(self, *args, **kwargs):
user = User.objects.get(**kwargs)
if not self.is_dirty() and not self.is_deleted:
if not self.is_dirty(check_relationship=True) and not self.is_deleted:
self.date_updated = py_datetime.now()
self.user_updated = user
self.version = self.version + 1
Expand Down Expand Up @@ -654,7 +654,7 @@ def _create_new_entity(self, user):

def _update_replaced_entity(self, user, uuid_from_new_entity, date_valid_from_new_entity):
"""2 step - update the fields for the entity to be replaced"""
if not self.is_dirty():
if not self.is_dirty(check_relationship=True):
if self.date_valid_to is not None:
if date_valid_from_new_entity < self.date_valid_to:
self.date_valid_to = date_valid_from_new_entity
Expand Down

0 comments on commit 3ad0cba

Please sign in to comment.