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 | 84 | } |
85 | 85 | searcher(col, tabela_atual,true); |
86 | 86 | } |
87 | + scroll("#title-table"); | |
87 | 88 | } |
88 | 89 | chart.setSelection([]) |
89 | 90 | } |
... | ... | @@ -153,16 +154,18 @@ |
153 | 154 | {% endblock %} |
154 | 155 | |
155 | 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 | 169 | <div class="panel panel-info topic-panel"> |
167 | 170 | <div class="panel-heading"> |
168 | 171 | <div class="row"> |
... | ... | @@ -391,17 +394,41 @@ |
391 | 394 | $("body").removeClass("modal-open"); |
392 | 395 | $( "#modal-message" ).empty(); |
393 | 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 | 408 | } else { |
395 | 409 | $( "#modal-message" ).empty(); |
396 | 410 | $(".modal-backdrop.fade.in").remove(); |
397 | 411 | $( "#modal-message" ).append( data ); |
398 | 412 | $("#send-message-modal").modal("show"); |
413 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
399 | 414 | } |
400 | 415 | }, |
401 | 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 | 433 | </script> |
407 | 434 | {% endblock %} | ... | ... |
pdf_file/views.py
... | ... | @@ -23,6 +23,7 @@ from chat.models import Conversation, TalkMessages |
23 | 23 | from users.models import User |
24 | 24 | from subjects.models import Subject |
25 | 25 | from webpage.forms import FormModalMessage |
26 | +from django.http import JsonResponse | |
26 | 27 | |
27 | 28 | |
28 | 29 | class ViewPDFFile(LoginRequiredMixin, LogMixin, generic.TemplateView): |
... | ... | @@ -458,6 +459,8 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
458 | 459 | context["history_table"] = history |
459 | 460 | return context |
460 | 461 | |
462 | +from django.http import HttpResponse #used to send HTTP 404 error to ajax | |
463 | + | |
461 | 464 | class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
462 | 465 | log_component = 'resources' |
463 | 466 | log_action = 'send' |
... | ... | @@ -486,11 +489,17 @@ class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
486 | 489 | users = (self.request.POST.get('users[]','')).split(",") |
487 | 490 | user = self.request.user |
488 | 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 | 504 | def get_context_data(self, **kwargs): |
496 | 505 | context = super(SendMessage,self).get_context_data() | ... | ... |