summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-18 23:19:00 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-18 23:19:00 +0200
commitfdd70f62447f8bba7fca85e8251d277ff3c81e1c (patch)
tree971bf266763a55e18ba12302b49d8afa801ddc28 /ishtar_common
parent1cb5752c02dda43ee8afc2a27c2a3d047ea86b7f (diff)
downloadIshtar-fdd70f62447f8bba7fca85e8251d277ff3c81e1c.tar.bz2
Ishtar-fdd70f62447f8bba7fca85e8251d277ff3c81e1c.zip
Fix "labels" shortcut display for finds and treatments
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index c0ac5004f..2a50533db 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2039,14 +2039,16 @@ class TemplateItem:
@classmethod
def _label_templates_q(cls):
model_name = "{}.{}".format(
- cls.__module__, cls.__name__).replace(
+ cls.__module__, cls.__name__)
+ q = Q(associated_model__klass=model_name,
+ for_labels=True, available=True)
+ alt_model_name = model_name.replace(
"models_finds", "models").replace(
"models_treatments", "models")
- return DocumentTemplate.objects.filter(
- associated_model__klass=model_name,
- for_labels=True,
- available=True
- )
+ if alt_model_name != model_name:
+ q |= Q(associated_model__klass=model_name,
+ for_labels=True, available=True)
+ return DocumentTemplate.objects.filter(q)
@classmethod
def has_label_templates(cls):