From cfbf635f10b701eb946b4e6db5890678d26b7aa0 Mon Sep 17 00:00:00 2001 From: Zambom Date: Tue, 17 Jan 2017 16:13:06 -0200 Subject: [PATCH] Adding file to store permission tags --- amadeus/templatetags/permissions_tags.py | 9 +++++++++ subjects/templates/subjects/view.html | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 amadeus/templatetags/permissions_tags.py diff --git a/amadeus/templatetags/permissions_tags.py b/amadeus/templatetags/permissions_tags.py new file mode 100644 index 0000000..8aeb669 --- /dev/null +++ b/amadeus/templatetags/permissions_tags.py @@ -0,0 +1,9 @@ +from django import template + +from amadeus import permissions + +register = template.Library() + +@register.assignment_tag +def subject_permissions(user, subject): + return permissions.has_subject_permissions(user, subject) \ No newline at end of file diff --git a/subjects/templates/subjects/view.html b/subjects/templates/subjects/view.html index 3cd0c24..bac61a7 100644 --- a/subjects/templates/subjects/view.html +++ b/subjects/templates/subjects/view.html @@ -1,6 +1,6 @@ {% extends 'categories/home.html' %} -{% load static i18n pagination %} +{% load static i18n pagination permissions_tags %} {% load django_bootstrap_breadcrumbs %} {% block javascript%} @@ -25,10 +25,12 @@ {% endfor %} {% endif %} + {% subject_permissions request.user subject as has_subject_permissions %} + {% if subject.visible %}
- {% elif request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} + {% elif has_subject_permissions %}
{% endif %} @@ -78,7 +80,7 @@

{{subject.description|safe}}

- {% if request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %} + {% if has_subject_permissions %} {% trans "Create new topic" %} {% endif %} -- libgit2 0.21.2