diff --git a/amadeus/context_processors.py b/amadeus/context_processors.py index b28efeb..47bd62e 100644 --- a/amadeus/context_processors.py +++ b/amadeus/context_processors.py @@ -3,6 +3,7 @@ from datetime import datetime from themes.models import Themes from notifications.models import Notification from mural.models import MuralVisualizations +from chat.models import ChatVisualizations def theme(request): context = {} @@ -35,4 +36,16 @@ def mural_notifies(request): context['mural_notifications_count'] = notifications + return context + +def chat_notifies(request): + context = {} + + notifications = 0 + + if request.user.is_authenticated: + notifications = ChatVisualizations.objects.filter(viewed = False, user = request.user).count() + + context['chat_notifications_count'] = notifications + return context \ No newline at end of file diff --git a/amadeus/settings.py b/amadeus/settings.py index 9652874..8ca2238 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -118,6 +118,7 @@ TEMPLATES = [ 'amadeus.context_processors.theme', 'amadeus.context_processors.notifies', 'amadeus.context_processors.mural_notifies', + 'amadeus.context_processors.chat_notifies', ], }, }, diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index 3aeba58..f9c1bc8 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -1468,6 +1468,7 @@ div.dataTables_wrapper div.dataTables_paginate { #msg_editable { width: 100%; z-index: 1; + min-height: 20px; } .action-button { diff --git a/amadeus/static/js/socket.js b/amadeus/static/js/socket.js index f440bbe..6d6d15d 100644 --- a/amadeus/static/js/socket.js +++ b/amadeus/static/js/socket.js @@ -239,6 +239,43 @@ function messageReceived(content) { $(this).hide(); }); + } else { + var talk_line = $("#talk-" + content.container), + talk_notifies = talk_line.find('.chat_notify'), + actual_count = talk_notifies.text(); + + actual_count = parseInt(actual_count, 10) + 1; + + talk_notifies.text(actual_count); + + $('.chat_badge').each(function () { + var actual = $(this).text(); + + if (actual != "+99") { + actual = parseInt(actual, 10) + 1; + + if (actual > 99) { + actual = "+99"; + } + + $(this).text(actual); + } + + $(this).show(); + }); + + $('.chat-tabs').find('li').each(function () { + var identity = $(this).data('chat'); + + if (identity == content.subtype) { + var span = $(this).find('span'), + actual = span.text(); + + actual = parseInt(actual, 10) + 1; + + span.text(actual); + } + }); } if (("Notification" in window)) { diff --git a/amadeus/templates/base.html b/amadeus/templates/base.html index 23ae849..68eb560 100644 --- a/amadeus/templates/base.html +++ b/amadeus/templates/base.html @@ -209,6 +209,7 @@
  • +
  • @@ -263,6 +264,7 @@
  • +
  • diff --git a/chat/templates/chat/_view.html b/chat/templates/chat/_view.html index 65f6b5a..d266d6f 100644 --- a/chat/templates/chat/_view.html +++ b/chat/templates/chat/_view.html @@ -4,12 +4,12 @@ {% is_online talking_to as status %} -
    +
    diff --git a/chat/templates/chat/list.html b/chat/templates/chat/list.html index 0909dc3..b529c03 100644 --- a/chat/templates/chat/list.html +++ b/chat/templates/chat/list.html @@ -13,10 +13,10 @@ {% block content %} diff --git a/chat/templatetags/chat_tags.py b/chat/templatetags/chat_tags.py index f812625..7f5e0d8 100644 --- a/chat/templatetags/chat_tags.py +++ b/chat/templatetags/chat_tags.py @@ -7,7 +7,7 @@ from django.contrib.sessions.models import Session from log.models import Log -from chat.models import TalkMessages +from chat.models import TalkMessages, ChatVisualizations register = template.Library() @@ -49,4 +49,10 @@ def chat_user(user, chat): def last_message(chat): last_message = TalkMessages.objects.filter(talk = chat).order_by('-create_date')[0] - return last_message.create_date \ No newline at end of file + return last_message.create_date + +@register.filter(name = 'notifies') +def notifies(chat, user): + total = ChatVisualizations.objects.filter(message__talk = chat, user = user).count() + + return total \ No newline at end of file -- libgit2 0.21.2