diff --git a/asuzr/templatetags/__init__.py b/asuzr/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/asuzr/templatetags/filters.py b/asuzr/templatetags/filters.py new file mode 100644 index 0000000..ed1e053 --- /dev/null +++ b/asuzr/templatetags/filters.py @@ -0,0 +1,9 @@ +from django import template +from django.contrib.auth.models import Group + +register = template.Library() + +@register.filter(name='has_group') +def has_group(user, group_name): + group = Group.objects.get(name=group_name) + return True if group in user.groups.all() else False diff --git a/templates/asuzr/base.html b/templates/asuzr/base.html index 1ad7710..5dc577a 100644 --- a/templates/asuzr/base.html +++ b/templates/asuzr/base.html @@ -1,4 +1,6 @@ {% load inplace_edit %} +{% load filters %} +