Code

Ticket #8163: admin_interface.diff

File admin_interface.diff, 8.3 KB (added by nathan, 6 years ago)
Line 
1Index: admin/media/css/global.css
2===================================================================
3--- admin/media/css/global.css  (revision 8194)
4+++ admin/media/css/global.css  (working copy)
5@@ -97,7 +97,7 @@
6 .module blockquote { margin-left:12px; }
7 .module ul, .module ol { margin-left:1.5em; }
8 .module h3 { margin-top:.6em; }
9-.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; }
10+.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; }
11 .module table { border-collapse: collapse; }
12 
13 /* MESSAGES & ERRORS */
14Index: admin/media/css/forms.css
15===================================================================
16--- admin/media/css/forms.css   (revision 8194)
17+++ admin/media/css/forms.css   (working copy)
18@@ -58,19 +58,21 @@
19 .vLargeTextField, .vXMLLargeTextField { width:48em; }
20 .flatpages-flatpage #id_content { height:40.2em; }
21 .module table .vPositiveSmallIntegerField { width:2.2em; }
22+.vTextField { width:20em; }
23+.vIntegerField { width:5em; }
24 
25 /* x unsorted */
26-.inline-group {padding:10px; padding-bottom:5px; background:#eee; margin:10px 0;}
27-.inline-group h3.header {margin:-5px -10px 5px -10px; background:#bbb; color:#fff; padding:2px 5px 3px 5px; font-size:11px}
28-.inline-related {margin-bottom:15px; position:relative;}
29-.last-related {margin-bottom:0px;}
30-.inline-related h2 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold;  color:#888; }
31-.inline-related h2 b {font-weight:normal; color:#aaa;}
32-.inline-related h2 span.delete {padding-left:20px; position:absolute; top:0px; right:5px;}
33-.inline-related h2 span.delete label {margin-left:2px; padding-top:1px;}
34-.inline-related fieldset {background:#fbfbfb;}
35-.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; }
36+.inline-group {padding:0; border:1px solid #ccc; margin:10px 0;}
37+.inline-group .aligned label { width: 7em; }
38+
39+.inline-related {position:relative;}
40+.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;}
41+.inline-related h3 span.delete {padding-left:20px; position:absolute; top:2px; right:10px;}
42+.inline-related h3 span.delete label {margin-left:2px; font-size: 11px;}
43+.inline-related fieldset {margin: 0; background:#fff; border: none; }
44+.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; }
45 .inline-related.tabular fieldset.module table {width:100%;}
46+.last-related fieldset {border: none;}
47 
48 .inline-group .tabular tr.has_original td {padding-top:2em;}
49 .inline-group .tabular tr td.original { padding:2px 0 0 0; width:0; _position:relative; }
50Index: admin/options.py
51===================================================================
52--- admin/options.py    (revision 8194)
53+++ admin/options.py    (working copy)
54@@ -164,7 +164,27 @@
55         if isinstance(db_field, models.TimeField):
56             kwargs['widget'] = widgets.AdminTimeWidget
57             return db_field.formfield(**kwargs)
58+       
59+        # For TextFields, add a custom CSS class.
60+        if isinstance(db_field, models.TextField):
61+            kwargs['widget'] = widgets.AdminTextareaWidget
62+            return db_field.formfield(**kwargs)
63+       
64+        # For URLFIelds, add a custom CSS class.
65+        if isinstance(db_field, models.URLField):
66+            kwargs['widget'] = widgets.AdminURLFieldWidget
67+            return db_field.formfield(**kwargs)
68+       
69+        # For IntegerFields, add a custom CSS class.
70+        if isinstance(db_field, models.IntegerField):
71+            kwargs['widget'] = widgets.AdminIntegerFieldWidget
72+            return db_field.formfield(**kwargs)
73 
74+        # For TextInputs, add a custom CSS class.
75+        if isinstance(db_field, models.CharField):
76+            kwargs['widget'] = widgets.AdminTextInputWidget
77+            return db_field.formfield(**kwargs)
78+   
79         # For FileFields and ImageFields add a link to the current file.
80         if isinstance(db_field, models.ImageField) or isinstance(db_field, models.FileField):
81             kwargs['widget'] = widgets.AdminFileWidget
82Index: admin/widgets.py
83===================================================================
84--- admin/widgets.py    (revision 8194)
85+++ admin/widgets.py    (working copy)
86@@ -208,3 +208,19 @@
87 
88     def id_for_label(self, id_):
89         return self.widget.id_for_label(id_)
90+
91+class AdminTextareaWidget(forms.Textarea):
92+    def __init__(self, attrs={}):
93+        super(AdminTextareaWidget, self).__init__(attrs={'class': 'vLargeTextField'})
94+
95+class AdminTextInputWidget(forms.TextInput):
96+    def __init__(self, attrs={}):
97+        super(AdminTextInputWidget, self).__init__(attrs={'class': 'vTextField'})
98+
99+class AdminURLFieldWidget(forms.TextInput):
100+    def __init__(self, attrs={}):
101+        super(AdminURLFieldWidget, self).__init__(attrs={'class': 'vURLField'})
102+
103+class AdminIntegerFieldWidget(forms.TextInput):
104+    def __init__(self, attrs={}):
105+        super(AdminIntegerFieldWidget, self).__init__(attrs={'class': 'vIntegerField'})
106\ No newline at end of file
107Index: admin/templates/admin/edit_inline/stacked.html
108===================================================================
109--- admin/templates/admin/edit_inline/stacked.html      (revision 8194)
110+++ admin/templates/admin/edit_inline/stacked.html      (working copy)
111@@ -1,14 +1,14 @@
112 {% load i18n %}
113 <div class="inline-group">
114+  <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
115 {{ inline_admin_formset.formset.management_form }}
116-{# <h3 class="header">{{ inline_admin_formset.opts.verbose_name_plural|title }}</h3> #}
117 {{ inline_admin_formset.formset.non_form_errors }}
118 
119 {% for inline_admin_form in inline_admin_formset %}
120 <div class="inline-related {% if forloop.last %}last-related{% endif %}">
121-  <h2><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
122+  <h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
123     {% 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 %}
124-    </h2>
125+  </h3>
126   {% if inline_admin_form.show_url %}
127   <p><a href="/r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a></p>
128   {% endif %}
129Index: admin/templates/admin/edit_inline/tabular.html
130===================================================================
131--- admin/templates/admin/edit_inline/tabular.html      (revision 8194)
132+++ admin/templates/admin/edit_inline/tabular.html      (working copy)
133@@ -19,7 +19,8 @@
134                   
135         <tr class="{% cycle row1,row2 %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}">
136 
137-        <td class="original">{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
138+        <td class="original">
139+          {% if inline_admin_form.original or inline_admin_form.show_url %}<p>
140           {% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
141           {% 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 %}
142             </p>{% endif %}
143@@ -46,7 +47,9 @@
144           {% endfor %}
145         {% endfor %}
146                 
147-        {% if inline_admin_formset.formset.can_delete %}<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>{% endif %}
148+        {% if inline_admin_formset.formset.can_delete %}
149+          <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
150+        {% endif %}
151         
152         </tr>
153