summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2014-07-15 19:49:32 +0200
committerÉtienne Loks <etienne.loks@proxience.com>2014-07-15 19:49:32 +0200
commitafa94b470a1e487a045bb24edf9054fdddfa0209 (patch)
tree242723c196943164000a0a09c47ac749568da4cb /archaeological_operations
parentea0d4565ce035c49fd08c2791df71bd8d36a5579 (diff)
downloadIshtar-afa94b470a1e487a045bb24edf9054fdddfa0209.tar.bz2
Ishtar-afa94b470a1e487a045bb24edf9054fdddfa0209.zip
Fix history creator reinit when teh creator dosn't exist anymore
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/migrations/0024_reinit_history_creator.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/archaeological_operations/migrations/0024_reinit_history_creator.py b/archaeological_operations/migrations/0024_reinit_history_creator.py
index 40292844b..8a6b1f819 100644
--- a/archaeological_operations/migrations/0024_reinit_history_creator.py
+++ b/archaeological_operations/migrations/0024_reinit_history_creator.py
@@ -14,12 +14,26 @@ class Migration(DataMigration):
).order_by('history_date', 'history_id')
if not q.count():
return
- hist_item = q.all()[0]
- creator_id = hist_item.history_modifier_id
+ hist_items, idx = list(q.all()), 0
+ creator_id = None
+ while not creator_id:
+ if len(hist_items) <= idx:
+ break
+ hist_item = hist_items[idx]
+ try:
+ creator = orm['auth.User'].objects.get(
+ pk=hist_item.history_modifier_id)
+ creator_id = creator.pk
+ except:
+ pass
+ idx += 1
+ if not creator_id:
+ continue
+
item.history_creator_id = creator_id
item.skip_history_when_saving = True
item.save()
- for hist in q.all():
+ for hist in hist_items:
hist.history_creator_id = creator_id
hist.save()