Commit a71ff4336da4ca9390afdce31dd2b3a2117b9ed2
1 parent
341d2d2b
Exists in
master
and in
3 other branches
added webconference variables to report view as well as added distinct days vari…
…ables to all kind of resources
Showing
2 changed files
with
22 additions
and
5 deletions
Show diff stats
links/views.py
@@ -21,7 +21,7 @@ from topics.models import Topic | @@ -21,7 +21,7 @@ from topics.models import Topic | ||
21 | class CreateLinkView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): | 21 | class CreateLinkView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
22 | log_component = 'resources' | 22 | log_component = 'resources' |
23 | log_action = 'create' | 23 | log_action = 'create' |
24 | - log_resource = 'links' | 24 | + log_resource = 'link' |
25 | log_context = {} | 25 | log_context = {} |
26 | 26 | ||
27 | login_url = reverse_lazy("users:login") | 27 | login_url = reverse_lazy("users:login") |
@@ -185,7 +185,7 @@ class DeleteLinkView(LoginRequiredMixin, LogMixin, generic.edit.DeleteView): | @@ -185,7 +185,7 @@ class DeleteLinkView(LoginRequiredMixin, LogMixin, generic.edit.DeleteView): | ||
185 | class DetailLinkView(LoginRequiredMixin, LogMixin, generic.detail.DetailView): | 185 | class DetailLinkView(LoginRequiredMixin, LogMixin, generic.detail.DetailView): |
186 | log_component = 'resources' | 186 | log_component = 'resources' |
187 | log_action = 'view' | 187 | log_action = 'view' |
188 | - log_resource = 'links' | 188 | + log_resource = 'link' |
189 | log_context = {} | 189 | log_context = {} |
190 | login_url = reverse_lazy("users:login") | 190 | login_url = reverse_lazy("users:login") |
191 | redirect_field_name = 'next' | 191 | redirect_field_name = 'next' |
reports/views.py
@@ -58,7 +58,6 @@ class ReportView(LoginRequiredMixin, generic.FormView): | @@ -58,7 +58,6 @@ class ReportView(LoginRequiredMixin, generic.FormView): | ||
58 | 58 | ||
59 | classes = Resource.__subclasses__() | 59 | classes = Resource.__subclasses__() |
60 | 60 | ||
61 | - | ||
62 | #set formset | 61 | #set formset |
63 | resourceTagFormSet = formset_factory(ResourceAndTagForm, formset=BaseResourceAndTagFormset) | 62 | resourceTagFormSet = formset_factory(ResourceAndTagForm, formset=BaseResourceAndTagFormset) |
64 | resourceTagFormSet = resourceTagFormSet() | 63 | resourceTagFormSet = resourceTagFormSet() |
@@ -319,26 +318,44 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): | @@ -319,26 +318,44 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): | ||
319 | distinct_resources = 0 | 318 | distinct_resources = 0 |
320 | total_count = 0 | 319 | total_count = 0 |
321 | 320 | ||
321 | + day_numbers = [0, 1, 2, 3, 4, 5, 6] | ||
322 | + distinct_days = 0 | ||
322 | for resource in resources: | 323 | for resource in resources: |
324 | + | ||
323 | if isinstance(topics,Topic): | 325 | if isinstance(topics,Topic): |
324 | #or it selected only one topic to work with | 326 | #or it selected only one topic to work with |
325 | count = Log.objects.filter(action="view", resource=resources_types[i].lower(), | 327 | count = Log.objects.filter(action="view", resource=resources_types[i].lower(), |
326 | user_id = student.id, context__contains = {'subject_id': subject.id, | 328 | user_id = student.id, context__contains = {'subject_id': subject.id, |
327 | resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__range=(init_date, end_date)).count() | 329 | resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__range=(init_date, end_date)).count() |
328 | - | 330 | + |
331 | + for daynum in day_numbers: | ||
332 | + count_temp = Log.objects.filter(action="view", resource=resources_types[i].lower(), | ||
333 | + user_id = student.id, context__contains = {'subject_id': subject.id, | ||
334 | + resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__week_day = day_num+1, datetime__range=(init_date, end_date)).count() | ||
335 | + if count_temp > 0: | ||
336 | + distinct_days += 1 | ||
329 | else: | 337 | else: |
330 | #or the user selected all | 338 | #or the user selected all |
331 | 339 | ||
332 | - count = Log.objects.filter(action="view", resource=resources_types[i].lower(), | 340 | + count = Log.objects.filter(action="view", resource=resources_types[i].lower(), |
333 | user_id = student.id, context__contains = {'subject_id': subject.id, | 341 | user_id = student.id, context__contains = {'subject_id': subject.id, |
334 | resources_types[i].lower()+'_id': resource.id}, datetime__range=(init_date, end_date)).count() | 342 | resources_types[i].lower()+'_id': resource.id}, datetime__range=(init_date, end_date)).count() |
335 | 343 | ||
344 | + for daynum in day_numbers: | ||
345 | + count_temp = Log.objects.filter(action="view", resource=resources_types[i].lower(), | ||
346 | + user_id = student.id, context__contains = {'subject_id': subject.id, | ||
347 | + resources_types[i].lower()+'_id': resource.id}, datetime__week_day = daynum+1, | ||
348 | + datetime__range=(init_date, end_date)).count() | ||
349 | + if count_temp > 0: | ||
350 | + distinct_days += 1 | ||
336 | if count > 0: | 351 | if count > 0: |
337 | distinct_resources += 1 | 352 | distinct_resources += 1 |
338 | total_count += count | 353 | total_count += count |
339 | 354 | ||
340 | data[str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = total_count | 355 | data[str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = total_count |
341 | data["distintic " + str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = distinct_resources | 356 | data["distintic " + str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = distinct_resources |
357 | + data["distintic days " + str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = distinct_days | ||
358 | + | ||
342 | """data["distinct" + str(resources[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = Log.objects.filter(action="view", resource=resources[i].lower(), | 359 | """data["distinct" + str(resources[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = Log.objects.filter(action="view", resource=resources[i].lower(), |
343 | user_id = student.id, context__contains = {'subject_id': subject.id}).distinct().count()""" | 360 | user_id = student.id, context__contains = {'subject_id': subject.id}).distinct().count()""" |
344 | 361 |