Commit 052db9356ac0ebb652e1cffa15e31e8be1cbe538
1 parent
e19964e6
Exists in
master
and in
2 other branches
Resolvendo bug 1, 2 e 3 em file-link
Showing
2 changed files
with
52 additions
and
17 deletions
Show diff stats
file_link/templates/file_links/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 | } |
| ... | ... | @@ -148,21 +149,24 @@ |
| 148 | 149 | |
| 149 | 150 | {% block breadcrumbs %} |
| 150 | 151 | {{ block.super }} |
| 152 | + {% breadcrumb filelink.topic 'subjects:topic_view' filelink.topic.subject.slug filelink.topic.slug %} | |
| 151 | 153 | {% trans 'Reports' as bread %} |
| 152 | 154 | {% breadcrumb bread filelink%} |
| 153 | 155 | {% endblock %} |
| 154 | 156 | |
| 155 | 157 | {% 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 %} | |
| 158 | + <div id="message-top"> | |
| 159 | + {% if messages %} | |
| 160 | + {% for message in messages %} | |
| 161 | + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | |
| 162 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
| 163 | + <span aria-hidden="true">×</span> | |
| 164 | + </button> | |
| 165 | + <p>{{ message }}</p> | |
| 166 | + </div> | |
| 167 | + {% endfor %} | |
| 168 | + {% endif %} | |
| 169 | + </div> | |
| 166 | 170 | <div class="panel panel-info topic-panel"> |
| 167 | 171 | <div class="panel-heading"> |
| 168 | 172 | <div class="row"> |
| ... | ... | @@ -392,17 +396,41 @@ |
| 392 | 396 | $("body").removeClass("modal-open"); |
| 393 | 397 | $( "#modal-message" ).empty(); |
| 394 | 398 | $(".modal-backdrop.fade.in").remove(); |
| 399 | + $("#message-top").empty(); | |
| 400 | + $("#message-top").append('\ | |
| 401 | + <div class="alert alert-success alert-dismissible" role="alert">\ | |
| 402 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close">\ | |
| 403 | + <span aria-hidden="true">×</span>\ | |
| 404 | + </button>\ | |
| 405 | + <p>' + data["message"] + '</p>\ | |
| 406 | + </div>\ | |
| 407 | + '); | |
| 408 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
| 409 | + $('#google-chart-checkbox')[0].reset(); | |
| 395 | 410 | } else { |
| 396 | 411 | $( "#modal-message" ).empty(); |
| 397 | 412 | $(".modal-backdrop.fade.in").remove(); |
| 398 | 413 | $( "#modal-message" ).append( data ); |
| 399 | 414 | $("#send-message-modal").modal("show"); |
| 415 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
| 400 | 416 | } |
| 401 | 417 | }, |
| 402 | 418 | error: function(data){ |
| 403 | - console.log("erro"); | |
| 419 | + $("#message-top").empty(); | |
| 420 | + $("#message-top").append('\ | |
| 421 | + <div class="alert alert-danger alert-dismissible" role="alert">\ | |
| 422 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close">\ | |
| 423 | + <span aria-hidden="true">×</span>\ | |
| 424 | + </button>\ | |
| 425 | + <p>' + data.responseText + '</p>\ | |
| 426 | + </div>\ | |
| 427 | + '); | |
| 428 | + $("html, body").animate({ scrollTop: 0 }, "slow"); | |
| 404 | 429 | } |
| 405 | 430 | }); |
| 406 | 431 | } |
| 432 | + function scroll(to){ | |
| 433 | + $("html, body").animate({ scrollTop: $(to).offset().top }, "slow"); | |
| 434 | + } | |
| 407 | 435 | </script> |
| 408 | 436 | {% endblock %} | ... | ... |
file_link/views.py
| ... | ... | @@ -26,6 +26,7 @@ from users.models import User |
| 26 | 26 | from subjects.models import Subject |
| 27 | 27 | |
| 28 | 28 | from webpage.forms import FormModalMessage |
| 29 | +from django.http import JsonResponse | |
| 29 | 30 | |
| 30 | 31 | class DownloadFile(LoginRequiredMixin, LogMixin, generic.DetailView): |
| 31 | 32 | log_component = 'resources' |
| ... | ... | @@ -453,7 +454,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView): |
| 453 | 454 | context["history_table"] = history |
| 454 | 455 | return context |
| 455 | 456 | |
| 456 | - | |
| 457 | +from django.http import HttpResponse #used to send HTTP 404 error to ajax | |
| 457 | 458 | |
| 458 | 459 | class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
| 459 | 460 | log_component = 'resources' |
| ... | ... | @@ -483,11 +484,17 @@ class SendMessage(LoginRequiredMixin, LogMixin, generic.edit.FormView): |
| 483 | 484 | users = (self.request.POST.get('users[]','')).split(",") |
| 484 | 485 | user = self.request.user |
| 485 | 486 | subject = self.filelink.topic.subject |
| 486 | - for u in users: | |
| 487 | - to_user = User.objects.get(email=u) | |
| 488 | - talk, create = Conversation.objects.get_or_create(user_one=user,user_two=to_user) | |
| 489 | - created = TalkMessages.objects.create(text=message,talk=talk,user=user,subject=subject,image=image) | |
| 490 | - return JsonResponse({"message":"ok"}) | |
| 487 | + | |
| 488 | + if (users[0] is not ''): | |
| 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 | + success = str(_('The message was successfull sent!')) | |
| 494 | + return JsonResponse({"message":success}) | |
| 495 | + erro = HttpResponse(str(_("No user selected!"))) | |
| 496 | + erro.status_code = 404 | |
| 497 | + return erro | |
| 491 | 498 | |
| 492 | 499 | def get_context_data(self, **kwargs): |
| 493 | 500 | context = super(SendMessage,self).get_context_data() | ... | ... |