diff --git a/amadeus/static/js/socket.js b/amadeus/static/js/socket.js index a6b5ae5..c49689f 100644 --- a/amadeus/static/js/socket.js +++ b/amadeus/static/js/socket.js @@ -28,7 +28,7 @@ function muralNotificationPost(content) { var page = window.location.pathname, render = (content.paths.indexOf(page) != -1); - if (render) { + if ((render && page.indexOf(content.post_type) != -1) || (render && content.post_type == "general")) { if (content.accordion) { var section = $(content.container); @@ -58,6 +58,37 @@ function muralNotificationPost(content) { $(this).show(); }); + + $('.mural-tabs').find('li').each(function () { + var identity = $(this).data('mural'); + + if (identity == content.post_type) { + var span = $(this).find('span'), + actual = span.text(); + + actual = parseInt(actual, 10) + 1; + + span.text(actual); + } + }); + + if (content.post_type == "subject") { + var slug = content.container.substring(1, content.container.length), + subject_mbadge = $("#subject_" + slug).find('.mural_notify'), + actual = subject_mbadge.text(); + + if (actual != "+99") { + actual = parseInt(actual, 10) + 1; + + if (actual > 99) { + actual = "+99"; + } + + subject_mbadge.text(actual); + } + + subject_mbadge.show(); + } } if (("Notification" in window)) { @@ -105,18 +136,18 @@ function muralNotificationMuralDelete(content) { function muralNotificationComment(content) { var page = window.location.pathname, render = (content.paths.indexOf(page) != -1), - checker = ""; + checker = "general"; switch (content.post_type) { case "categorypost": - checker = "category"; + checker = "categories"; break; case "subjectpost": - checker = "subject"; + checker = "subjects"; break; } - if ((render && page.indexOf(checker) != -1) || (render && content.post_type == "generalpost")) { + if ((render && page.indexOf(checker) != -1) || (render && content.post_type == "generalpost" && page.indexOf("categories") == -1 && page.indexOf("subjects") == -1)) { var section = $(content.container); if (section.is(":visible") || section.is(":hidden")) { @@ -125,6 +156,8 @@ function muralNotificationComment(content) { comments.append(content.complete); } } else { + console.log("Lester"); + $('.mural_badge').each(function () { var actual = $(this).text(); @@ -140,6 +173,36 @@ function muralNotificationComment(content) { $(this).show(); }); + + $('.mural-tabs').find('li').each(function () { + var identity = $(this).data('mural'); + + if ((identity == checker) || (identity == "general" && content.post_type == "generalpost")) { + var span = $(this).find('span'), + actual = span.text(); + + actual = parseInt(actual, 10) + 1; + + span.text(actual); + } + }); + + if (content.post_type == "subjectpost") { + var subject_mbadge = $("#subject_" + content.type_slug).find('.mural_notify'), + actual = subject_mbadge.text(); + + if (actual != "+99") { + actual = parseInt(actual, 10) + 1; + + if (actual > 99) { + actual = "+99"; + } + + subject_mbadge.text(actual); + } + + subject_mbadge.show(); + } } if (("Notification" in window)) { diff --git a/mural/models.py b/mural/models.py index 444844c..820b12a 100644 --- a/mural/models.py +++ b/mural/models.py @@ -32,7 +32,11 @@ class Mural(KnowsChild): @always_as_child def get_space(self): - pass + pass + + @always_as_child + def get_space_slug(self): + pass @always_as_child def update_link(self): @@ -51,6 +55,9 @@ class GeneralPost(Mural): def get_space(self): return self.space + def get_space_slug(self): + return "" + def update_link(self): return "mural:update_general" @@ -66,6 +73,9 @@ class CategoryPost(Mural): def get_space(self): return self.space.id + def get_space_slug(self): + return self.space.slug + def update_link(self): return "mural:update_category" @@ -82,6 +92,9 @@ class SubjectPost(Mural): def get_space(self): return self.space.id + def get_space_slug(self): + return self.space.slug + def update_link(self): return "mural:update_subject" diff --git a/mural/templates/mural/list.html b/mural/templates/mural/list.html index f4f8364..2b22771 100644 --- a/mural/templates/mural/list.html +++ b/mural/templates/mural/list.html @@ -13,10 +13,10 @@ {% block content %}
-
diff --git a/mural/templates/mural/list_category.html b/mural/templates/mural/list_category.html index 417f87b..2587b44 100644 --- a/mural/templates/mural/list_category.html +++ b/mural/templates/mural/list_category.html @@ -15,10 +15,10 @@
-
diff --git a/mural/templates/mural/list_subject.html b/mural/templates/mural/list_subject.html index 26f16f0..30b9432 100644 --- a/mural/templates/mural/list_subject.html +++ b/mural/templates/mural/list_subject.html @@ -15,10 +15,10 @@
-
@@ -134,4 +134,5 @@ + {% endblock %} \ No newline at end of file diff --git a/mural/views.py b/mural/views.py index 817dd9d..4149048 100644 --- a/mural/views.py +++ b/mural/views.py @@ -129,7 +129,8 @@ class GeneralCreate(LoginRequiredMixin, generic.edit.CreateView): "simple_notify": _("%s has made a post in General")%(str(self.object.user)), "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), "container": ".post", - "accordion": False + "accordion": False, + "post_type": "general" } notification = json.dumps(notification) @@ -360,7 +361,8 @@ class CategoryCreate(LoginRequiredMixin, generic.edit.CreateView): "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), "container": "#" + slug, - "accordion": True + "accordion": True, + "post_type": "categories" } notification = json.dumps(notification) @@ -602,7 +604,8 @@ class SubjectCreate(LoginRequiredMixin, generic.edit.CreateView): "simple_notify": _("%s has made a post in %s")%(str(self.object.user), str(self.object.space)), "complete": render_to_string("mural/_view.html", {"post": self.object}, self.request), "container": "#" + slug, - "accordion": True + "accordion": True, + "post_type": "subjects" } notification = json.dumps(notification) @@ -801,8 +804,9 @@ class CommentCreate(LoginRequiredMixin, generic.edit.CreateView): "user_icon": self.object.user.image_url, "simple_notify": _("%s has commented in a post")%(str(self.object.user)), "complete": render_to_string("mural/_view_comment.html", {"comment": self.object}, self.request), - "container": "#post-id" + str(post.get_id()), - "post_type": post._my_subclass + "container": "#post-" + str(post.get_id()), + "post_type": post._my_subclass, + "type_slug": post.get_space_slug() } notification = json.dumps(notification) diff --git a/subjects/templates/subjects/badge.html b/subjects/templates/subjects/badge.html index 7f5d86c..6cf94a9 100644 --- a/subjects/templates/subjects/badge.html +++ b/subjects/templates/subjects/badge.html @@ -1,3 +1 @@ -{% if number > 0 %} - {% if number > 99 %} +99 {% else %} {{ number }} {% endif %} -{% endif %} \ No newline at end of file + \ No newline at end of file diff --git a/subjects/templates/subjects/subject_card.html b/subjects/templates/subjects/subject_card.html index 3c0276a..b4b83a8 100644 --- a/subjects/templates/subjects/subject_card.html +++ b/subjects/templates/subjects/subject_card.html @@ -40,7 +40,10 @@ {% notifies_number subject request.user %} - + + + {% mural_number subject request.user %} + diff --git a/subjects/templates/subjects/view.html b/subjects/templates/subjects/view.html index 6c28257..b28f99b 100644 --- a/subjects/templates/subjects/view.html +++ b/subjects/templates/subjects/view.html @@ -29,10 +29,10 @@ {% subject_permissions request.user subject as has_subject_permissions %} {% if subject.visible %} -
+
{% elif has_subject_permissions %} -
+
{% endif %}
@@ -62,7 +62,10 @@ {% notifies_number subject request.user %} - + + + {% mural_number subject request.user %} +
diff --git a/subjects/templatetags/subject_counter.py b/subjects/templatetags/subject_counter.py index 8f07e5b..6ae23d8 100644 --- a/subjects/templatetags/subject_counter.py +++ b/subjects/templatetags/subject_counter.py @@ -2,6 +2,7 @@ import datetime from django import template from django.db.models import Q +from mural.models import MuralVisualizations from notifications.models import Notification register = template.Library() @@ -24,6 +25,25 @@ def notifies_number(subject, user): context = {} context['number'] = Notification.objects.filter(task__resource__topic__subject = subject, creation_date = datetime.datetime.now(), viewed = False, user = user).count() + context['custom_class'] = 'pendencies_notify' + + return context + +@register.inclusion_tag('subjects/badge.html') +def mural_number(subject, user): + context = {} + + context['number'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__subjectpost__space = subject) | Q(comment__post__subjectpost__space = subject))).count() + context['custom_class'] = 'mural_notify' + + return context + +@register.inclusion_tag('subjects/badge.html') +def resource_mural_number(resource, user): + context = {} + + context['number'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__subjectpost__resource = resource) | Q(comment__post__subjectpost__resource = resource))).count() + context['custom_class'] = 'mural_resource_notify' return context diff --git a/webpage/templates/webpages/view.html b/webpage/templates/webpages/view.html index c94e042..0204d84 100644 --- a/webpage/templates/webpages/view.html +++ b/webpage/templates/webpages/view.html @@ -1,6 +1,6 @@ {% extends 'subjects/view.html' %} -{% load static i18n pagination permissions_tags %} +{% load static i18n pagination permissions_tags subject_counter %} {% load django_bootstrap_breadcrumbs %} {% block javascript%} @@ -41,7 +41,10 @@
diff --git a/youtube_video/templates/youtube/view.html b/youtube_video/templates/youtube/view.html index 66aa42e..6f5314c 100644 --- a/youtube_video/templates/youtube/view.html +++ b/youtube_video/templates/youtube/view.html @@ -1,6 +1,6 @@ {% extends 'subjects/view.html' %} -{% load static i18n pagination permissions_tags %} +{% load static i18n pagination permissions_tags subject_counter %} {% load django_bootstrap_breadcrumbs %} {% block javascript%} @@ -41,7 +41,10 @@
-- libgit2 0.21.2