From cccde539177da309bc3af5549bccaa65aca172ca Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 9 Jun 2022 15:54:37 +0200 Subject: custom index: "whole_db" key is available for index on the whole db --- ishtar_common/models_common.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ishtar_common/models_common.py') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index fd1a00d95..ac42e5ee6 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -3021,6 +3021,14 @@ class CompleteIdentifierItem(models.Model, ImageContainerModel): complete_identifier = getattr(self, cached_label_key) return complete_identifier + def get_index_whole_db(self): + q = self.__class__.objects.exclude(custom_index__isnull=True) + q = q.order_by("-custom_index") + if q.count(): + current_index = q.values_list("custom_index", flat=True).all()[0] + return current_index + 1 + return 1 + def generate_custom_index(self, force=False): if not self.pk: return -- cgit v1.2.3