mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
magic-removal: Added a 'description' option to fieldset options that allows extra HTML to be displayed at the top of each fieldset in the admin.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2556 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
dc0fe82957
commit
b9f4a027b4
@ -186,6 +186,7 @@ td ul.errorlist li { margin:0 !important; }
|
||||
.error input, .error select { border:1px solid red; }
|
||||
div.system-message { background: #ffc; margin: 10px; padding: 6px 8px; font-size: .8em; }
|
||||
div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; color:red; background:#ffc url(../img/admin/icon_error.gif) 5px .3em no-repeat; }
|
||||
.description { font-size:12px; padding:5px 0 0 12px; }
|
||||
|
||||
/* ACTION ICONS */
|
||||
.addlink { padding-left:12px; background:url(../img/admin/icon_addlink.gif) 0 .2em no-repeat; }
|
||||
|
@ -32,6 +32,7 @@
|
||||
{% for bound_field_set in bound_field_sets %}
|
||||
<fieldset class="module aligned {{ bound_field_set.classes }}">
|
||||
{% if bound_field_set.name %}<h2>{{ bound_field_set.name }}</h2>{% endif %}
|
||||
{% if bound_field_set.description %}<div class="description">{{ bound_field_set.description }}</div>{% endif %}
|
||||
{% for bound_field_line in bound_field_set %}
|
||||
{% admin_field_line bound_field_line %}
|
||||
{% for bound_field in bound_field_line %}
|
||||
|
@ -177,6 +177,7 @@ class AdminBoundFieldSet(object):
|
||||
def __init__(self, field_set, field_mapping, original):
|
||||
self.name = field_set.name
|
||||
self.classes = field_set.classes
|
||||
self.description = field_set.description
|
||||
self.bound_field_lines = [field_line.bind(field_mapping, original, AdminBoundFieldLine) for field_line in field_set]
|
||||
|
||||
def __iter__(self):
|
||||
|
@ -218,7 +218,9 @@ class AdminOptions:
|
||||
for fieldset in field_struct:
|
||||
fs_options = fieldset[1]
|
||||
classes = fs_options.get('classes', ())
|
||||
new_fieldset_list.append(AdminFieldSet(fieldset[0], classes, opts.get_field, fs_options['fields']))
|
||||
description = fs_options.get('description', '')
|
||||
new_fieldset_list.append(AdminFieldSet(fieldset[0], classes,
|
||||
opts.get_field, fs_options['fields'], description))
|
||||
return new_fieldset_list
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
@ -227,10 +229,11 @@ class AdminOptions:
|
||||
self.manager.model = cls
|
||||
|
||||
class AdminFieldSet(object):
|
||||
def __init__(self, name, classes, field_locator_func, line_specs):
|
||||
def __init__(self, name, classes, field_locator_func, line_specs, description):
|
||||
self.name = name
|
||||
self.field_lines = [AdminFieldLine(field_locator_func, line_spec) for line_spec in line_specs]
|
||||
self.classes = classes
|
||||
self.description = description
|
||||
|
||||
def __repr__(self):
|
||||
return "FieldSet: (%s, %s)" % (self.name, self.field_lines)
|
||||
|
@ -855,6 +855,12 @@ object, which takes the following parameters. All are optional.
|
||||
"click to expand" link. Fieldsets with the ``wide`` style will be
|
||||
given extra horizontal space.
|
||||
|
||||
``description``
|
||||
Optional extra text to be displayed at the top of each fieldset,
|
||||
underneath the heading of the fieldset. It is used verbatim,
|
||||
so you can use any HTML and you must escape any special HTML
|
||||
characters (such as ampersand) yourself.
|
||||
|
||||
For example (taken from the ``django.contrib.flatpages`` model)::
|
||||
|
||||
fields = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user