summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-05 12:18:10 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-05 12:18:10 +0100
commit11a0a14931cc5cc6f6f2a128f6d02dea93562438 (patch)
tree93bff58404c855b89d4c337ce1f01c34bacacd41
parente1f7bda77320dff67bb77514bbd649b08fa5b00b (diff)
downloadIshtar-11a0a14931cc5cc6f6f2a128f6d02dea93562438.tar.bz2
Ishtar-11a0a14931cc5cc6f6f2a128f6d02dea93562438.zip
History: if a previous step do not exist, get the first in history
-rw-r--r--ishtar_common/models.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 610d92551..674e42538 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1179,8 +1179,11 @@ class BaseHistorizedItem(FullSearch, Imported, JsonData, FixAssociated):
historized = self.history.all()
item = None
if step:
- assert len(historized) > step
- item = historized[step]
+ if len(historized) <= step:
+ # silently return the last step if too far in the history
+ item = historized[len(historized) - 1]
+ else:
+ item = historized[step]
else:
for step, item in enumerate(historized):
if item.history_date == date: