]> git.parisson.com Git - django-jqchat.git/commitdiff
Allow datetime format in the messages to be customised.
authorrichardbarran <richardbarran@8369a704-5b4a-11de-992f-fdd7e25b9163>
Sat, 1 Aug 2009 22:40:59 +0000 (22:40 +0000)
committerrichardbarran <richardbarran@8369a704-5b4a-11de-992f-fdd7e25b9163>
Sat, 1 Aug 2009 22:40:59 +0000 (22:40 +0000)
git-svn-id: http://django-jqchat.googlecode.com/svn/trunk@10 8369a704-5b4a-11de-992f-fdd7e25b9163

jqchat/templates/jqchat/chat_payload.json
jqchat/tests.py
jqchat/views.py

index e7d4af57fd8e92fffbd96ad800bcfdee04b8f894..13add894c52e08ab04ba2dbb24f897fe1b5493a8 100644 (file)
@@ -5,7 +5,7 @@
 {% if NewDescription %}        "description": {{ NewDescription }},{% endif %}
        "messages": [
 {% for row in NewMessages %}{# The localtime filter is part of Django timezone and adjusts a datetime to the given timezone #}
-       { "text": "{{ row.created|localtime:user_tz|time:"H:i:s" }} {{ row.text|safe }}"}{% if not forloop.last %},{% endif %}
+       { "text": "{{ row.created|localtime:user_tz|date:TimeDisplayFormat }} {{ row.text|safe }}"}{% if not forloop.last %},{% endif %}
 {% endfor %}
        ]
 {{ CustomPayload|default:""|safe }}
index 0e5795dae30c3fbb952f5de3c54f4bbf22bed953..11e081bf2942d1cc211ba014f277afa6c73a1610 100644 (file)
@@ -7,10 +7,15 @@ Unit tests for jqchat application.
 from django.test import TestCase
 from django.test.client import Client
 from django.contrib.auth.models import User
+#from django.conf import settings
 
 import simplejson
 from models import Room, Message
 
+# During testing we want to use default settings.
+import views
+views.DATE_FORMAT = "H:i:s"
+
 class ChatPageTest(TestCase):
     """Test the chat test page."""
 
@@ -49,7 +54,7 @@ class AJAXGetTest(TestCase):
     def setUp(self):
         self.client = Client()
         self.client.login(username='mickey', password='test')
-
+        
     def test_get_messages(self):
         """Get the latest messages."""
 
index 32f627a324a6c30aed46989ec04104691d9325dc..167c9cb66f02af6a3186ba93c90f3f1ed7cc5d06 100644 (file)
@@ -8,6 +8,12 @@ from models import Room, Message
 
 import time
 
+# The format of the date displayed in the chat window can be customised.
+try:
+    DATE_FORMAT = settings.JQCHAT_DATE_FORMAT
+except:
+    # Use default format.
+    DATE_FORMAT = "H:i:s"
 
 #------------------------------------------------------------------------------
 @login_required
@@ -114,6 +120,7 @@ class Ajax(object):
                                        'NewDescription': NewDescription,
                                        'user_tz': user_tz,
                                        'CustomPayload': CustomPayload,
+                                       'TimeDisplayFormat': DATE_FORMAT
                                        },
                                       context_instance=RequestContext(self.request))
             response['Content-Type'] = 'text/plain; charset=utf-8'