From a9962cdce67c9a55046ac25104ff222d1c16b0fc Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 5 Feb 2025 16:23:41 +0100 Subject: [PATCH] shows time of ModelLog --- sync/admin.py | 2 +- sync/models/model_log.py | 3 +++ sync/signals.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sync/admin.py b/sync/admin.py index 894c2da..41ab058 100644 --- a/sync/admin.py +++ b/sync/admin.py @@ -20,7 +20,7 @@ class SyncedObjectAdmin(admin.ModelAdmin): queryset.delete() class ModelLogAdmin(admin.ModelAdmin): - list_display = ['get_users', 'date', 'operation', 'model_id', 'model_name', 'count'] + list_display = ['get_users', 'formatted_time', 'operation', 'model_id', 'model_name', 'count'] list_filter = ['users', 'operation', 'model_name'] ordering = ['-date'] search_fields = ['model_id'] diff --git a/sync/models/model_log.py b/sync/models/model_log.py index a5fc3cb..1b84dc0 100644 --- a/sync/models/model_log.py +++ b/sync/models/model_log.py @@ -22,6 +22,9 @@ class ModelLog(models.Model): device_id = models.CharField(max_length=200, blank=True, null=True) count = models.IntegerField(default=0) + def formatted_time(self): + return self.date.strftime('%H:%M:%S.%f') + def save(self, *args, **kwargs): # Round microseconds to milliseconds (3 decimals to match Swift precision) if self.date: diff --git a/sync/signals.py b/sync/signals.py index d1411dc..7b4a78c 100644 --- a/sync/signals.py +++ b/sync/signals.py @@ -120,11 +120,11 @@ def save_model_log(users, model_operation, model_name, model_id, store_id, devic model_log = ModelLog() model_log.operation = model_operation - model_log.date = timezone.now() model_log.model_name = model_name model_log.model_id = model_id model_log.store_id = store_id model_log.device_id = device_id + model_log.date = timezone.now() model_log.save() model_log.users.set(users)