diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/templatetags/app_filter.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/client/templatetags/app_filter.py b/client/templatetags/app_filter.py index 3120b8e..e49e8a9 100644 --- a/client/templatetags/app_filter.py +++ b/client/templatetags/app_filter.py @@ -1,7 +1,22 @@ from django import template -from client.models import KeyVal +from django.db.models.query_utils import Q +from client.models import Document, KeyVal register = template.Library() @register.filter(name="doc_key") def doc_key(doc): - return KeyVal.objects.filter(container=doc)
\ No newline at end of file + return KeyVal.objects.filter(container=doc) + +@register.filter(name="user_docs") +def user_docs(admin_user, user): + parent_group = admin_user.groups.values_list('name', flat=True)[0] + documents = Document.objects.filter(Q(user=user) & ~Q(status='archive') & Q(group__name=parent_group)) + return documents + +@register.filter(name="user_groups") +def user_groups(user): + return user.groups.values_list('name', flat=True) + +@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 |