From 0967b82c15b23e79468c08d8d71b199e318715e0 Mon Sep 17 00:00:00 2001 From: Jailson Dias Date: Tue, 9 May 2017 17:36:38 -0300 Subject: [PATCH] Resolvendo bug 1, 2 e 3 em youtube-video --- youtube_video/templates/youtube/relatorios.html | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- youtube_video/views.py | 18 ++++++++++++------ 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/youtube_video/templates/youtube/relatorios.html b/youtube_video/templates/youtube/relatorios.html index d188e79..596a2c1 100644 --- a/youtube_video/templates/youtube/relatorios.html +++ b/youtube_video/templates/youtube/relatorios.html @@ -64,7 +64,7 @@ function selectHandler() { var selectedItem = chart.getSelection()[0]; - console.log(selectedItem.row,selectedItem.column); + var col = data.getColumnLabel(selectedItem.column); if (selectedItem) { if (selectedItem.row == 0 && selectedItem.column == 1){ tabela_atual = true; @@ -144,7 +144,25 @@ drawTable(column_n_did,pagination(search,1),false); alterTitleTable(search.length); putpagination(search,tabela_atual); + } else 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], + json_n_did["data"][i][2],json_n_did["data"][i][3]]); + } + searcher(col, tabela_atual,true); + + } 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, tabela_atual,true); } + scroll("#title-table"); } chart.setSelection([]) } @@ -214,16 +232,18 @@ {% endblock %} {% block content %} - {% if messages %} - {% for message in messages %} - - {% endfor %} - {% endif %} +
+ {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} +
@@ -453,19 +473,42 @@ $("body").removeClass("modal-open"); $( "#modal-message" ).empty(); $(".modal-backdrop.fade.in").remove(); + $("#message-top").empty(); + $("#message-top").append('\ + \ + '); + $("html, body").animate({ scrollTop: 0 }, "slow"); + $('#google-chart-checkbox')[0].reset(); } else { $( "#modal-message" ).empty(); $(".modal-backdrop.fade.in").remove(); $( "#modal-message" ).append( data ); $("#send-message-modal").modal("show"); + $("html, body").animate({ scrollTop: 0 }, "slow"); } }, error: function(data){ - console.log("erro"); + $("#message-top").empty(); + $("#message-top").append('\ + \ + '); + $("html, body").animate({ scrollTop: 0 }, "slow"); } }); } - + function scroll(to){ + $("html, body").animate({ scrollTop: $(to).offset().top }, "slow"); + } function alterTitleTable (quant){ $("#title-table").text(quant + " {% trans 'record(s)' %}"); } diff --git a/youtube_video/views.py b/youtube_video/views.py index 8f0d5b8..4b6d115 100644 --- a/youtube_video/views.py +++ b/youtube_video/views.py @@ -593,7 +593,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): context["history_table"] = history return context - +from django.http import HttpResponse #used to send HTTP 404 error to ajax class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): log_component = 'resources' @@ -623,11 +623,17 @@ class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): users = (self.request.POST.get('users[]','')).split(",") user = self.request.user subject = self.ytvideo.topic.subject - 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,image=image) - return JsonResponse({"message":"ok"}) + + if (users[0] is not ''): + 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,image=image) + success = str(_('The message was successfull sent!')) + return JsonResponse({"message":success}) + erro = HttpResponse(str(_("No user selected!"))) + erro.status_code = 404 + return erro def get_context_data(self, **kwargs): context = super(SendMessage,self).get_context_data() -- libgit2 0.21.2