summaryrefslogtreecommitdiff
path: root/ishtar_common/utils_migrations.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-10-17 17:33:30 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-10-24 12:06:09 +0200
commite98b1dc6156eda6261e158f02868d9f8d51b2913 (patch)
treec8c33449dc1ad25f195839068fa1fdd6125931ec /ishtar_common/utils_migrations.py
parent359a43054add412d143d66b5e41cf1d2058fd4fe (diff)
downloadIshtar-e98b1dc6156eda6261e158f02868d9f8d51b2913.tar.bz2
Ishtar-e98b1dc6156eda6261e158f02868d9f8d51b2913.zip
Find: search last modified and modified by
Diffstat (limited to 'ishtar_common/utils_migrations.py')
-rw-r--r--ishtar_common/utils_migrations.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/ishtar_common/utils_migrations.py b/ishtar_common/utils_migrations.py
index 48e9e4f9b..40cdcb5cd 100644
--- a/ishtar_common/utils_migrations.py
+++ b/ishtar_common/utils_migrations.py
@@ -75,3 +75,25 @@ def migrate_sources(apps, base_model, source_model, item_attr):
doc.authors.add(author)
item = base_model.objects.get(pk=getattr(source, item_attr).pk)
item.documents.add(doc)
+
+
+def reinit_last_modified(apps, app_name, models):
+ for model_name in models:
+ model = apps.get_model(app_name, model_name)
+ try:
+ historical_model = apps.get_model(
+ app_name, 'Historical' + model_name)
+ except:
+ continue
+ for item in model.objects.all():
+ q = historical_model.objects.filter(
+ id=item.pk).order_by('-history_date')
+ if not q.count():
+ return
+ edit_date = q.all()[0].history_date
+ if not edit_date:
+ return
+ item.last_modified = edit_date
+ item.skip_history_when_saving = True
+ item.save()
+