]> git.parisson.com Git - django-jqchat.git/commitdiff
Changes to the admin: improve Room change page, and add to it a list of all the messa...
authorrichardbarran <richardbarran@8369a704-5b4a-11de-992f-fdd7e25b9163>
Thu, 10 Jun 2010 13:45:14 +0000 (13:45 +0000)
committerrichardbarran <richardbarran@8369a704-5b4a-11de-992f-fdd7e25b9163>
Thu, 10 Jun 2010 13:45:14 +0000 (13:45 +0000)
git-svn-id: http://django-jqchat.googlecode.com/svn/trunk@17 8369a704-5b4a-11de-992f-fdd7e25b9163

jqchat/admin.py
jqchat/templates/admin/jqchat/room/change_form.html [new file with mode: 0644]

index 9c99d4e8ab5e0b23d1dd264fcf47e7a0bdd3d5f5..2d12e1aa803b9bbb634db3f25add4af0fa30f4db 100644 (file)
@@ -5,6 +5,15 @@ from django.contrib import admin
 
 class RoomAdmin(admin.ModelAdmin):
     list_display = ('name', 'created', 'last_activity_formatted', 'description', 'description_modified')
+    readonly_fields = ('created', 'description_modified', 'content_type', 'object_id')
+    # As we've set some fields to be read-only, they will automatically appear at the end 
+    # of the list. Manually order the fields to be as they are defined in the model.
+    fieldsets = (
+        (None, {
+            'fields': ('name', 'created', 'description', 'description_modified',
+                       'content_type', 'object_id')
+        }),
+    )
 
     # When changing a description, we need to know the request.user as an attribute
     # of the room instance. This snippet below adds it.
diff --git a/jqchat/templates/admin/jqchat/room/change_form.html b/jqchat/templates/admin/jqchat/room/change_form.html
new file mode 100644 (file)
index 0000000..d968937
--- /dev/null
@@ -0,0 +1,28 @@
+{% extends "admin/change_form.html" %}
+{% load i18n admin_modify adminmedia %}
+
+{% block extrastyle %}
+       {{ block.super }}
+       <style type="text/css">
+               #chat-room-messages div {
+                       margin-left: 10em;
+               }
+       </style>
+{% endblock %}
+
+{% block after_field_sets %}
+<fieldset class="module aligned">
+       <div class="form-row">
+               <label>Last activity:</label> {{ original.last_activity_datetime }}
+       </div>
+       <div class="form-row" id="chat-room-messages">
+               <label>Messages:</label> 
+               <div>
+                       {% for m in original.message_set.all %}
+                               {{ m.created|time:"H:i:s" }} {{ m.text|safe }}
+                       {% endfor %}
+               </div>
+       </div>
+</fieldset>
+{% endblock %}
+