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
commit5a616ab12800f0647414824ec000ef05e64074fd (patch)
tree242723c196943164000a0a09c47ac749568da4cb /archaeological_operations
parent3c4675c7d2f657a5dce8bf55cc8b6a3289197943 (diff)
downloadIshtar-5a616ab12800f0647414824ec000ef05e64074fd.tar.bz2
Ishtar-5a616ab12800f0647414824ec000ef05e64074fd.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()