Skip to content

Commit cfcdabc

Browse files
author
Ross Mechanic
authored
Cleaned up create_historical_record call (#550)
1 parent 36dd049 commit cfcdabc

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

simple_history/models.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,22 +435,17 @@ def post_save(self, instance, created, using=None, **kwargs):
435435
if not created and hasattr(instance, "skip_history_when_saving"):
436436
return
437437
if not kwargs.get("raw", False):
438-
self.create_historical_record(
439-
instance,
440-
created and "+" or "~",
441-
using=using if self.use_base_model_db else None,
442-
)
438+
self.create_historical_record(instance, created and "+" or "~", using=using)
443439

444440
def post_delete(self, instance, using=None, **kwargs):
445441
if self.cascade_delete_history:
446442
manager = getattr(instance, self.manager_name)
447443
manager.using(using).all().delete()
448444
else:
449-
self.create_historical_record(
450-
instance, "-", using=using if self.use_base_model_db else None
451-
)
445+
self.create_historical_record(instance, "-", using=using)
452446

453447
def create_historical_record(self, instance, history_type, using=None):
448+
using = using if self.use_base_model_db else None
454449
history_date = getattr(instance, "_history_date", now())
455450
history_user = self.get_history_user(instance)
456451
history_change_reason = getattr(instance, "changeReason", None)

0 commit comments

Comments
 (0)