aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/templatetags/app_filter.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/client/templatetags/app_filter.py b/client/templatetags/app_filter.py
index e49e8a9..9f378e1 100644
--- a/client/templatetags/app_filter.py
+++ b/client/templatetags/app_filter.py
@@ -1,12 +1,16 @@
from django import template
from django.db.models.query_utils import Q
-from client.models import Document, KeyVal
+from client.models import Document, KeyVal, Keys
register = template.Library()
@register.filter(name="doc_key")
def doc_key(doc):
return KeyVal.objects.filter(container=doc)
+@register.filter(name="doc_key_type")
+def doc_key_type(doc_type):
+ return Keys.objects.filter(container=doc_type)
+
@register.filter(name="user_docs")
def user_docs(admin_user, user):
parent_group = admin_user.groups.values_list('name', flat=True)[0]
@@ -19,4 +23,15 @@ def user_groups(user):
@register.filter(name="user_primary_group")
def user_primary_group(user):
- return user.groups.values_list('name', flat=True)[0] \ No newline at end of file
+ return user.groups.values_list('name', flat=True)[0]
+
+@register.filter(name="doc_count")
+def doc_count(doc):
+ doc_count = str(Document.objects.filter(document_type=doc).count())
+ ref_docs_archived = Document.objects.filter(document_type=doc, status="archive").count()
+ if ref_docs_archived > 0:
+ doc_count += "-" + str(ref_docs_archived)
+ if doc.max_instances != 0:
+ doc_count += "/" + str(doc.max_instances)
+
+ return doc_count \ No newline at end of file