Commit 8c9e775ce6163576812989a334de90e4a08ca61c
1 parent
187e2bb3
Exists in
master
and in
3 other branches
resolvendo bug na postagem em um arquivo
Showing
1 changed file
with
29 additions
and
29 deletions
Show diff stats
mural/views.py
... | ... | @@ -77,7 +77,7 @@ class GeneralIndex(LoginRequiredMixin, LogMixin, generic.ListView): |
77 | 77 | self.totals['general'] = general_visualizations.count() |
78 | 78 | self.totals['category'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & ((Q(user__is_staff = True) & (Q(post__categorypost__isnull = False) | Q(comment__post__categorypost__isnull = False))) | Q(post__categorypost__space__coordinators = user) | Q(comment__post__categorypost__space__coordinators = user) | Q(post__categorypost__space__subject_category__students = user) | Q(comment__post__categorypost__space__subject_category__students = user) | Q(post__categorypost__space__subject_category__professor = user) | Q(comment__post__categorypost__space__subject_category__professor = user))).distinct().count() |
79 | 79 | self.totals['subject'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & ((Q(user__is_staff = True) & (Q(post__subjectpost__isnull = False) | Q(comment__post__subjectpost__isnull = False))) | Q(post__subjectpost__space__professor = user) | Q(comment__post__subjectpost__space__professor = user) | Q(post__subjectpost__space__students = user) | Q(comment__post__subjectpost__space__students = user))).distinct().count() |
80 | - | |
80 | + | |
81 | 81 | general_visualizations.update(viewed = True, date_viewed = datetime.now()) |
82 | 82 | |
83 | 83 | MuralVisualizations.objects.filter(user = user, viewed = False, comment__post__generalpost__isnull = False).update(viewed = True, date_viewed = datetime.now()) |
... | ... | @@ -153,7 +153,7 @@ class GeneralCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
153 | 153 | "user_icon": self.object.user.image_url, |
154 | 154 | "simple_notify": _("%s has made a post in General")%(str(self.object.user)), |
155 | 155 | "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), |
156 | - "container": ".post", | |
156 | + "container": ".post", | |
157 | 157 | "accordion": False, |
158 | 158 | "post_type": "general" |
159 | 159 | } |
... | ... | @@ -207,7 +207,7 @@ class GeneralUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
207 | 207 | self.object.save() |
208 | 208 | |
209 | 209 | users = User.objects.all().exclude(id = self.request.user.id) |
210 | - | |
210 | + | |
211 | 211 | paths = [reverse("mural:manage_general")] |
212 | 212 | |
213 | 213 | notification = { |
... | ... | @@ -226,7 +226,7 @@ class GeneralUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
226 | 226 | self.log_context['post_id'] = str(self.object.id) |
227 | 227 | |
228 | 228 | super(GeneralUpdate, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
229 | - | |
229 | + | |
230 | 230 | return super(GeneralUpdate, self).form_valid(form) |
231 | 231 | |
232 | 232 | def get_context_data(self, *args, **kwargs): |
... | ... | @@ -261,7 +261,7 @@ class GeneralDelete(LoginRequiredMixin, LogMixin, generic.DeleteView): |
261 | 261 | |
262 | 262 | def get_success_url(self): |
263 | 263 | users = User.objects.all().exclude(id = self.request.user.id) |
264 | - | |
264 | + | |
265 | 265 | paths = [reverse("mural:manage_general")] |
266 | 266 | |
267 | 267 | notification = { |
... | ... | @@ -295,7 +295,7 @@ def load_category_posts(request, category): |
295 | 295 | mines = request.GET.get('mine', False) |
296 | 296 | showing = request.GET.get('showing', '') |
297 | 297 | n_views = 0 |
298 | - | |
298 | + | |
299 | 299 | if not favorites: |
300 | 300 | if mines: |
301 | 301 | posts = CategoryPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_categorypost.mural_ptr_id))"}).filter(space__id = category, mural_ptr__user = user) |
... | ... | @@ -306,7 +306,7 @@ def load_category_posts(request, category): |
306 | 306 | posts = CategoryPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_categorypost.mural_ptr_id))"}).filter(space__id = category, favorites_post__isnull = False, favorites_post__user = user, mural_ptr__user = user) |
307 | 307 | else: |
308 | 308 | posts = CategoryPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_categorypost.mural_ptr_id))"}).filter(space__id = category, favorites_post__isnull = False, favorites_post__user = user) |
309 | - | |
309 | + | |
310 | 310 | if showing: #Exclude ajax creation posts results |
311 | 311 | showing = showing.split(',') |
312 | 312 | posts = posts.exclude(id__in = showing) |
... | ... | @@ -348,7 +348,7 @@ class CategoryIndex(LoginRequiredMixin, generic.ListView): |
348 | 348 | |
349 | 349 | def get_queryset(self): |
350 | 350 | user = self.request.user |
351 | - | |
351 | + | |
352 | 352 | if user.is_staff: |
353 | 353 | categories = Category.objects.all() |
354 | 354 | else: |
... | ... | @@ -366,7 +366,7 @@ class CategoryIndex(LoginRequiredMixin, generic.ListView): |
366 | 366 | context['title'] = _('Mural - Per Category') |
367 | 367 | context['totals'] = self.totals |
368 | 368 | context['mural_menu_active'] = 'subjects_menu_active' |
369 | - | |
369 | + | |
370 | 370 | return context |
371 | 371 | |
372 | 372 | class CategoryCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
... | ... | @@ -400,7 +400,7 @@ class CategoryCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
400 | 400 | |
401 | 401 | users = getSpaceUsers(self.request.user.id, self.object) |
402 | 402 | entries = [] |
403 | - | |
403 | + | |
404 | 404 | paths = [reverse("mural:manage_category")] |
405 | 405 | |
406 | 406 | notification = { |
... | ... | @@ -410,7 +410,7 @@ class CategoryCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
410 | 410 | "user_icon": self.object.user.image_url, |
411 | 411 | "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), |
412 | 412 | "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), |
413 | - "container": "#" + slug, | |
413 | + "container": "#" + slug, | |
414 | 414 | "accordion": True, |
415 | 415 | "post_type": "categories" |
416 | 416 | } |
... | ... | @@ -468,7 +468,7 @@ class CategoryUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
468 | 468 | self.object.save() |
469 | 469 | |
470 | 470 | users = getSpaceUsers(self.request.user.id, self.object) |
471 | - | |
471 | + | |
472 | 472 | paths = [reverse("mural:manage_category")] |
473 | 473 | |
474 | 474 | notification = { |
... | ... | @@ -483,7 +483,7 @@ class CategoryUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
483 | 483 | |
484 | 484 | for user in users: |
485 | 485 | Group("user-%s" % user.id).send({'text': notification}) |
486 | - | |
486 | + | |
487 | 487 | self.log_context['post_id'] = self.object.id |
488 | 488 | self.log_context['category_id'] = self.object.space.id |
489 | 489 | self.log_context['category_name'] = self.object.space.name |
... | ... | @@ -525,7 +525,7 @@ class CategoryDelete(LoginRequiredMixin, LogMixin, generic.DeleteView): |
525 | 525 | |
526 | 526 | def get_success_url(self): |
527 | 527 | users = getSpaceUsers(self.request.user.id, self.object) |
528 | - | |
528 | + | |
529 | 529 | paths = [reverse("mural:manage_category")] |
530 | 530 | |
531 | 531 | notification = { |
... | ... | @@ -584,7 +584,7 @@ def load_subject_posts(request, subject): |
584 | 584 | mines = request.GET.get('mine', False) |
585 | 585 | showing = request.GET.get('showing', '') |
586 | 586 | n_views = 0 |
587 | - | |
587 | + | |
588 | 588 | if not favorites: |
589 | 589 | if mines: |
590 | 590 | posts = SubjectPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_subjectpost.mural_ptr_id))"}).filter(space__id = subject, mural_ptr__user = user) |
... | ... | @@ -595,7 +595,7 @@ def load_subject_posts(request, subject): |
595 | 595 | posts = SubjectPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_subjectpost.mural_ptr_id))"}).filter(space__id = subject, favorites_post__isnull = False, favorites_post__user = user, mural_ptr__user = user) |
596 | 596 | else: |
597 | 597 | posts = SubjectPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_subjectpost.mural_ptr_id))"}).filter(space__id = subject, favorites_post__isnull = False, favorites_post__user = user) |
598 | - | |
598 | + | |
599 | 599 | if showing: #Exclude ajax creation posts results |
600 | 600 | showing = showing.split(',') |
601 | 601 | posts = posts.exclude(id__in = showing) |
... | ... | @@ -637,7 +637,7 @@ class SubjectIndex(LoginRequiredMixin, generic.ListView): |
637 | 637 | |
638 | 638 | def get_queryset(self): |
639 | 639 | user = self.request.user |
640 | - | |
640 | + | |
641 | 641 | if user.is_staff: |
642 | 642 | subjects = Subject.objects.all() |
643 | 643 | else: |
... | ... | @@ -655,7 +655,7 @@ class SubjectIndex(LoginRequiredMixin, generic.ListView): |
655 | 655 | context['title'] = _('Mural - Per Subject') |
656 | 656 | context['totals'] = self.totals |
657 | 657 | context['mural_menu_active'] = 'subjects_menu_active' |
658 | - | |
658 | + | |
659 | 659 | return context |
660 | 660 | |
661 | 661 | class SubjectCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
... | ... | @@ -716,7 +716,7 @@ class SubjectCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
716 | 716 | "user_icon": self.object.user.image_url, |
717 | 717 | "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), |
718 | 718 | "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), |
719 | - "container": "#" + slug, | |
719 | + "container": "#" + slug, | |
720 | 720 | "accordion": True, |
721 | 721 | "post_type": "subjects" |
722 | 722 | } |
... | ... | @@ -793,7 +793,7 @@ class SubjectUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
793 | 793 | self.object.save() |
794 | 794 | |
795 | 795 | users = getSpaceUsers(self.request.user.id, self.object) |
796 | - | |
796 | + | |
797 | 797 | paths = [ |
798 | 798 | reverse("mural:manage_subject"), |
799 | 799 | reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.space.slug}) |
... | ... | @@ -826,7 +826,7 @@ class SubjectUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
826 | 826 | self.log_context['resource_slug'] = self.object.resource.slug |
827 | 827 | |
828 | 828 | super(SubjectUpdate, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
829 | - | |
829 | + | |
830 | 830 | return super(SubjectUpdate, self).form_valid(form) |
831 | 831 | |
832 | 832 | def get_context_data(self, *args, **kwargs): |
... | ... | @@ -861,7 +861,7 @@ class SubjectDelete(LoginRequiredMixin, LogMixin, generic.DeleteView): |
861 | 861 | |
862 | 862 | def get_success_url(self): |
863 | 863 | users = getSpaceUsers(self.request.user.id, self.object) |
864 | - | |
864 | + | |
865 | 865 | paths = [ |
866 | 866 | reverse("mural:manage_subject"), |
867 | 867 | reverse("mural:subject_view", args = (), kwargs = {'slug': self.object.space.slug}) |
... | ... | @@ -1113,7 +1113,7 @@ class ResourceCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
1113 | 1113 | form_class = ResourcePostForm |
1114 | 1114 | |
1115 | 1115 | def form_invalid(self, form): |
1116 | - context = super(SubjectCreate, self).form_invalid(form) | |
1116 | + context = super(ResourceCreate, self).form_invalid(form) | |
1117 | 1117 | context.status_code = 400 |
1118 | 1118 | |
1119 | 1119 | return context |
... | ... | @@ -1151,7 +1151,7 @@ class ResourceCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
1151 | 1151 | "user_icon": self.object.user.image_url, |
1152 | 1152 | "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), |
1153 | 1153 | "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), |
1154 | - "container": "#" + slug, | |
1154 | + "container": "#" + slug, | |
1155 | 1155 | "accordion": True, |
1156 | 1156 | "post_type": "subjects" |
1157 | 1157 | } |
... | ... | @@ -1263,7 +1263,7 @@ class CommentCreate(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
1263 | 1263 | |
1264 | 1264 | users = getSpaceUsers(self.request.user.id, post) |
1265 | 1265 | entries = [] |
1266 | - | |
1266 | + | |
1267 | 1267 | paths = [ |
1268 | 1268 | reverse("mural:manage_general"), |
1269 | 1269 | reverse("mural:manage_category"), |
... | ... | @@ -1361,7 +1361,7 @@ class CommentUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
1361 | 1361 | self.object.save() |
1362 | 1362 | |
1363 | 1363 | users = getSpaceUsers(self.request.user.id, self.object.post) |
1364 | - | |
1364 | + | |
1365 | 1365 | paths = [ |
1366 | 1366 | reverse("mural:manage_general"), |
1367 | 1367 | reverse("mural:manage_category"), |
... | ... | @@ -1411,7 +1411,7 @@ class CommentUpdate(LoginRequiredMixin, LogMixin, generic.UpdateView): |
1411 | 1411 | self.log_context['resource_slug'] = self.object.post.subjectpost.resource.slug |
1412 | 1412 | |
1413 | 1413 | super(CommentUpdate, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
1414 | - | |
1414 | + | |
1415 | 1415 | return super(CommentUpdate, self).form_valid(form) |
1416 | 1416 | |
1417 | 1417 | def get_context_data(self, *args, **kwargs): |
... | ... | @@ -1541,7 +1541,7 @@ def load_comments(request, post, child_id): |
1541 | 1541 | comments = Comment.objects.filter(post__id = post).order_by('-last_update') |
1542 | 1542 | else: |
1543 | 1543 | showing = showing.split(',') |
1544 | - comments = Comment.objects.filter(post__id = post).exclude(id__in = showing).order_by('-last_update') | |
1544 | + comments = Comment.objects.filter(post__id = post).exclude(id__in = showing).order_by('-last_update') | |
1545 | 1545 | |
1546 | 1546 | paginator = Paginator(comments, 5) |
1547 | 1547 | |
... | ... | @@ -1563,4 +1563,4 @@ def load_comments(request, post, child_id): |
1563 | 1563 | |
1564 | 1564 | response = render_to_string("mural/_list_view_comment.html", context, request) |
1565 | 1565 | |
1566 | - return JsonResponse({"loaded": response}) | |
1567 | 1566 | \ No newline at end of file |
1567 | + return JsonResponse({"loaded": response}) | ... | ... |