From 029b74dfa13919222138734b41265642e30494ab Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 29 Oct 2018 23:14:22 +0100 Subject: Add update_data util to overload data dict properly --- scripts/restore_find_data.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 scripts/restore_find_data.py (limited to 'scripts/restore_find_data.py') diff --git a/scripts/restore_find_data.py b/scripts/restore_find_data.py new file mode 100644 index 000000000..3dbbc4518 --- /dev/null +++ b/scripts/restore_find_data.py @@ -0,0 +1,19 @@ +""" +Restore find data on destructive import +""" + +from ishtar_common.utils import update_data + +from archaeological_finds.models import Find + + +for item in Find.objects.all()[0:50]: + data = item.data + for h in item.history.order_by('-history_modifier_id', '-history_date', + '-history_id').all(): + data = update_data(data, h.data) + item.data = data + item.skip_history_when_saving = True + item.save() + + -- cgit v1.2.3