diff options
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 |
commit | 11a0a14931cc5cc6f6f2a128f6d02dea93562438 (patch) | |
tree | 93bff58404c855b89d4c337ce1f01c34bacacd41 | |
parent | e1f7bda77320dff67bb77514bbd649b08fa5b00b (diff) | |
download | Ishtar-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.py | 7 |
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: |