Commit 47e6310a4c56e952ccc8e93605a9529624ae38c8
1 parent
d9bc8ef6
Exists in
master
and in
2 other branches
Resolvendo bug 1 e 2 em pdf_file
Showing
2 changed files
with
52 additions
and
16 deletions
Show diff stats
pdf_file/templates/pdf_file/relatorios.html
@@ -84,6 +84,7 @@ | @@ -84,6 +84,7 @@ | ||
84 | } | 84 | } |
85 | searcher(col, tabela_atual,true); | 85 | searcher(col, tabela_atual,true); |
86 | } | 86 | } |
87 | + scroll("#title-table"); | ||
87 | } | 88 | } |
88 | chart.setSelection([]) | 89 | chart.setSelection([]) |
89 | } | 90 | } |
@@ -153,16 +154,18 @@ | @@ -153,16 +154,18 @@ | ||
153 | {% endblock %} | 154 | {% endblock %} |
154 | 155 | ||
155 | {% block content %} | 156 | {% block content %} |
156 | - {% if messages %} | ||
157 | - {% for message in messages %} | ||
158 | - <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | ||
159 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
160 | - <span aria-hidden="true">×</span> | ||
161 | - </button> | ||
162 | - <p>{{ message }}</p> | ||
163 | - </div> | ||
164 | - {% endfor %} | ||
165 | - {% endif %} | 157 | + <div id="message-top"> |
158 | + {% if messages %} | ||
159 | + {% for message in messages %} | ||
160 | + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | ||
161 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
162 | + <span aria-hidden="true">×</span> | ||
163 | + </button> | ||
164 | + <p>{{ message }}</p> | ||
165 | + </div> | ||
166 | + {% endfor %} | ||
167 | + {% endif %} | ||
168 | + </div> | ||
166 | <div class="panel panel-info topic-panel"> | 169 | <div class="panel panel-info topic-panel"> |
167 | <div class="panel-heading"> | 170 | <div class="panel-heading"> |
168 | <div class="row"> | 171 | <div class="row"> |
@@ -391,17 +394,41 @@ | @@ -391,17 +394,41 @@ | ||
391 | $("body").removeClass("modal-open"); | 394 | $("body").removeClass("modal-open"); |
392 | $( "#modal-message" ).empty(); | 395 | $( "#modal-message" ).empty(); |
393 | $(".modal-backdrop.fade.in").remove(); | 396 | $(".modal-backdrop.fade.in").remove(); |
397 | + $("#message-top").empty(); | ||
398 | + $("#message-top").append('\ | ||
399 | + <div class="alert alert-success alert-dismissible" role="alert">\ | ||
400 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close">\ | ||
401 | + <span aria-hidden="true">×</span>\ | ||
402 | + </button>\ | ||
403 | + <p>' + data["message"] + '</p>\ | ||
404 | + </div>\ | ||
405 | + '); | ||
406 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | ||
407 | + $('#google-chart-checkbox')[0].reset(); | ||
394 | } else { | 408 | } else { |
395 | $( "#modal-message" ).empty(); | 409 | $( "#modal-message" ).empty(); |
396 | $(".modal-backdrop.fade.in").remove(); | 410 | $(".modal-backdrop.fade.in").remove(); |
397 | $( "#modal-message" ).append( data ); | 411 | $( "#modal-message" ).append( data ); |
398 | $("#send-message-modal").modal("show"); | 412 | $("#send-message-modal").modal("show"); |
413 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | ||
399 | } | 414 | } |
400 | }, | 415 | }, |
401 | error: function(data){ | 416 | error: function(data){ |
402 | - console.log("erro"); | 417 | + $("#message-top").empty(); |
418 | + $("#message-top").append('\ | ||
419 | + <div class="alert alert-danger alert-dismissible" role="alert">\ | ||
420 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close">\ | ||
421 | + <span aria-hidden="true">×</span>\ | ||
422 | + </button>\ | ||
423 | + <p>' + data.responseText + '</p>\ | ||
424 | + </div>\ | ||
425 | + '); | ||
426 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | ||
403 | } | 427 | } |
404 | }); | 428 | }); |
405 | } | 429 | } |
430 | + function scroll(to){ | ||
431 | + $("html, body").animate({ scrollTop: $(to).offset().top }, "slow"); | ||
432 | + } | ||
406 | </script> | 433 | </script> |
407 | {% endblock %} | 434 | {% endblock %} |
pdf_file/views.py
@@ -23,6 +23,7 @@ from chat.models import Conversation, TalkMessages | @@ -23,6 +23,7 @@ from chat.models import Conversation, TalkMessages | ||
23 | from users.models import User | 23 | from users.models import User |
24 | from subjects.models import Subject | 24 | from subjects.models import Subject |
25 | from webpage.forms import FormModalMessage | 25 | from webpage.forms import FormModalMessage |
26 | +from django.http import JsonResponse | ||
26 | 27 | ||
27 | 28 | ||
28 | class ViewPDFFile(LoginRequiredMixin, LogMixin, generic.TemplateView): | 29 | class ViewPDFFile(LoginRequiredMixin, LogMixin, generic.TemplateView): |
@@ -458,6 +459,8 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | @@ -458,6 +459,8 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): | ||
458 | context["history_table"] = history | 459 | context["history_table"] = history |
459 | return context | 460 | return context |
460 | 461 | ||
462 | +from django.http import HttpResponse #used to send HTTP 404 error to ajax | ||
463 | + | ||
461 | class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): | 464 | class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
462 | log_component = 'resources' | 465 | log_component = 'resources' |
463 | log_action = 'send' | 466 | log_action = 'send' |
@@ -486,11 +489,17 @@ class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): | @@ -486,11 +489,17 @@ class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): | ||
486 | users = (self.request.POST.get('users[]','')).split(",") | 489 | users = (self.request.POST.get('users[]','')).split(",") |
487 | user = self.request.user | 490 | user = self.request.user |
488 | subject = self.pdf_file.topic.subject | 491 | subject = self.pdf_file.topic.subject |
489 | - for u in users: | ||
490 | - to_user = User.objects.get(email=u) | ||
491 | - talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | ||
492 | - created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | ||
493 | - return JsonResponse({"message":"ok"}) | 492 | + |
493 | + if (users[0] is not ''): | ||
494 | + for u in users: | ||
495 | + to_user = User.objects.get(email=u) | ||
496 | + talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | ||
497 | + created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | ||
498 | + success = str(_('The message was successfull sent!')) | ||
499 | + return JsonResponse({"message":success}) | ||
500 | + erro = HttpResponse(str(_("No user selected!"))) | ||
501 | + erro.status_code = 404 | ||
502 | + return erro | ||
494 | 503 | ||
495 | def get_context_data(self, **kwargs): | 504 | def get_context_data(self, **kwargs): |
496 | context = super(SendMessage,self).get_context_data() | 505 | context = super(SendMessage,self).get_context_data() |