Commit 7245b5d4310000ce33cea87ead83aa2f685b3fdd
1 parent
3c4cba7d
Exists in
master
and in
2 other branches
Modified webconference view updated to include other log actions
Showing
1 changed file
with
33 additions
and
9 deletions
Show diff stats
webconference/views.py
... | ... | @@ -10,6 +10,7 @@ from webpage.forms import FormModalMessage |
10 | 10 | from chat.models import Conversation, TalkMessages, ChatVisualizations |
11 | 11 | import textwrap |
12 | 12 | import json |
13 | +from django.db.models import Q | |
13 | 14 | from channels import Group |
14 | 15 | import datetime |
15 | 16 | from users.models import User |
... | ... | @@ -545,6 +546,7 @@ class ConferenceSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffus |
545 | 546 | context['title'] = _('Web Conference Settings') |
546 | 547 | |
547 | 548 | return context |
549 | + | |
548 | 550 | class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
549 | 551 | log_component = 'resources' |
550 | 552 | log_action = 'view_statistics' |
... | ... | @@ -561,7 +563,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
561 | 563 | webconference = get_object_or_404(Webconference, slug = slug) |
562 | 564 | |
563 | 565 | if not has_subject_permissions(request.user, webconference.topic.subject): |
564 | - return redirect(reverse_lazy('subjects:home')) | |
566 | + return redirect(reverse_lazy('subjects:home')) | |
565 | 567 | |
566 | 568 | return super(StatisticsView, self).dispatch(request, *args, **kwargs) |
567 | 569 | |
... | ... | @@ -584,7 +586,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
584 | 586 | super(StatisticsView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
585 | 587 | |
586 | 588 | |
587 | - context['title'] = _('Webconference Reports') | |
589 | + context['title'] = _('Youtube Video Reports') | |
588 | 590 | |
589 | 591 | slug = self.kwargs.get('slug') |
590 | 592 | webconference = get_object_or_404(Webconference, slug = slug) |
... | ... | @@ -602,7 +604,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
602 | 604 | if webconference.all_students : |
603 | 605 | alunos = webconference.topic.subject.students.all() |
604 | 606 | |
605 | - vis_ou = Log.objects.filter(context__contains={'webconference_id':webconference.id},resource="webconference",action="view",user_email__in=(aluno.email for aluno in alunos), datetime__range=(start_date,end_date + datetime.timedelta(minutes = 1))) | |
607 | + vis_ou = Log.objects.filter(context__contains={'webconference_id':webconference.id},resource="webconference",user_email__in=(aluno.email for aluno in alunos), datetime__range=(start_date,end_date + datetime.timedelta(minutes = 1))).filter(Q(action="view") | Q(action="initwebconference") | Q(action="participating")) | |
606 | 608 | did,n_did,history = str(_("Realized")),str(_("Unrealized")),str(_("Historic")) |
607 | 609 | re = [] |
608 | 610 | data_n_did,data_history = [],[] |
... | ... | @@ -615,26 +617,48 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
615 | 617 | |
616 | 618 | json_history["data"] = data_history |
617 | 619 | |
618 | - not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.distinct("user_email")]) | |
620 | + column_view,column_initwebconference,column_participate = str(_('View')),str(_('Enter')),str(_('Participate')) | |
621 | + | |
622 | + not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="view").distinct("user_email")]) | |
619 | 623 | index = 0 |
620 | 624 | for alun in not_view: |
621 | - data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),str(_('View')), str(alun.email)]) | |
625 | + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_view, str(alun.email)]) | |
626 | + index += 1 | |
627 | + | |
628 | + not_initwebconference = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="initwebconference").distinct("user_email")]) | |
629 | + for alun in not_initwebconference: | |
630 | + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_initwebconference, str(alun.email)]) | |
631 | + index += 1 | |
632 | + | |
633 | + not_participate = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="participating").distinct("user_email")]) | |
634 | + for alun in not_participate: | |
635 | + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_participate, str(alun.email)]) | |
622 | 636 | index += 1 |
637 | + | |
623 | 638 | json_n_did["data"] = data_n_did |
624 | 639 | |
625 | 640 | |
626 | 641 | context["json_n_did"] = json_n_did |
627 | 642 | context["json_history"] = json_history |
628 | - c_visualizou = vis_ou.distinct("user_email").count() | |
629 | - column_view = str(_('View')) | |
630 | - re.append([str(_('File link')),did,n_did]) | |
643 | + c_visualizou = vis_ou.filter(action="view").distinct("user_email").count() | |
644 | + c_initwebconference = vis_ou.filter(action="initwebconference").distinct("user_email").count() | |
645 | + c_participate = vis_ou.filter(action="participating").distinct("user_email").count() | |
646 | + re.append([str(_('Webconference')),did,n_did]) | |
647 | + | |
631 | 648 | re.append([column_view,c_visualizou, alunos.count() - c_visualizou]) |
649 | + re.append([column_initwebconference,c_initwebconference, alunos.count() - c_initwebconference]) | |
650 | + re.append([column_participate,c_participate, alunos.count() - c_participate]) | |
651 | + | |
652 | + context['view'] = column_view | |
653 | + context['initwebconference'] = column_initwebconference | |
654 | + context['participate'] = column_participate | |
632 | 655 | context['topic'] = webconference.topic |
633 | 656 | context['subject'] = webconference.topic.subject |
657 | + context['webconference'] = webconference | |
634 | 658 | context['db_data'] = re |
635 | 659 | context['title_chart'] = _('Actions about resource') |
636 | 660 | context['title_vAxis'] = _('Quantity') |
637 | - context['view'] = column_view | |
661 | + | |
638 | 662 | context["n_did_table"] = n_did |
639 | 663 | context["did_table"] = did |
640 | 664 | context["history_table"] = history | ... | ... |