diff --git a/courses/templates/course/view.html b/courses/templates/course/view.html index cb3e92d..d5519a1 100644 --- a/courses/templates/course/view.html +++ b/courses/templates/course/view.html @@ -1,6 +1,6 @@ {% extends 'home.html' %} -{% load static i18n permission_tags %} +{% load static i18n permission_tags custom_filters %} {% load django_bootstrap_breadcrumbs %} {% block style %} @@ -217,7 +217,7 @@ {% endif %} - {% if user|has_role:'student' and not user in subject.students.all and subject.show_subscribe %} + {% if user|show_subject_subscribe:subject %}
{% trans 'Subscribe' %}
@@ -269,7 +269,7 @@ {% endif %} - {% if user|has_role:'student' and not user in subject.students and subject.show_subscribe %} + {% if user|show_subject_subscribe:subject %}
{% trans 'Subscribe' %}
diff --git a/courses/templatetags/custom_filters.py b/courses/templatetags/custom_filters.py new file mode 100644 index 0000000..65661fd --- /dev/null +++ b/courses/templatetags/custom_filters.py @@ -0,0 +1,15 @@ +from django import template +from rolepermissions.verifications import has_role +import datetime + +register = template.Library() + +@register.filter +def show_subject_subscribe(user, subject): + if not user is None: + if user.is_authenticated: + if has_role(user, 'student'): + if not user in subject.students.all() and subject.show_subscribe: + return True + + return False \ No newline at end of file -- libgit2 0.21.2