set ModelLog transactions as atomic

sync
Laurent 9 months ago
parent 5922e1b6ec
commit 8b8e0eb9d5
  1. 3
      sync/models/model_log.py
  2. 1
      sync/signals.py

@ -24,6 +24,9 @@ class ModelLog(models.Model):
device_id = models.CharField(max_length=200, blank=True, null=True)
count = models.IntegerField(default=0)
class Meta:
ordering = ['-date']
def formatted_time(self):
return self.date.strftime('%H:%M:%S.%f')

@ -120,6 +120,7 @@ def save_model_log_if_possible(instance, signal, created, device_id):
def save_model_log(users, model_operation, model_name, model_id, store_id, device_id):
with transaction.atomic():
model_log = ModelLog()
model_log.operation = model_operation
model_log.model_name = model_name

Loading…
Cancel
Save