diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-06-01 14:02:59 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-06-01 14:02:59 +0200 |
commit | 25e1287c1c139e21693a4a01a1592332b8016d59 (patch) | |
tree | b06809d5e620495e33587b19acf64aa0b89c30dc /ishtar_common | |
parent | eba9c7a64ad884c8a1fffd4f4b652e6dfff5101c (diff) | |
download | Ishtar-25e1287c1c139e21693a4a01a1592332b8016d59.tar.bz2 Ishtar-25e1287c1c139e21693a4a01a1592332b8016d59.zip |
Custom index - document: operation_source_type_code, index by operation and source_type code
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models.py | 13 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 72b2ff9cb..94e02aafe 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3880,7 +3880,14 @@ class Document( ) return list(set(operations)) - def get_index_operation(self): + def get_index_operation_source_type_code(self): + if not self.source_type or not self.source_type.code: + return + return self.get_index_operation( + extra_filters={"source_type__code": self.source_type.code} + ) + + def get_index_operation(self, extra_filters=None): operations = self.get_related_operation_ids() if len(operations) != 1: return @@ -3892,8 +3899,10 @@ class Document( | Q(context_records__operation_id=current_operation) | Q(finds__base_finds__context_record__operation_id=current_operation) ) - .order_by("-custom_index") ) + if extra_filters: + q = q.filter(**extra_filters) + q = q.order_by("-custom_index") current_index = None for doc in q.all(): if not doc.custom_index: diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 7a0397c36..db7e77ce0 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -3034,6 +3034,7 @@ class CompleteIdentifierItem(models.Model, ImageContainerModel): try: self_keys = set(list(model.objects.filter(pk=self.pk).values_list(*keys))) except Exception: # bad settings - not managed here + print("Bad settings for custom_index {}".format(";".join(keys))) return if len(self_keys) != 1: # key is not distinct return |