Commit 5a71d4f9bd85aa7f6f941bad06c43efc541962c7

Authored by Zambom
1 parent e6636f13

Hiding pendencies buttons in non-student visualization

notifications/templates/notifications/_view.html
1 -{% load i18n notification_filters %} 1 +{% load i18n notification_filters permissions_tags %}
  2 +
  3 +{% subject_permissions request.user subject as has_subject_permissions %}
2 4
3 {% for notification in notifications %} 5 {% for notification in notifications %}
4 <div class="row"> 6 <div class="row">
@@ -44,52 +46,54 @@ @@ -44,52 +46,54 @@
44 </div> 46 </div>
45 </div> 47 </div>
46 </div> 48 </div>
47 - <div class="row text-center">  
48 - <a href="{{ notification.task.resource.access_link }}" class="btn btn-success btn-raised" {% if notification.task.resource.show_window %}target="_blank"{% endif %}>  
49 - {% if notification.level == 4 %}  
50 - {% trans 'Access the task' %}  
51 - {% else %}  
52 - {% trans 'Realize the task' %}  
53 - {% endif %}  
54 - </a>  
55 -  
56 - {% if notification.level < 3 %}  
57 - <button class="btn btn-default no_button">{% trans 'or' %}</button>  
58 - <button class="btn btn-default btn-raised" data-toggle="popover" data-placement="right">  
59 - {% if notification.level == 1 %}  
60 - {% trans 'Define goal to realization' %} 49 + {% if not has_subject_permissions %}
  50 + <div class="row text-center">
  51 + <a href="{{ notification.task.resource.access_link }}" class="btn btn-success btn-raised" {% if notification.task.resource.show_window %}target="_blank"{% endif %}>
  52 + {% if notification.level == 4 %}
  53 + {% trans 'Access the task' %}
61 {% else %} 54 {% else %}
62 - {% trans 'Define new goal' %} 55 + {% trans 'Realize the task' %}
63 {% endif %} 56 {% endif %}
64 - </button> 57 + </a>
65 58
66 - <div class="popover">  
67 - <div class="popover-content">  
68 - <form action="{% url 'notifications:set_goal' %}" role="form" method="post">  
69 - {% csrf_token %}  
70 - <div style="overflow:hidden;">  
71 - <div class="form-group">  
72 - <div class="row">  
73 - <div class="col-md-12">  
74 - <div class="datetimepicker"></div>  
75 - <input type="hidden" name="id" value="{{ notification.id }}">  
76 - </div>  
77 - </div>  
78 - </div>  
79 - </div>  
80 - </form>  
81 - </div>  
82 - <div class="popover-footer">  
83 - <button type="button" class="btn btn-raised btn-sm btn-success save pull-left">  
84 - {% trans 'Save Goal' %}  
85 - </button>  
86 - <button type="button" class="btn btn-default btn-sm btn-raised cancel pull-right">  
87 - {% trans 'Cancel' %}  
88 - </button>  
89 - </div>  
90 - </div>  
91 - {% endif %}  
92 - </div> 59 + {% if notification.level < 3 %}
  60 + <button class="btn btn-default no_button">{% trans 'or' %}</button>
  61 + <button class="btn btn-default btn-raised" data-toggle="popover" data-placement="right">
  62 + {% if notification.level == 1 %}
  63 + {% trans 'Define goal to realization' %}
  64 + {% else %}
  65 + {% trans 'Define new goal' %}
  66 + {% endif %}
  67 + </button>
  68 +
  69 + <div class="popover">
  70 + <div class="popover-content">
  71 + <form action="{% url 'notifications:set_goal' %}" role="form" method="post">
  72 + {% csrf_token %}
  73 + <div style="overflow:hidden;">
  74 + <div class="form-group">
  75 + <div class="row">
  76 + <div class="col-md-12">
  77 + <div class="datetimepicker"></div>
  78 + <input type="hidden" name="id" value="{{ notification.id }}">
  79 + </div>
  80 + </div>
  81 + </div>
  82 + </div>
  83 + </form>
  84 + </div>
  85 + <div class="popover-footer">
  86 + <button type="button" class="btn btn-raised btn-sm btn-success save pull-left">
  87 + {% trans 'Save Goal' %}
  88 + </button>
  89 + <button type="button" class="btn btn-default btn-sm btn-raised cancel pull-right">
  90 + {% trans 'Cancel' %}
  91 + </button>
  92 + </div>
  93 + </div>
  94 + {% endif %}
  95 + </div>
  96 + {% endif %}
93 </div> 97 </div>
94 </div> 98 </div>
95 </div> 99 </div>
notifications/views.py
@@ -311,6 +311,17 @@ class AjaxNotifications(LoginRequiredMixin, generic.ListView): @@ -311,6 +311,17 @@ class AjaxNotifications(LoginRequiredMixin, generic.ListView):
311 311
312 return notifications 312 return notifications
313 313
  314 + def get_context_data(self, **kwargs):
  315 + context = super(AjaxNotifications, self).get_context_data(**kwargs)
  316 +
  317 + subject_id = self.kwargs.get('id', '')
  318 + subject = Subject.objects.get(id = subject_id)
  319 +
  320 + context['subject_id'] = subject_id
  321 + context['subject'] = subject
  322 +
  323 + return context
  324 +
314 class AjaxHistory(LoginRequiredMixin, generic.ListView): 325 class AjaxHistory(LoginRequiredMixin, generic.ListView):
315 login_url = reverse_lazy("users:login") 326 login_url = reverse_lazy("users:login")
316 redirect_field_name = 'next' 327 redirect_field_name = 'next'
@@ -351,8 +362,10 @@ class AjaxHistory(LoginRequiredMixin, generic.ListView): @@ -351,8 +362,10 @@ class AjaxHistory(LoginRequiredMixin, generic.ListView):
351 context = super(AjaxHistory, self).get_context_data(**kwargs) 362 context = super(AjaxHistory, self).get_context_data(**kwargs)
352 363
353 subject_id = self.kwargs.get('id', '') 364 subject_id = self.kwargs.get('id', '')
  365 + subject = Subject.objects.get(id = subject_id)
354 366
355 context['subject_id'] = subject_id 367 context['subject_id'] = subject_id
  368 + context['subject'] = subject
356 context['rows'] = self.num_rows 369 context['rows'] = self.num_rows
357 context['searched'] = self.request.GET.get("search", "") 370 context['searched'] = self.request.GET.get("search", "")
358 context['order_by'] = self.request.GET.get("order_by", "") 371 context['order_by'] = self.request.GET.get("order_by", "")