From 0f135ea72625338c18f7aa52da8e8802926b5150 Mon Sep 17 00:00:00 2001 From: Jailson Dias Date: Sat, 29 Apr 2017 17:05:30 -0300 Subject: [PATCH] colocando opção para enviar mensagens no pdf file --- pdf_file/templates/pdf_file/relatorios.html | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------- pdf_file/urls.py | 1 + pdf_file/views.py | 23 +++++++++++++++++++++-- 3 files changed, 154 insertions(+), 63 deletions(-) diff --git a/pdf_file/templates/pdf_file/relatorios.html b/pdf_file/templates/pdf_file/relatorios.html index b0fffb7..460e3c8 100644 --- a/pdf_file/templates/pdf_file/relatorios.html +++ b/pdf_file/templates/pdf_file/relatorios.html @@ -7,6 +7,7 @@ {{ block.super }} @@ -58,38 +66,35 @@ var selectedItem = chart.getSelection()[0]; if (selectedItem) { var col = data.getColumnLabel(selectedItem.column); - var element = ''; - if (col == "{{n_did_table}}" && text("#title-table") != "{{n_did_table}}"){ - if (length("#link-history") <= 0){ - add(element,"#view-table",true); - } - altertitle("{{n_did_table}}"); + if (col == "{{n_did_table}}"){ + tabela_atual = false; search = []; for (var i in json_n_did["data"]){ - search.push([json_n_did["data"][i][0],json_n_did["data"][i][1]]); + search.push([json_n_did["data"][i][0],json_n_did["data"][i][1], + json_n_did["data"][i][2],json_n_did["data"][i][3]]); } - drawTable(column_n_did,pagination(json_n_did["data"],1),false); - putpagination(json_n_did["data"]); + searcher(col, tabela_atual,true); - } else if (col == "{{did_table}}" && text("#title-table") != "{{did_table}}"){ + } else if (col == "{{did_table}}"){ + tabela_atual = true; search = []; for (var i in json_history["data"]){ search.push([json_history["data"][i][0],json_history["data"][i][1], json_history["data"][i][2],json_history["data"][i][3]]); } - searcher(col, true); + searcher(col, tabela_atual,true); } } chart.setSelection([]) - } + } var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); google.visualization.events.addListener(chart, 'select', selectHandler); chart.draw(data, options); } + + var sortAscending = {0:false,1:false,2:false,3:false}; function drawTable(columns = column_history,rows = pagination(json_history["data"],1),isdate = true,columndate = 3) { var data_table = new google.visualization.DataTable(); for (var i in columns){ @@ -109,10 +114,33 @@ // } // } // console.log(methods.join(",")); - + var options = { + sort: "event", + allowHtml: true, + cssClassNames : { + tableRow: 'text-center', + tableCell: 'text-center', + headerCell: 'text-center' + }, + showRowNumber: true, + width: '100%', + height: '100%', + } + function ordenar(properties){ + var columnIndex = properties['column']; + if (columnIndex > 0) { + options["sortColumn"] = columnIndex; + options["sortAscending"] = sortAscending[columnIndex]; + data_table.sort({column:columnIndex,desc:sortAscending[columnIndex]}); + sortAscending = {0:false,1:false,2:false,3:false}; + sortAscending[columnIndex] = !sortAscending[columnIndex]; + // console.log(sortAscending); + table.draw(data_table, options); + } + } var table = new google.visualization.Table(document.getElementById('table_div')); - - table.draw(data_table, {allowHtml: true, cssClassNames : {tableRow: 'text-center',tableCell: 'text-center', headerCell: 'text-center'},showRowNumber: true, width: '100%', height: '100%'}); + google.visualization.events.addListener(table, 'sort', function(e) {ordenar(e)}); + table.draw(data_table, options); } {% endblock%} @@ -148,25 +176,29 @@

{% trans "Report of the resource " %}{{pdf_file}}

-
-

{% trans "Select the period: " %}

-
-
+
+
+
+ +
+
+
@@ -199,12 +231,44 @@
+ + +


{% endblock %} diff --git a/pdf_file/urls.py b/pdf_file/urls.py index 068e071..585e67e 100644 --- a/pdf_file/urls.py +++ b/pdf_file/urls.py @@ -9,4 +9,5 @@ urlpatterns = [ url(r'^delete/(?P[\w_-]+)/$', views.DeleteView.as_view(), name = 'delete'), url(r'^view/(?P[\w_-]+)/$', views.ViewPDFFile.as_view(), name = 'view'), url(r'^chart/(?P[\w_-]+)/$', views.StatisticsView.as_view(), name = 'get_chart'), + url(r'^send-message/(?P[\w_-]+)/$', views.sendMessage, name = 'send_message'), ] diff --git a/pdf_file/views.py b/pdf_file/views.py index 09e1464..b32b71f 100644 --- a/pdf_file/views.py +++ b/pdf_file/views.py @@ -428,8 +428,10 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): json_history["data"] = data_history not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.distinct("user_email")]) + index = 0 for alun in not_view: - data_n_did.append([str(alun),", ".join([str(x) for x in pdf_file.topic.subject.group_subject.filter(participants__email=alun.email)]),str(_('View'))]) + data_n_did.append([index,str(alun),", ".join([str(x) for x in pdf_file.topic.subject.group_subject.filter(participants__email=alun.email)]),str(_('View')), str(alun.email)]) + index += 1 json_n_did["data"] = data_n_did @@ -441,10 +443,27 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): context['topic'] = pdf_file.topic context['subject'] = pdf_file.topic.subject context['db_data'] = re - context['title_chart'] = _('Students viewing the PDF File') + context['title_chart'] = _('Actions about resource') context['title_vAxis'] = _('Quantity') context["n_did_table"] = n_did context["did_table"] = did context["history_table"] = history return context + + +from chat.models import Conversation, TalkMessages +from users.models import User +from subjects.models import Subject +def sendMessage(request, slug): + message = request.GET.get('message','') + users = request.GET.getlist('users[]','') + user = request.user + subject = get_object_or_404(Subject,slug = slug) + + for u in users: + to_user = User.objects.get(email=u) + talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) + created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject) + + return JsonResponse({"message":"ok"}) -- libgit2 0.21.2