{% 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 }}
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."""
def setUp(self):
self.client = Client()
self.client.login(username='mickey', password='test')
-
+
def test_get_messages(self):
"""Get the latest messages."""
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
'NewDescription': NewDescription,
'user_tz': user_tz,
'CustomPayload': CustomPayload,
+ 'TimeDisplayFormat': DATE_FORMAT
},
context_instance=RequestContext(self.request))
response['Content-Type'] = 'text/plain; charset=utf-8'