Fixed #8163 -- Restore oldforms admin styling on input fields. Also cleaned up some styles for both tabular and stacked inlines. Thanks Nathan Borror for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8240 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Brian Rosner 2008-08-08 19:54:34 +00:00
parent 5fb9599086
commit 5d199ba901
6 changed files with 58 additions and 16 deletions

View File

@ -58,19 +58,21 @@ fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Cou
.vLargeTextField, .vXMLLargeTextField { width:48em; }
.flatpages-flatpage #id_content { height:40.2em; }
.module table .vPositiveSmallIntegerField { width:2.2em; }
.vTextField { width:20em; }
.vIntegerField { width:5em; }
/* x unsorted */
.inline-group {padding:10px; padding-bottom:5px; background:#eee; margin:10px 0;}
.inline-group h3.header {margin:-5px -10px 5px -10px; background:#bbb; color:#fff; padding:2px 5px 3px 5px; font-size:11px}
.inline-related {margin-bottom:15px; position:relative;}
.last-related {margin-bottom:0px;}
.inline-related h2 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; color:#888; }
.inline-related h2 b {font-weight:normal; color:#aaa;}
.inline-related h2 span.delete {padding-left:20px; position:absolute; top:0px; right:5px;}
.inline-related h2 span.delete label {margin-left:2px; padding-top:1px;}
.inline-related fieldset {background:#fbfbfb;}
.inline-related fieldset.module h2 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#bcd; color:#fff; }
.inline-group {padding:0; border:1px solid #ccc; margin:10px 0;}
.inline-group .aligned label { width: 7em; }
.inline-related {position:relative;}
.inline-related h3 {margin: 0; color:#666; padding:3px 5px; font-size:11px; background:#e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x; border-bottom:1px solid #ddd;}
.inline-related h3 span.delete {padding-left:20px; position:absolute; top:2px; right:10px;}
.inline-related h3 span.delete label {margin-left:2px; font-size: 11px;}
.inline-related fieldset {margin: 0; background:#fff; border: none; }
.inline-related fieldset.module h3 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#bcd; color:#fff; }
.inline-related.tabular fieldset.module table {width:100%;}
.last-related fieldset {border: none;}
.inline-group .tabular tr.has_original td {padding-top:2em;}
.inline-group .tabular tr td.original { padding:2px 0 0 0; width:0; _position:relative; }

View File

@ -97,7 +97,7 @@ input[type=submit].default:active { background-image:url(../img/admin/default-bg
.module blockquote { margin-left:12px; }
.module ul, .module ol { margin-left:1.5em; }
.module h3 { margin-top:.6em; }
.module h2, .module caption { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#7CA0C7 url(../img/admin/default-bg.gif) top left repeat-x; color:white; }
.module h2, .module caption, .inline-group h2 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; background:#7CA0C7 url(../img/admin/default-bg.gif) top left repeat-x; color:white; }
.module table { border-collapse: collapse; }
/* MESSAGES & ERRORS */

View File

@ -145,6 +145,7 @@ class BaseModelAdmin(object):
'class': get_ul_class(self.radio_fields[db_field.name]),
}
)
return db_field.formfield(**kwargs)
else:
# Otherwise, use the default select widget.
return db_field.formfield(**kwargs)
@ -164,7 +165,27 @@ class BaseModelAdmin(object):
if isinstance(db_field, models.TimeField):
kwargs['widget'] = widgets.AdminTimeWidget
return db_field.formfield(**kwargs)
# For TextFields, add a custom CSS class.
if isinstance(db_field, models.TextField):
kwargs['widget'] = widgets.AdminTextareaWidget
return db_field.formfield(**kwargs)
# For URLFields, add a custom CSS class.
if isinstance(db_field, models.URLField):
kwargs['widget'] = widgets.AdminURLFieldWidget
return db_field.formfield(**kwargs)
# For IntegerFields, add a custom CSS class.
if isinstance(db_field, models.IntegerField):
kwargs['widget'] = widgets.AdminIntegerFieldWidget
return db_field.formfield(**kwargs)
# For TextInputs, add a custom CSS class.
if isinstance(db_field, models.CharField):
kwargs['widget'] = widgets.AdminTextInputWidget
return db_field.formfield(**kwargs)
# For FileFields and ImageFields add a link to the current file.
if isinstance(db_field, models.ImageField) or isinstance(db_field, models.FileField):
kwargs['widget'] = widgets.AdminFileWidget

View File

@ -1,14 +1,14 @@
{% load i18n %}
<div class="inline-group">
<h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
{{ inline_admin_formset.formset.management_form }}
{# <h3 class="header">{{ inline_admin_formset.opts.verbose_name_plural|title }}</h3> #}
{{ inline_admin_formset.formset.non_form_errors }}
{% for inline_admin_form in inline_admin_formset %}
<div class="inline-related {% if forloop.last %}last-related{% endif %}">
<h2><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
<h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
{% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
</h2>
</h3>
{% if inline_admin_form.show_url %}
<p><a href="/r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a></p>
{% endif %}

View File

@ -19,7 +19,8 @@
<tr class="{% cycle row1,row2 %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}">
<td class="original">{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
<td class="original">
{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
{% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
{% if inline_admin_form.show_url %}<a href="/r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a>{% endif %}
</p>{% endif %}
@ -46,7 +47,9 @@
{% endfor %}
{% endfor %}
{% if inline_admin_formset.formset.can_delete %}<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>{% endif %}
{% if inline_admin_formset.formset.can_delete %}
<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
{% endif %}
</tr>

View File

@ -208,3 +208,19 @@ class RelatedFieldWidgetWrapper(forms.Widget):
def id_for_label(self, id_):
return self.widget.id_for_label(id_)
class AdminTextareaWidget(forms.Textarea):
def __init__(self, attrs={}):
super(AdminTextareaWidget, self).__init__(attrs={'class': 'vLargeTextField'})
class AdminTextInputWidget(forms.TextInput):
def __init__(self, attrs={}):
super(AdminTextInputWidget, self).__init__(attrs={'class': 'vTextField'})
class AdminURLFieldWidget(forms.TextInput):
def __init__(self, attrs={}):
super(AdminURLFieldWidget, self).__init__(attrs={'class': 'vURLField'})
class AdminIntegerFieldWidget(forms.TextInput):
def __init__(self, attrs={}):
super(AdminIntegerFieldWidget, self).__init__(attrs={'class': 'vIntegerField'})