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,6 +10,7 @@ from webpage.forms import FormModalMessage | ||
10 | from chat.models import Conversation, TalkMessages, ChatVisualizations | 10 | from chat.models import Conversation, TalkMessages, ChatVisualizations |
11 | import textwrap | 11 | import textwrap |
12 | import json | 12 | import json |
13 | +from django.db.models import Q | ||
13 | from channels import Group | 14 | from channels import Group |
14 | import datetime | 15 | import datetime |
15 | from users.models import User | 16 | from users.models import User |
@@ -545,6 +546,7 @@ class ConferenceSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffus | @@ -545,6 +546,7 @@ class ConferenceSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffus | ||
545 | context['title'] = _('Web Conference Settings') | 546 | context['title'] = _('Web Conference Settings') |
546 | 547 | ||
547 | return context | 548 | return context |
549 | + | ||
548 | class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | 550 | class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
549 | log_component = 'resources' | 551 | log_component = 'resources' |
550 | log_action = 'view_statistics' | 552 | log_action = 'view_statistics' |
@@ -561,7 +563,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | @@ -561,7 +563,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | ||
561 | webconference = get_object_or_404(Webconference, slug = slug) | 563 | webconference = get_object_or_404(Webconference, slug = slug) |
562 | 564 | ||
563 | if not has_subject_permissions(request.user, webconference.topic.subject): | 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 | return super(StatisticsView, self).dispatch(request, *args, **kwargs) | 568 | return super(StatisticsView, self).dispatch(request, *args, **kwargs) |
567 | 569 | ||
@@ -584,7 +586,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | @@ -584,7 +586,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | ||
584 | super(StatisticsView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | 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 | slug = self.kwargs.get('slug') | 591 | slug = self.kwargs.get('slug') |
590 | webconference = get_object_or_404(Webconference, slug = slug) | 592 | webconference = get_object_or_404(Webconference, slug = slug) |
@@ -602,7 +604,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | @@ -602,7 +604,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | ||
602 | if webconference.all_students : | 604 | if webconference.all_students : |
603 | alunos = webconference.topic.subject.students.all() | 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 | did,n_did,history = str(_("Realized")),str(_("Unrealized")),str(_("Historic")) | 608 | did,n_did,history = str(_("Realized")),str(_("Unrealized")),str(_("Historic")) |
607 | re = [] | 609 | re = [] |
608 | data_n_did,data_history = [],[] | 610 | data_n_did,data_history = [],[] |
@@ -615,26 +617,48 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | @@ -615,26 +617,48 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | ||
615 | 617 | ||
616 | json_history["data"] = data_history | 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 | index = 0 | 623 | index = 0 |
620 | for alun in not_view: | 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 | index += 1 | 636 | index += 1 |
637 | + | ||
623 | json_n_did["data"] = data_n_did | 638 | json_n_did["data"] = data_n_did |
624 | 639 | ||
625 | 640 | ||
626 | context["json_n_did"] = json_n_did | 641 | context["json_n_did"] = json_n_did |
627 | context["json_history"] = json_history | 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 | re.append([column_view,c_visualizou, alunos.count() - c_visualizou]) | 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 | context['topic'] = webconference.topic | 655 | context['topic'] = webconference.topic |
633 | context['subject'] = webconference.topic.subject | 656 | context['subject'] = webconference.topic.subject |
657 | + context['webconference'] = webconference | ||
634 | context['db_data'] = re | 658 | context['db_data'] = re |
635 | context['title_chart'] = _('Actions about resource') | 659 | context['title_chart'] = _('Actions about resource') |
636 | context['title_vAxis'] = _('Quantity') | 660 | context['title_vAxis'] = _('Quantity') |
637 | - context['view'] = column_view | 661 | + |
638 | context["n_did_table"] = n_did | 662 | context["n_did_table"] = n_did |
639 | context["did_table"] = did | 663 | context["did_table"] = did |
640 | context["history_table"] = history | 664 | context["history_table"] = history |