Commit 72992dfcae1caad4b42c7ffc64f66f7a5b2aa51c

Authored by Zambom
1 parent 1ba9511f

Updating last message chat date when new arrives

Showing 2 changed files with 7 additions and 2 deletions   Show diff stats
amadeus/static/js/socket.js
@@ -242,11 +242,14 @@ function messageReceived(content) { @@ -242,11 +242,14 @@ function messageReceived(content) {
242 } else { 242 } else {
243 var talk_line = $("#talk-" + content.container), 243 var talk_line = $("#talk-" + content.container),
244 talk_notifies = talk_line.find('.chat_notify'), 244 talk_notifies = talk_line.find('.chat_notify'),
245 - actual_count = talk_notifies.text(); 245 + actual_count = talk_notifies.text(),
  246 + actual_date = talk_line.find(".talk-last_msg");
246 247
247 actual_count = parseInt(actual_count, 10) + 1; 248 actual_count = parseInt(actual_count, 10) + 1;
248 249
249 talk_notifies.text(actual_count); 250 talk_notifies.text(actual_count);
  251 +
  252 + actual_date.html(content.last_date);
250 253
251 $('.chat_badge').each(function () { 254 $('.chat_badge').each(function () {
252 var actual = $(this).text(); 255 var actual = $(this).text();
@@ -7,6 +7,7 @@ from django.http import JsonResponse @@ -7,6 +7,7 @@ from django.http import JsonResponse
7 from django.template.loader import render_to_string 7 from django.template.loader import render_to_string
8 from django.core.urlresolvers import reverse, reverse_lazy 8 from django.core.urlresolvers import reverse, reverse_lazy
9 import textwrap 9 import textwrap
  10 +from django.utils import formats
10 from django.utils.html import strip_tags 11 from django.utils.html import strip_tags
11 from django.utils.translation import ugettext_lazy as _ 12 from django.utils.translation import ugettext_lazy as _
12 from django.contrib.auth.mixins import LoginRequiredMixin 13 from django.contrib.auth.mixins import LoginRequiredMixin
@@ -193,7 +194,8 @@ class SendMessage(LoginRequiredMixin, generic.edit.CreateView): @@ -193,7 +194,8 @@ class SendMessage(LoginRequiredMixin, generic.edit.CreateView):
193 "notify_title": str(self.object.user), 194 "notify_title": str(self.object.user),
194 "simple_notify": simple_notify, 195 "simple_notify": simple_notify,
195 "complete": render_to_string("chat/_message.html", {"talk_msg": self.object}, self.request), 196 "complete": render_to_string("chat/_message.html", {"talk_msg": self.object}, self.request),
196 - "container": "chat-" + str(self.object.user.id) 197 + "container": "chat-" + str(self.object.user.id),
  198 + "last_date": _("Last message in %s")%(formats.date_format(self.object.create_date, "SHORT_DATETIME_FORMAT"))
197 } 199 }
198 200
199 notification = json.dumps(notification) 201 notification = json.dumps(notification)