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 | 39 | |
40 | 40 | if resource.visible or resource.topic.repository: |
41 | 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 | 43 | return True |
44 | 44 | |
45 | 45 | if resource.students.filter(id = user.id).exists(): | ... | ... |
amadeus/templatetags/permissions_tags.py
... | ... | @@ -10,4 +10,8 @@ def subject_permissions(user, subject): |
10 | 10 | |
11 | 11 | @register.assignment_tag |
12 | 12 | def subject_view_permissions(user, subject): |
13 | - return permissions.has_subject_view_permissions(user, subject) | |
14 | 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 | 19 | \ No newline at end of file | ... | ... |
topics/templates/resources/list.html
... | ... | @@ -5,7 +5,9 @@ |
5 | 5 | |
6 | 6 | <div id="resource_{{ topic.slug }}" class="list-group resource_list"> |
7 | 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 | 11 | <div class="list-group-item {% if not resource.visible %}disabled{% endif %}"> |
10 | 12 | <input type="hidden" class="id_inp" name="id" value="{{ resource.id }}" /> |
11 | 13 | <input type="hidden" class="order_inp" name="order" value="{{ resource.order }}" /> | ... | ... |