Commit fa8acea4a8926fe09352f93223e31088fd125dfb

Authored by Felipe Henrique de Almeida Bormann
2 parents 9b2182dd cfbf635f

Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring

amadeus/templatetags/permissions_tags.py 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +from django import template
  2 +
  3 +from amadeus import permissions
  4 +
  5 +register = template.Library()
  6 +
  7 +@register.assignment_tag
  8 +def subject_permissions(user, subject):
  9 + return permissions.has_subject_permissions(user, subject)
0 10 \ No newline at end of file
... ...
subjects/templates/subjects/view.html
1 1 {% extends 'categories/home.html' %}
2 2  
3   -{% load static i18n pagination %}
  3 +{% load static i18n pagination permissions_tags %}
4 4 {% load django_bootstrap_breadcrumbs %}
5 5  
6 6 {% block javascript%}
... ... @@ -25,10 +25,12 @@
25 25 {% endfor %}
26 26 {% endif %}
27 27  
  28 + {% subject_permissions request.user subject as has_subject_permissions %}
  29 +
28 30 {% if subject.visible %}
29 31 <div class="panel panel-info subject-panel">
30 32 <div class="panel-heading">
31   - {% elif request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %}
  33 + {% elif has_subject_permissions %}
32 34 <div class="panel panel-info subject-panel-invisible">
33 35 <div class="panel-heading panel-invisible">
34 36 {% endif %}
... ... @@ -78,7 +80,7 @@
78 80  
79 81 <p>{{subject.description|safe}}</p>
80 82  
81   - {% if request.user in subject.professor.all or request.user in subject.category.coordinators.all or request.user.is_staff %}
  83 + {% if has_subject_permissions %}
82 84 <a href="{% url 'topics:create' subject.slug %}" class="btn btn-sm btn-success btn-raised btn-block">{% trans "Create new topic" %}</a>
83 85 {% endif %}
84 86  
... ...