Commit a76e5f3645ddf0593c76738d73ee99757ef5e9fe
1 parent
47688d90
Exists in
master
and in
3 other branches
Webpages list visualization control
Showing
3 changed files
with
9 additions
and
3 deletions
Show diff stats
amadeus/permissions.py
@@ -39,7 +39,7 @@ def has_resource_permissions(user, resource): | @@ -39,7 +39,7 @@ def has_resource_permissions(user, resource): | ||
39 | 39 | ||
40 | if resource.visible or resource.topic.repository: | 40 | if resource.visible or resource.topic.repository: |
41 | if resource.all_students: | 41 | if resource.all_students: |
42 | - if subject.students.filter(id = user.id).exists(): | 42 | + if resource.topic.subject.students.filter(id = user.id).exists(): |
43 | return True | 43 | return True |
44 | 44 | ||
45 | if resource.students.filter(id = user.id).exists(): | 45 | if resource.students.filter(id = user.id).exists(): |
amadeus/templatetags/permissions_tags.py
@@ -10,4 +10,8 @@ def subject_permissions(user, subject): | @@ -10,4 +10,8 @@ def subject_permissions(user, subject): | ||
10 | 10 | ||
11 | @register.assignment_tag | 11 | @register.assignment_tag |
12 | def subject_view_permissions(user, subject): | 12 | def subject_view_permissions(user, subject): |
13 | - return permissions.has_subject_view_permissions(user, subject) | ||
14 | \ No newline at end of file | 13 | \ No newline at end of file |
14 | + return permissions.has_subject_view_permissions(user, subject) | ||
15 | + | ||
16 | +@register.assignment_tag | ||
17 | +def resource_permissions(user, resource): | ||
18 | + return permissions.has_resource_permissions(user, resource) | ||
15 | \ No newline at end of file | 19 | \ No newline at end of file |
topics/templates/resources/list.html
@@ -5,7 +5,9 @@ | @@ -5,7 +5,9 @@ | ||
5 | 5 | ||
6 | <div id="resource_{{ topic.slug }}" class="list-group resource_list"> | 6 | <div id="resource_{{ topic.slug }}" class="list-group resource_list"> |
7 | {% for resource in topic.resource_topic.all %} | 7 | {% for resource in topic.resource_topic.all %} |
8 | - {% if resource.visible or has_subject_permissions %} | 8 | + {% resource_permissions request.user resource as has_resource_permissions %} |
9 | + | ||
10 | + {% if has_resource_permissions %} | ||
9 | <div class="list-group-item {% if not resource.visible %}disabled{% endif %}"> | 11 | <div class="list-group-item {% if not resource.visible %}disabled{% endif %}"> |
10 | <input type="hidden" class="id_inp" name="id" value="{{ resource.id }}" /> | 12 | <input type="hidden" class="id_inp" name="id" value="{{ resource.id }}" /> |
11 | <input type="hidden" class="order_inp" name="order" value="{{ resource.order }}" /> | 13 | <input type="hidden" class="order_inp" name="order" value="{{ resource.order }}" /> |