Commit 0967b82c15b23e79468c08d8d71b199e318715e0
1 parent
052db935
Exists in
master
and in
2 other branches
Resolvendo bug 1, 2 e 3 em youtube-video
Showing
2 changed files
with
68 additions
and
19 deletions
Show diff stats
youtube_video/templates/youtube/relatorios.html
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | |
65 | 65 | function selectHandler() { |
66 | 66 | var selectedItem = chart.getSelection()[0]; |
67 | - console.log(selectedItem.row,selectedItem.column); | |
67 | + var col = data.getColumnLabel(selectedItem.column); | |
68 | 68 | if (selectedItem) { |
69 | 69 | if (selectedItem.row == 0 && selectedItem.column == 1){ |
70 | 70 | tabela_atual = true; |
... | ... | @@ -144,7 +144,25 @@ |
144 | 144 | drawTable(column_n_did,pagination(search,1),false); |
145 | 145 | alterTitleTable(search.length); |
146 | 146 | putpagination(search,tabela_atual); |
147 | + } else if (col == "{{n_did_table}}"){ | |
148 | + tabela_atual = false; | |
149 | + search = []; | |
150 | + for (var i in json_n_did["data"]){ | |
151 | + search.push([json_n_did["data"][i][0],json_n_did["data"][i][1], | |
152 | + json_n_did["data"][i][2],json_n_did["data"][i][3]]); | |
153 | + } | |
154 | + searcher(col, tabela_atual,true); | |
155 | + | |
156 | + } else if (col == "{{did_table}}"){ | |
157 | + tabela_atual = true; | |
158 | + search = []; | |
159 | + for (var i in json_history["data"]){ | |
160 | + search.push([json_history["data"][i][0],json_history["data"][i][1], | |
161 | + json_history["data"][i][2],json_history["data"][i][3]]); | |
162 | + } | |
163 | + searcher(col, tabela_atual,true); | |
147 | 164 | } |
165 | + scroll("#title-table"); | |
148 | 166 | } |
149 | 167 | chart.setSelection([]) |
150 | 168 | } |
... | ... | @@ -214,16 +232,18 @@ |
214 | 232 | {% endblock %} |
215 | 233 | |
216 | 234 | {% block content %} |
217 | - {% if messages %} | |
218 | - {% for message in messages %} | |
219 | - <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | |
220 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
221 | - <span aria-hidden="true">×</span> | |
222 | - </button> | |
223 | - <p>{{ message }}</p> | |
224 | - </div> | |
225 | - {% endfor %} | |
226 | - {% endif %} | |
235 | + <div id="message-top"> | |
236 | + {% if messages %} | |
237 | + {% for message in messages %} | |
238 | + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | |
239 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
240 | + <span aria-hidden="true">×</span> | |
241 | + </button> | |
242 | + <p>{{ message }}</p> | |
243 | + </div> | |
244 | + {% endfor %} | |
245 | + {% endif %} | |
246 | + </div> | |
227 | 247 | <div class="panel panel-info topic-panel"> |
228 | 248 | <div class="panel-heading"> |
229 | 249 | <div class="row"> |
... | ... | @@ -453,19 +473,42 @@ |
453 | 473 | $("body").removeClass("modal-open"); |
454 | 474 | $( "#modal-message" ).empty(); |
455 | 475 | $(".modal-backdrop.fade.in").remove(); |
476 | + $("#message-top").empty(); | |
477 | + $("#message-top").append('\ | |
478 | + <div class="alert alert-success alert-dismissible" role="alert">\ | |
479 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close">\ | |
480 | + <span aria-hidden="true">×</span>\ | |
481 | + </button>\ | |
482 | + <p>' + data["message"] + '</p>\ | |
483 | + </div>\ | |
484 | + '); | |
485 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
486 | + $('#google-chart-checkbox')[0].reset(); | |
456 | 487 | } else { |
457 | 488 | $( "#modal-message" ).empty(); |
458 | 489 | $(".modal-backdrop.fade.in").remove(); |
459 | 490 | $( "#modal-message" ).append( data ); |
460 | 491 | $("#send-message-modal").modal("show"); |
492 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
461 | 493 | } |
462 | 494 | }, |
463 | 495 | error: function(data){ |
464 | - console.log("erro"); | |
496 | + $("#message-top").empty(); | |
497 | + $("#message-top").append('\ | |
498 | + <div class="alert alert-danger alert-dismissible" role="alert">\ | |
499 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close">\ | |
500 | + <span aria-hidden="true">×</span>\ | |
501 | + </button>\ | |
502 | + <p>' + data.responseText + '</p>\ | |
503 | + </div>\ | |
504 | + '); | |
505 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
465 | 506 | } |
466 | 507 | }); |
467 | 508 | } |
468 | - | |
509 | + function scroll(to){ | |
510 | + $("html, body").animate({ scrollTop: $(to).offset().top }, "slow"); | |
511 | + } | |
469 | 512 | function alterTitleTable (quant){ |
470 | 513 | $("#title-table").text(quant + " {% trans 'record(s)' %}"); |
471 | 514 | } | ... | ... |
youtube_video/views.py
... | ... | @@ -593,7 +593,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
593 | 593 | context["history_table"] = history |
594 | 594 | return context |
595 | 595 | |
596 | - | |
596 | +from django.http import HttpResponse #used to send HTTP 404 error to ajax | |
597 | 597 | |
598 | 598 | class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
599 | 599 | log_component = 'resources' |
... | ... | @@ -623,11 +623,17 @@ class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
623 | 623 | users = (self.request.POST.get('users[]','')).split(",") |
624 | 624 | user = self.request.user |
625 | 625 | subject = self.ytvideo.topic.subject |
626 | - for u in users: | |
627 | - to_user = User.objects.get(email=u) | |
628 | - talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | |
629 | - created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | |
630 | - return JsonResponse({"message":"ok"}) | |
626 | + | |
627 | + if (users[0] is not ''): | |
628 | + for u in users: | |
629 | + to_user = User.objects.get(email=u) | |
630 | + talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | |
631 | + created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | |
632 | + success = str(_('The message was successfull sent!')) | |
633 | + return JsonResponse({"message":success}) | |
634 | + erro = HttpResponse(str(_("No user selected!"))) | |
635 | + erro.status_code = 404 | |
636 | + return erro | |
631 | 637 | |
632 | 638 | def get_context_data(self, **kwargs): |
633 | 639 | context = super(SendMessage,self).get_context_data() | ... | ... |