From 6b0001a8e10c6d248e5fabd966bdf0fe0f2c2cfc Mon Sep 17 00:00:00 2001 From: richardbarran Date: Thu, 10 Jun 2010 13:45:14 +0000 Subject: [PATCH] Changes to the admin: improve Room change page, and add to it a list of all the messages for that Room. git-svn-id: http://django-jqchat.googlecode.com/svn/trunk@17 8369a704-5b4a-11de-992f-fdd7e25b9163 --- jqchat/admin.py | 9 ++++++ .../admin/jqchat/room/change_form.html | 28 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 jqchat/templates/admin/jqchat/room/change_form.html diff --git a/jqchat/admin.py b/jqchat/admin.py index 9c99d4e..2d12e1a 100644 --- a/jqchat/admin.py +++ b/jqchat/admin.py @@ -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 index 0000000..d968937 --- /dev/null +++ b/jqchat/templates/admin/jqchat/room/change_form.html @@ -0,0 +1,28 @@ +{% extends "admin/change_form.html" %} +{% load i18n admin_modify adminmedia %} + +{% block extrastyle %} + {{ block.super }} + +{% endblock %} + +{% block after_field_sets %} +
+
+ {{ original.last_activity_datetime }} +
+
+ +
+ {% for m in original.message_set.all %} + {{ m.created|time:"H:i:s" }} {{ m.text|safe }} + {% endfor %} +
+
+
+{% endblock %} + -- 2.39.5