Fix styling of AFE admin interface.

The change_list.html for tests used to be handled as a customized
template. The template failed to extend the original change_list.html,
so it didn't keep up to date. Additionally, the "white-space:pre" style
was applied to all <td> elements instead of just the description.

This restricts that style change to the description only, and also
maintains most of the default Django admin interface.

Signed-off-by: James Ren <[email protected]>

--- autotest/frontend/afe/admin.py      2010-02-12 12:41:15.000000000 -0800
+++ autotest/frontend/afe/admin.py      2010-02-12 12:41:15.000000000 -0800
@@ -101,7 +101,7 @@
               'test_time', 'sync_count', 'test_type', 'path',
               'dependencies', 'experimental', 'run_verify',
               'description')
-    list_display = ('name', 'test_type', 'description', 'sync_count')
+    list_display = ('name', 'test_type', 'admin_description', 'sync_count')
     search_fields = ('name',)
     filter_horizontal = ('dependency_labels',)
 
--- autotest/frontend/afe/models.py     2010-02-12 12:41:15.000000000 -0800
+++ autotest/frontend/afe/models.py     2010-02-12 12:41:15.000000000 -0800
@@ -1,6 +1,7 @@
 import logging, os
 from datetime import datetime
 from django.db import models as dbmodels, connection
+from xml.sax import saxutils
 import common
 from autotest_lib.frontend.afe import model_logic
 from autotest_lib.frontend import settings, thread_local
@@ -422,6 +423,12 @@
     objects = model_logic.ExtendedManager()
 
 
+    def admin_description(self):
+        escaped_description = saxutils.escape(self.description)
+        return '<span style="white-space:pre">%s</span>' % escaped_description
+    admin_description.allow_tags = True
+
+
     class Meta:
         db_table = 'afe_autotests'
 
==== (deleted) 
//depot/google_vendor_src_branch/autotest/frontend/templates/admin/afe/test/change_list.html
 ====
--- autotest/frontend/templates/admin/afe/test/change_list.html 2010-02-12 
12:41:15.000000000 -0800
+++ /dev/null   2009-12-17 12:29:38.000000000 -0800
@@ -1,45 +0,0 @@
-{% extends "admin/base_site.html" %}
-{% load adminmedia admin_list i18n %}
-
-{% block stylesheet %}{% admin_media_prefix %}css/changelists.css{% endblock %}
-
-<!-- This file is a copy of 
django/contrib/admin/templates/admin/change_list.html with the following 
extrastyle added: -->
-{% block extrastyle %}
-<style type="text/css">
-  table tbody td { white-space:pre; }
-</style>
-{% endblock %}
-
-{% block bodyclass %}change-list{% endblock %}
-
-{% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a 
href="../../">{% trans "Home" %}</a> &rsaquo; <a href="../">{{ 
app_label|capfirst }}</a> &rsaquo; {{ cl.opts.verbose_name_plural|capfirst 
}}</div>{% endblock %}{% endif %}
-
-{% block coltype %}flex{% endblock %}
-
-{% block content %}
-<div id="content-main">
-{% block object-tools %}
-{% if has_add_permission %}
-<ul class="object-tools"><li><a href="add/{% if is_popup %}?_popup=1{% endif 
%}" class="addlink">{% blocktrans with cl.opts.verbose_name as name %}Add {{ 
name }}{% endblocktrans %}</a></li></ul>
-{% endif %}
-{% endblock %}
-<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
-{% block search %}{% search_form cl %}{% endblock %}
-{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
-
-{% block filters %}
-{% if cl.has_filters %}
-<div id="changelist-filter">
-<h2>{% trans 'Filter' %}</h2>
-{% for spec in cl.filter_specs %}
-   {% admin_list_filter cl spec %}
-{% endfor %}
-</div>
-{% endif %}
-{% endblock %}
-
-{% block result_list %}{% result_list cl %}{% endblock %}
-{% block pagination %}{% pagination cl %}{% endblock %}
-</div>
-</div>
-{% endblock %}
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to