Commit c63d5b3629f497b1b982fd45ce617d4c9e61316e
1 parent
d0908746
Exists in
master
and in
3 other branches
Adding invisiblity propagation on subjects/topics/resources and adjust invisible…
… resource presentation
Showing
7 changed files
with
39 additions
and
26 deletions
Show diff stats
categories/templates/categories/list.html
| ... | ... | @@ -117,8 +117,6 @@ |
| 117 | 117 | <li><a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> |
| 118 | 118 | </ul> |
| 119 | 119 | {% endif %} |
| 120 | - <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
| 121 | - <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | |
| 122 | 120 | </div> |
| 123 | 121 | </div> |
| 124 | 122 | </div> | ... | ... |
categories/views.py
| ... | ... | @@ -22,6 +22,7 @@ from log.models import Log |
| 22 | 22 | |
| 23 | 23 | import time |
| 24 | 24 | |
| 25 | +from topics.models import Topic, Resource | |
| 25 | 26 | from users.models import User |
| 26 | 27 | |
| 27 | 28 | class IndexView(views.SuperuserRequiredMixin, LoginRequiredMixin, ListView): |
| ... | ... | @@ -212,10 +213,9 @@ class UpdateCategory(LogMixin, UpdateView): |
| 212 | 213 | category = form.save() |
| 213 | 214 | |
| 214 | 215 | if not category.visible: |
| 215 | - for subjects in category.subject_category.all(): | |
| 216 | - subjects.visible = False | |
| 217 | - | |
| 218 | - subjects.save() | |
| 216 | + category.subject_category.all().update(visible = False) | |
| 217 | + Topic.objects.filter(subject__category = category, repository = False).update(visible = False) | |
| 218 | + Resource.objects.filter(topic__subject__category = category, topic__repository = False).update(visible = False) | |
| 219 | 219 | |
| 220 | 220 | return super(UpdateCategory, self).form_valid(form) |
| 221 | 221 | ... | ... |
pdf_file/templates/pdf_file/view.html
| ... | ... | @@ -24,14 +24,14 @@ |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | {% block content %} |
| 27 | - {% subject_permissions request.user subject as has_subject_permissions %} | |
| 28 | - | |
| 29 | - {% if subject.visible %} | |
| 30 | - <div class="panel panel-info topic-panel"> | |
| 31 | - <div class="panel-heading"> | |
| 32 | - {% elif has_subject_permissions %} | |
| 33 | - <div class="panel panel-info topic-panel-invisible"> | |
| 34 | - <div class="panel-heading panel-invisible"> | |
| 27 | + {% resource_permissions request.user pdf_file as has_resource_permissions %} | |
| 28 | + | |
| 29 | + {% if pdf_file.visible %} | |
| 30 | + <div class="panel panel-info topic-panel"> | |
| 31 | + <div class="panel-heading"> | |
| 32 | + {% elif has_resource_permissions %} | |
| 33 | + <div class="panel panel-info topic-panel-invisible"> | |
| 34 | + <div class="panel-heading panel-invisible"> | |
| 35 | 35 | {% endif %} |
| 36 | 36 | <div class="row"> |
| 37 | 37 | <div class="col-md-12 category-header"> | ... | ... |
subjects/views.py
| ... | ... | @@ -28,7 +28,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger |
| 28 | 28 | from .forms import CreateSubjectForm, UpdateSubjectForm |
| 29 | 29 | from .utils import has_student_profile, has_professor_profile, count_subjects, get_category_page |
| 30 | 30 | from users.models import User |
| 31 | -from topics.models import Resource | |
| 31 | +from topics.models import Topic, Resource | |
| 32 | 32 | |
| 33 | 33 | from amadeus.permissions import has_category_permissions, has_subject_permissions, has_subject_view_permissions, has_resource_permissions |
| 34 | 34 | |
| ... | ... | @@ -366,6 +366,10 @@ class SubjectUpdateView(LoginRequiredMixin, LogMixin, UpdateView): |
| 366 | 366 | self.object.visible = False |
| 367 | 367 | self.object.save() |
| 368 | 368 | |
| 369 | + if not self.object.visible: | |
| 370 | + Topic.objects.filter(subject = self.object, repository = False).update(visible = False) | |
| 371 | + Resource.objects.filter(topic__subject = self.object, topic__repository = False).update(visible = False) | |
| 372 | + | |
| 369 | 373 | self.log_context['category_id'] = self.object.category.id |
| 370 | 374 | self.log_context['category_name'] = self.object.category.name |
| 371 | 375 | self.log_context['category_slug'] = self.object.category.slug | ... | ... |
topics/views.py
| ... | ... | @@ -61,6 +61,10 @@ class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
| 61 | 61 | |
| 62 | 62 | self.object.save() |
| 63 | 63 | |
| 64 | + if not self.object.subject.visible and not self.object.repository: | |
| 65 | + self.object.visible = False | |
| 66 | + self.object.save() | |
| 67 | + | |
| 64 | 68 | self.log_context['category_id'] = self.object.subject.category.id |
| 65 | 69 | self.log_context['category_name'] = self.object.subject.category.name |
| 66 | 70 | self.log_context['category_slug'] = self.object.subject.category.slug |
| ... | ... | @@ -137,6 +141,13 @@ class UpdateView(LoginRequiredMixin, LogMixin, generic.UpdateView): |
| 137 | 141 | return context |
| 138 | 142 | |
| 139 | 143 | def get_success_url(self): |
| 144 | + if not self.object.subject.visible: | |
| 145 | + self.object.visible = False | |
| 146 | + self.object.save() | |
| 147 | + | |
| 148 | + if not self.object.visible and not self.object.repository: | |
| 149 | + Resource.objects.filter(topic = self.object).update(visible = False) | |
| 150 | + | |
| 140 | 151 | messages.success(self.request, _('Topic "%s" was updated on virtual enviroment "%s" successfully!')%(self.object.name, self.object.subject.name)) |
| 141 | 152 | |
| 142 | 153 | self.log_context['category_id'] = self.object.subject.category.id | ... | ... |
webpage/templates/webpages/view.html
| ... | ... | @@ -25,12 +25,12 @@ |
| 25 | 25 | {% endfor %} |
| 26 | 26 | {% endif %} |
| 27 | 27 | |
| 28 | - {% subject_permissions request.user subject as has_subject_permissions %} | |
| 28 | + {% resource_permissions request.user webpage as has_resource_permissions %} | |
| 29 | 29 | |
| 30 | - {% if subject.visible %} | |
| 30 | + {% if webpage.visible %} | |
| 31 | 31 | <div class="panel panel-info topic-panel"> |
| 32 | 32 | <div class="panel-heading"> |
| 33 | - {% elif has_subject_permissions %} | |
| 33 | + {% elif has_resource_permissions %} | |
| 34 | 34 | <div class="panel panel-info topic-panel-invisible"> |
| 35 | 35 | <div class="panel-heading panel-invisible"> |
| 36 | 36 | {% endif %} | ... | ... |
youtube_video/templates/youtube/view.html
| ... | ... | @@ -25,15 +25,15 @@ |
| 25 | 25 | {% endfor %} |
| 26 | 26 | {% endif %} |
| 27 | 27 | |
| 28 | - {% subject_permissions request.user subject as has_subject_permissions %} | |
| 28 | + {% resource_permissions request.user youtube as has_resource_permissions %} | |
| 29 | 29 | |
| 30 | - {% if subject.visible %} | |
| 31 | - <div class="panel panel-info topic-panel" style="margin-bottom: 0px;"> | |
| 32 | - <div class="panel-heading"> | |
| 33 | - {% elif has_subject_permissions %} | |
| 34 | - <div class="panel panel-info topic-panel-invisible" style="margin-bottom: 0px;"> | |
| 35 | - <div class="panel-heading panel-invisible"> | |
| 36 | - {% endif %} | |
| 30 | + {% if youtube.visible %} | |
| 31 | + <div class="panel panel-info topic-panel"> | |
| 32 | + <div class="panel-heading"> | |
| 33 | + {% elif has_resource_permissions %} | |
| 34 | + <div class="panel panel-info topic-panel-invisible"> | |
| 35 | + <div class="panel-heading panel-invisible"> | |
| 36 | + {% endif %} | |
| 37 | 37 | <div class="row"> |
| 38 | 38 | <div class="col-md-12 category-header"> |
| 39 | 39 | <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | ... | ... |