commit 4c1c00bcea2635c4c962cb5df58d960cceae0841
Author: Diederik van der Boor <vdboor@edoburu.nl>
Date: Fri Apr 22 15:30:29 2011 +0200
Add `col-field_name` class to change_list headers.
This allows setting the column widths; improving the look of the admin lists.
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index fdf082b..139c0a1 100644
|
a
|
b
|
def result_headers(cl):
|
| 100 | 100 | # It is a non-field, but perhaps one that is sortable |
| 101 | 101 | admin_order_field = getattr(attr, "admin_order_field", None) |
| 102 | 102 | if not admin_order_field: |
| 103 | | yield {"text": header} |
| | 103 | yield { |
| | 104 | "text": header, |
| | 105 | "class_attrib": mark_safe(' class="col-%s"' % field_name) |
| | 106 | } |
| 104 | 107 | continue |
| 105 | 108 | |
| 106 | 109 | # So this _is_ a sortable non-field. Go to the yield |
| … |
… |
def result_headers(cl):
|
| 108 | 111 | else: |
| 109 | 112 | admin_order_field = None |
| 110 | 113 | |
| 111 | | th_classes = [] |
| | 114 | th_classes = ['col-' + field_name] |
| 112 | 115 | new_order_type = 'asc' |
| 113 | 116 | if field_name == cl.order_field or admin_order_field == cl.order_field: |
| 114 | 117 | th_classes.append('sorted %sending' % cl.order_type.lower()) |
| … |
… |
def result_headers(cl):
|
| 118 | 121 | "text": header, |
| 119 | 122 | "sortable": True, |
| 120 | 123 | "url": cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type}), |
| 121 | | "class_attrib": mark_safe(th_classes and ' class="%s"' % ' '.join(th_classes) or '') |
| | 124 | "class_attrib": mark_safe(' class="%s"' % ' '.join(th_classes)) |
| 122 | 125 | } |
| 123 | 126 | |
| 124 | 127 | def _boolean_icon(field_val): |