Commit e6636f13c0adc604f0cdce3a6fe661ca915fa872
1 parent
fbd91084
Exists in
master
and in
2 other branches
Adding non-student view in pendencies (subject template)
Showing
6 changed files
with
146 additions
and
21 deletions
Show diff stats
goals/templates/goals/view.html
@@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
33 | {% endif %} | 33 | {% endif %} |
34 | 34 | ||
35 | {% resource_permissions request.user goal as has_resource_permissions %} | 35 | {% resource_permissions request.user goal as has_resource_permissions %} |
36 | - {% subject_permissions request.user goal as has_subject_permissions %} | 36 | + {% subject_permissions request.user goal.topic.subject as has_subject_permissions %} |
37 | 37 | ||
38 | {% if goal.visible %} | 38 | {% if goal.visible %} |
39 | <div class="panel panel-info topic-panel"> | 39 | <div class="panel panel-info topic-panel"> |
goals/views.py
@@ -215,7 +215,7 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -215,7 +215,7 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.ListView): | ||
215 | slug = self.kwargs.get('slug', '') | 215 | slug = self.kwargs.get('slug', '') |
216 | goal = get_object_or_404(Goals, slug = slug) | 216 | goal = get_object_or_404(Goals, slug = slug) |
217 | 217 | ||
218 | - if has_subject_permissions(self.request.user, goal): | 218 | + if has_subject_permissions(self.request.user, goal.topic.subject): |
219 | self.students = User.objects.filter(subject_student = goal.topic.subject).order_by('social_name', 'username') | 219 | self.students = User.objects.filter(subject_student = goal.topic.subject).order_by('social_name', 'username') |
220 | 220 | ||
221 | goals = MyGoals.objects.filter(user = self.students.first(), item__goal = goal) | 221 | goals = MyGoals.objects.filter(user = self.students.first(), item__goal = goal) |
@@ -230,7 +230,7 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -230,7 +230,7 @@ class InsideView(LoginRequiredMixin, LogMixin, generic.ListView): | ||
230 | 230 | ||
231 | user = request.POST.get('selected_student', None) | 231 | user = request.POST.get('selected_student', None) |
232 | 232 | ||
233 | - if has_subject_permissions(request.user, goal): | 233 | + if has_subject_permissions(request.user, goal.topic.subject): |
234 | self.students = User.objects.filter(subject_student = goal.topic.subject).order_by('social_name', 'username') | 234 | self.students = User.objects.filter(subject_student = goal.topic.subject).order_by('social_name', 'username') |
235 | 235 | ||
236 | if not user is None: | 236 | if not user is None: |
notifications/templates/notifications/_history.html
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | </div> | 7 | </div> |
8 | <div class="col-md-4"> | 8 | <div class="col-md-4"> |
9 | <form action="" method="GET" class="form-horizontal"> | 9 | <form action="" method="GET" class="form-horizontal"> |
10 | + <input type="hidden" value="{{ student }}" name="selected_student" /> | ||
10 | <div class="form-group"> | 11 | <div class="form-group"> |
11 | <label class="col-md-4 history-control-label control-label">{% trans 'Search' %}:</label> | 12 | <label class="col-md-4 history-control-label control-label">{% trans 'Search' %}:</label> |
12 | <div class="col-md-8"> | 13 | <div class="col-md-8"> |
@@ -18,37 +19,37 @@ | @@ -18,37 +19,37 @@ | ||
18 | <table class="table table-striped table-bordered"> | 19 | <table class="table table-striped table-bordered"> |
19 | <thead> | 20 | <thead> |
20 | <th> | 21 | <th> |
21 | - <a href="{{ request|order_href:'creation_date' }}"> | 22 | + <a href="{{ request|add_student:student|order_href:'creation_date' }}"> |
22 | {% trans 'Date' %} <i class="fa fa-fw {{ request|order_icon_class:'creation_date' }} pull-right"></i> | 23 | {% trans 'Date' %} <i class="fa fa-fw {{ request|order_icon_class:'creation_date' }} pull-right"></i> |
23 | </a> | 24 | </a> |
24 | </th> | 25 | </th> |
25 | <th> | 26 | <th> |
26 | - <a href="{{ request|order_href:'resource' }}"> | 27 | + <a href="{{ request|add_student:student|order_href:'resource' }}"> |
27 | {% trans 'Resource' %} <i class="fa fa-fw {{ request|order_icon_class:'resource' }} pull-right"></i> | 28 | {% trans 'Resource' %} <i class="fa fa-fw {{ request|order_icon_class:'resource' }} pull-right"></i> |
28 | </a> | 29 | </a> |
29 | </th> | 30 | </th> |
30 | <th> | 31 | <th> |
31 | - <a href="{{ request|order_href:'task' }}"> | 32 | + <a href="{{ request|add_student:student|order_href:'task' }}"> |
32 | {% trans 'Task' %} <i class="fa fa-fw {{ request|order_icon_class:'task' }} pull-right"></i> | 33 | {% trans 'Task' %} <i class="fa fa-fw {{ request|order_icon_class:'task' }} pull-right"></i> |
33 | </a> | 34 | </a> |
34 | </th> | 35 | </th> |
35 | <th> | 36 | <th> |
36 | - <a href="{{ request|order_href:'final_date' }}"> | 37 | + <a href="{{ request|add_student:student|order_href:'final_date' }}"> |
37 | {% trans 'Final Date' %} <i class="fa fa-fw {{ request|order_icon_class:'final_date' }} pull-right"></i> | 38 | {% trans 'Final Date' %} <i class="fa fa-fw {{ request|order_icon_class:'final_date' }} pull-right"></i> |
38 | </a> | 39 | </a> |
39 | </th> | 40 | </th> |
40 | <th> | 41 | <th> |
41 | - <a href="{{ request|order_href:'notification' }}"> | 42 | + <a href="{{ request|add_student:student|order_href:'notification' }}"> |
42 | {% trans 'Notification' %} <i class="fa fa-fw {{ request|order_icon_class:'notification' }} pull-right"></i> | 43 | {% trans 'Notification' %} <i class="fa fa-fw {{ request|order_icon_class:'notification' }} pull-right"></i> |
43 | </a> | 44 | </a> |
44 | </th> | 45 | </th> |
45 | <th> | 46 | <th> |
46 | - <a href="{{ request|order_href:'aware' }}"> | 47 | + <a href="{{ request|add_student:student|order_href:'aware' }}"> |
47 | {% trans 'Aware' %} <i class="fa fa-fw {{ request|order_icon_class:'aware' }} pull-right"></i> | 48 | {% trans 'Aware' %} <i class="fa fa-fw {{ request|order_icon_class:'aware' }} pull-right"></i> |
48 | </a> | 49 | </a> |
49 | </th> | 50 | </th> |
50 | <th> | 51 | <th> |
51 | - <a href="{{ request|order_href:'obs' }}"> | 52 | + <a href="{{ request|add_student:student|order_href:'obs' }}"> |
52 | {% trans 'Observation' %} <i class="fa fa-fw {{ request|order_icon_class:'obs' }} pull-right"></i> | 53 | {% trans 'Observation' %} <i class="fa fa-fw {{ request|order_icon_class:'obs' }} pull-right"></i> |
53 | </a> | 54 | </a> |
54 | </th> | 55 | </th> |
notifications/templates/notifications/subject.html
@@ -10,6 +10,8 @@ | @@ -10,6 +10,8 @@ | ||
10 | {% endblock %} | 10 | {% endblock %} |
11 | 11 | ||
12 | {% block content %} | 12 | {% block content %} |
13 | + {% subject_permissions request.user subject as has_subject_permissions %} | ||
14 | + | ||
13 | {% if subject.visible %} | 15 | {% if subject.visible %} |
14 | <div class="panel panel-info subject-panel"> | 16 | <div class="panel panel-info subject-panel"> |
15 | <div class="panel-heading"> | 17 | <div class="panel-heading"> |
@@ -26,11 +28,36 @@ | @@ -26,11 +28,36 @@ | ||
26 | </div> | 28 | </div> |
27 | </div> | 29 | </div> |
28 | <div id="{{subject.slug}}" class="panel-collapse in collapse pendencies-content subject-related-panel"> | 30 | <div id="{{subject.slug}}" class="panel-collapse in collapse pendencies-content subject-related-panel"> |
31 | + {% if has_subject_permissions %} | ||
32 | + <form id="student_goals" action="" method="POST"> | ||
33 | + {% csrf_token %} | ||
34 | + <select name="selected_student" onchange="$('#student_goals').submit();"> | ||
35 | + {% for stu in sub_students %} | ||
36 | + <option value="{{ stu.email }}" {% if stu.email == student %}selected{% endif %}>{{ stu }}</option> | ||
37 | + {% endfor %} | ||
38 | + </select> | ||
39 | + </form> | ||
40 | + <br clear="all" /> | ||
41 | + {% endif %} | ||
42 | + | ||
29 | <h5>{% trans 'This pendencies list is updated every 24 hours. Last update was in:' %} {{ last_update|default:_('Not determined') }}</h5> | 43 | <h5>{% trans 'This pendencies list is updated every 24 hours. Last update was in:' %} {{ last_update|default:_('Not determined') }}</h5> |
30 | <div id="core-subjects-options-div"> | 44 | <div id="core-subjects-options-div"> |
31 | <ul class="core-subjects-options"> | 45 | <ul class="core-subjects-options"> |
32 | - <a href="{% url 'notifications:view' subject.slug %}"><li {% if not history %} class="active" {% endif %}>{% trans "Actual Pendencies" %} ({{ total }})</li></a> | ||
33 | - <a href="{% url 'notifications:history' subject.slug %}"><li {% if history %} class="active" {% endif %}>{% trans "Notifications History" %}</li></a> | 46 | + {% if has_subject_permissions %} |
47 | + <form id="student_pend" action="{% url 'notifications:view' subject.slug %}" method="POST"> | ||
48 | + {% csrf_token %} | ||
49 | + <input type="hidden" value="{{ student }}" name="selected_student" /> | ||
50 | + <a onclick="$('#student_pend').submit();" style="cursor:pointer"><li {% if not history %} class="active" {% endif %}>{% trans "Actual Pendencies" %} ({{ total }})</li></a> | ||
51 | + </form> | ||
52 | + <form id="student_history" action="{% url 'notifications:history' subject.slug %}" method="POST"> | ||
53 | + {% csrf_token %} | ||
54 | + <input type="hidden" value="{{ student }}" name="selected_student" /> | ||
55 | + <a onclick="$('#student_history').submit();" style="cursor:pointer"><li {% if history %} class="active" {% endif %}>{% trans "Notifications History" %}</li></a> | ||
56 | + </form> | ||
57 | + {% else %} | ||
58 | + <a href="{% url 'notifications:view' subject.slug %}"><li {% if not history %} class="active" {% endif %}>{% trans "Actual Pendencies" %} ({{ total }})</li></a> | ||
59 | + <a href="{% url 'notifications:history' subject.slug %}"><li {% if history %} class="active" {% endif %}>{% trans "Notifications History" %}</li></a> | ||
60 | + {% endif %} | ||
34 | </ul> | 61 | </ul> |
35 | </div> | 62 | </div> |
36 | 63 | ||
@@ -58,4 +85,10 @@ | @@ -58,4 +85,10 @@ | ||
58 | metaFunctions(); | 85 | metaFunctions(); |
59 | }); | 86 | }); |
60 | </script> | 87 | </script> |
88 | +{% endblock %} | ||
89 | + | ||
90 | +{% block addtional_scripts %} | ||
91 | + <script type="text/javascript"> | ||
92 | + sessionSecurity.confirmFormDiscard = undefined; | ||
93 | + </script> | ||
61 | {% endblock %} | 94 | {% endblock %} |
62 | \ No newline at end of file | 95 | \ No newline at end of file |
notifications/templatetags/notification_filters.py
@@ -85,7 +85,7 @@ def order_href(request, column): | @@ -85,7 +85,7 @@ def order_href(request, column): | ||
85 | if 'order_by' in getvars: | 85 | if 'order_by' in getvars: |
86 | order = getvars['order_by'] | 86 | order = getvars['order_by'] |
87 | del getvars['order_by'] | 87 | del getvars['order_by'] |
88 | - | 88 | + |
89 | if not order: | 89 | if not order: |
90 | if column == "creation_date": | 90 | if column == "creation_date": |
91 | order_href = "creation_date" | 91 | order_href = "creation_date" |
@@ -93,12 +93,28 @@ def order_href(request, column): | @@ -93,12 +93,28 @@ def order_href(request, column): | ||
93 | if column in order: | 93 | if column in order: |
94 | if "-" in order: | 94 | if "-" in order: |
95 | order_href = column | 95 | order_href = column |
96 | - | 96 | + |
97 | if len(getvars) > 0: | 97 | if len(getvars) > 0: |
98 | params = '&%s' % getvars.urlencode() | 98 | params = '&%s' % getvars.urlencode() |
99 | 99 | ||
100 | return "?order_by=" + order_href + params | 100 | return "?order_by=" + order_href + params |
101 | 101 | ||
102 | +@register.filter(name = 'add_student') | ||
103 | +def add_student(request, student): | ||
104 | + getvars = request.GET.copy() | ||
105 | + params = "" | ||
106 | + | ||
107 | + if not student is None: | ||
108 | + if not student == "": | ||
109 | + if 'selected_student' in getvars: | ||
110 | + del getvars['selected_student'] | ||
111 | + | ||
112 | + getvars['selected_student'] = student | ||
113 | + | ||
114 | + request.GET = getvars | ||
115 | + | ||
116 | + return request | ||
117 | + | ||
102 | @register.filter(name = 'order_ajax') | 118 | @register.filter(name = 'order_ajax') |
103 | def order_ajax(request, column): | 119 | def order_ajax(request, column): |
104 | getvars = request.GET.copy() | 120 | getvars = request.GET.copy() |
@@ -109,7 +125,7 @@ def order_ajax(request, column): | @@ -109,7 +125,7 @@ def order_ajax(request, column): | ||
109 | if 'order_by' in getvars: | 125 | if 'order_by' in getvars: |
110 | order = getvars['order_by'] | 126 | order = getvars['order_by'] |
111 | del getvars['order_by'] | 127 | del getvars['order_by'] |
112 | - | 128 | + |
113 | if not order: | 129 | if not order: |
114 | if column == "creation_date": | 130 | if column == "creation_date": |
115 | order_href = "creation_date" | 131 | order_href = "creation_date" |
@@ -117,7 +133,7 @@ def order_ajax(request, column): | @@ -117,7 +133,7 @@ def order_ajax(request, column): | ||
117 | if column in order: | 133 | if column in order: |
118 | if "-" in order: | 134 | if "-" in order: |
119 | order_href = column | 135 | order_href = column |
120 | - | 136 | + |
121 | return order_href | 137 | return order_href |
122 | 138 | ||
123 | @register.filter(name = 'observation') | 139 | @register.filter(name = 'observation') |
notifications/views.py
@@ -12,10 +12,11 @@ from dateutil import parser | @@ -12,10 +12,11 @@ from dateutil import parser | ||
12 | from datetime import datetime | 12 | from datetime import datetime |
13 | from django.utils import formats, timezone | 13 | from django.utils import formats, timezone |
14 | 14 | ||
15 | -from amadeus.permissions import has_subject_view_permissions, has_category_permission | 15 | +from amadeus.permissions import has_subject_view_permissions, has_category_permission, has_subject_permissions |
16 | 16 | ||
17 | from subjects.models import Subject | 17 | from subjects.models import Subject |
18 | from categories.models import Category | 18 | from categories.models import Category |
19 | +from users.models import User | ||
19 | 20 | ||
20 | from log.models import Log | 21 | from log.models import Log |
21 | from log.mixins import LogMixin | 22 | from log.mixins import LogMixin |
@@ -39,6 +40,8 @@ class SubjectNotifications(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -39,6 +40,8 @@ class SubjectNotifications(LoginRequiredMixin, LogMixin, generic.ListView): | ||
39 | paginate_by = 10 | 40 | paginate_by = 10 |
40 | total = 0 | 41 | total = 0 |
41 | 42 | ||
43 | + students = None | ||
44 | + | ||
42 | def dispatch(self, request, *args, **kwargs): | 45 | def dispatch(self, request, *args, **kwargs): |
43 | slug = self.kwargs.get('slug', '') | 46 | slug = self.kwargs.get('slug', '') |
44 | subject = get_object_or_404(Subject, slug = slug) | 47 | subject = get_object_or_404(Subject, slug = slug) |
@@ -52,14 +55,38 @@ class SubjectNotifications(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -52,14 +55,38 @@ class SubjectNotifications(LoginRequiredMixin, LogMixin, generic.ListView): | ||
52 | slug = self.kwargs.get('slug', '') | 55 | slug = self.kwargs.get('slug', '') |
53 | subject = get_object_or_404(Subject, slug = slug) | 56 | subject = get_object_or_404(Subject, slug = slug) |
54 | 57 | ||
55 | - notifications = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject, creation_date = datetime.now()).order_by("task__limit_date", "task__end_date") | ||
56 | - | ||
57 | - notifications.update(viewed = True) | 58 | + if has_subject_permissions(self.request.user, subject): |
59 | + self.students = User.objects.filter(subject_student = subject).order_by('social_name', 'username') | ||
58 | 60 | ||
61 | + notifications = Notification.objects.filter(user = self.students.first(), task__resource__topic__subject = subject, creation_date = datetime.now()).order_by("task__limit_date", "task__end_date") | ||
62 | + else: | ||
63 | + notifications = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject, creation_date = datetime.now()).order_by("task__limit_date", "task__end_date") | ||
64 | + notifications.update(viewed = True) | ||
65 | + | ||
59 | self.total = notifications.count() | 66 | self.total = notifications.count() |
60 | 67 | ||
61 | return notifications | 68 | return notifications |
62 | 69 | ||
70 | + def post(self, request, *args, **kwargs): | ||
71 | + slug = self.kwargs.get('slug', '') | ||
72 | + subject = get_object_or_404(Subject, slug = slug) | ||
73 | + | ||
74 | + user = request.POST.get('selected_student', None) | ||
75 | + | ||
76 | + if has_subject_permissions(request.user, subject): | ||
77 | + self.students = User.objects.filter(subject_student = subject).order_by('social_name', 'username') | ||
78 | + | ||
79 | + if not user is None: | ||
80 | + self.object_list = Notification.objects.filter(user__email = user, task__resource__topic__subject = subject, creation_date = datetime.now()).order_by("task__limit_date", "task__end_date") | ||
81 | + else: | ||
82 | + self.object_list = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject, creation_date = datetime.now()).order_by("task__limit_date", "task__end_date") | ||
83 | + else: | ||
84 | + self.object_list = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject, creation_date = datetime.now()).order_by("task__limit_date", "task__end_date") | ||
85 | + | ||
86 | + self.total = self.object_list.count() | ||
87 | + | ||
88 | + return self.render_to_response(self.get_context_data()) | ||
89 | + | ||
63 | def get_context_data(self, **kwargs): | 90 | def get_context_data(self, **kwargs): |
64 | context = super(SubjectNotifications, self).get_context_data(**kwargs) | 91 | context = super(SubjectNotifications, self).get_context_data(**kwargs) |
65 | 92 | ||
@@ -70,6 +97,12 @@ class SubjectNotifications(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -70,6 +97,12 @@ class SubjectNotifications(LoginRequiredMixin, LogMixin, generic.ListView): | ||
70 | context['subject'] = subject | 97 | context['subject'] = subject |
71 | context['total'] = self.total | 98 | context['total'] = self.total |
72 | 99 | ||
100 | + if not self.students is None: | ||
101 | + context['sub_students'] = self.students | ||
102 | + context['student'] = self.request.POST.get('selected_student', self.students.first().email) | ||
103 | + else: | ||
104 | + context['student'] = None | ||
105 | + | ||
73 | update_pendencies = Log.objects.filter(action = "cron", component = "notifications").order_by('-datetime') | 106 | update_pendencies = Log.objects.filter(action = "cron", component = "notifications").order_by('-datetime') |
74 | 107 | ||
75 | if update_pendencies.count() > 0: | 108 | if update_pendencies.count() > 0: |
@@ -104,6 +137,8 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -104,6 +137,8 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | ||
104 | total = 0 | 137 | total = 0 |
105 | num_rows = 0 | 138 | num_rows = 0 |
106 | 139 | ||
140 | + students = None | ||
141 | + | ||
107 | def dispatch(self, request, *args, **kwargs): | 142 | def dispatch(self, request, *args, **kwargs): |
108 | slug = self.kwargs.get('slug', '') | 143 | slug = self.kwargs.get('slug', '') |
109 | subject = get_object_or_404(Subject, slug = slug) | 144 | subject = get_object_or_404(Subject, slug = slug) |
@@ -120,7 +155,17 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -120,7 +155,17 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | ||
120 | order = get_order_by(self.request.GET.get("order_by", None)) | 155 | order = get_order_by(self.request.GET.get("order_by", None)) |
121 | search = self.request.GET.get("search", None) | 156 | search = self.request.GET.get("search", None) |
122 | 157 | ||
123 | - notifications = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject).order_by(*order) | 158 | + if has_subject_permissions(self.request.user, subject): |
159 | + user = self.request.GET.get("selected_student", None) | ||
160 | + | ||
161 | + self.students = User.objects.filter(subject_student = subject).order_by('social_name', 'username') | ||
162 | + | ||
163 | + if not user is None: | ||
164 | + notifications = Notification.objects.filter(user__email = user, task__resource__topic__subject = subject).order_by(*order) | ||
165 | + else: | ||
166 | + notifications = Notification.objects.filter(user = self.students.first(), task__resource__topic__subject = subject).order_by(*order) | ||
167 | + else: | ||
168 | + notifications = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject).order_by(*order) | ||
124 | 169 | ||
125 | self.total = notifications.filter(creation_date = datetime.now()).count() | 170 | self.total = notifications.filter(creation_date = datetime.now()).count() |
126 | 171 | ||
@@ -145,6 +190,30 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -145,6 +190,30 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | ||
145 | 190 | ||
146 | return notifications | 191 | return notifications |
147 | 192 | ||
193 | + def post(self, request, *args, **kwargs): | ||
194 | + slug = self.kwargs.get('slug', '') | ||
195 | + subject = get_object_or_404(Subject, slug = slug) | ||
196 | + | ||
197 | + order = get_order_by(self.request.POST.get("order_by", None)) | ||
198 | + | ||
199 | + user = request.POST.get('selected_student', None) | ||
200 | + | ||
201 | + if has_subject_permissions(request.user, subject): | ||
202 | + self.students = User.objects.filter(subject_student = subject).order_by('social_name', 'username') | ||
203 | + | ||
204 | + if not user is None: | ||
205 | + self.object_list = Notification.objects.filter(user__email = user, task__resource__topic__subject = subject).order_by(*order) | ||
206 | + else: | ||
207 | + self.object_list = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject).order_by(*order) | ||
208 | + else: | ||
209 | + self.object_list = Notification.objects.filter(user = self.request.user, task__resource__topic__subject = subject).order_by(*order) | ||
210 | + | ||
211 | + self.total = self.object_list.filter(creation_date = datetime.now()).count() | ||
212 | + | ||
213 | + self.num_rows = self.object_list.count() | ||
214 | + | ||
215 | + return self.render_to_response(self.get_context_data()) | ||
216 | + | ||
148 | def get_context_data(self, **kwargs): | 217 | def get_context_data(self, **kwargs): |
149 | context = super(SubjectHistory, self).get_context_data(**kwargs) | 218 | context = super(SubjectHistory, self).get_context_data(**kwargs) |
150 | 219 | ||
@@ -158,6 +227,12 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -158,6 +227,12 @@ class SubjectHistory(LoginRequiredMixin, LogMixin, generic.ListView): | ||
158 | context['rows'] = self.num_rows | 227 | context['rows'] = self.num_rows |
159 | context['searched'] = self.request.GET.get("search", "") | 228 | context['searched'] = self.request.GET.get("search", "") |
160 | 229 | ||
230 | + if not self.students is None: | ||
231 | + context['sub_students'] = self.students | ||
232 | + context['student'] = self.request.POST.get('selected_student', self.request.GET.get('selected_student', self.students.first().email)) | ||
233 | + else: | ||
234 | + context['student'] = None | ||
235 | + | ||
161 | self.log_context['subject_id'] = subject.id | 236 | self.log_context['subject_id'] = subject.id |
162 | self.log_context['subject_name'] = subject.name | 237 | self.log_context['subject_name'] = subject.name |
163 | self.log_context['subject_slug'] = subject.slug | 238 | self.log_context['subject_slug'] = subject.slug |