Skip to content

Commit 2d85361

Browse files
committed
add compatibility for older django versions that did not use css variables in admin site
1 parent 044a3ad commit 2d85361

File tree

2 files changed

+378
-1
lines changed

2 files changed

+378
-1
lines changed

nested_inline/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class NestedModelAdmin(InlineInstancesMixin, admin.ModelAdmin):
4747

4848
class Media:
4949
css = {
50-
"all": ('admin/css/forms-nested.css',)
50+
"all": ('admin/css/forms-nested%s.css' % ('-novars' if VERSION < (3, 2) else ''),)
5151
}
5252
js = (
5353
'admin/js/jquery.init.js',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,377 @@
1+
/* This file is for django versions below 3.2, where CSS variables were not used in the admin site. */
2+
@import url('widgets.css');
3+
4+
/* FORM ROWS */
5+
6+
.form-row {
7+
overflow: hidden;
8+
padding: 8px 12px;
9+
font-size: 11px;
10+
border-bottom: 1px solid #eee;
11+
}
12+
13+
.form-row img, .form-row input {
14+
vertical-align: middle;
15+
}
16+
17+
form .form-row p {
18+
padding-left: 0;
19+
font-size: 11px;
20+
}
21+
22+
/* FORM LABELS */
23+
24+
form h4 {
25+
margin: 0 !important;
26+
padding: 0 !important;
27+
border: none !important;
28+
}
29+
30+
label {
31+
font-weight: normal !important;
32+
color: #666;
33+
font-size: 12px;
34+
}
35+
36+
.required label, label.required {
37+
font-weight: bold !important;
38+
color: #333 !important;
39+
}
40+
41+
/* RADIO BUTTONS */
42+
43+
form ul.radiolist li {
44+
list-style-type: none;
45+
}
46+
47+
form ul.radiolist label {
48+
float: none;
49+
display: inline;
50+
}
51+
52+
form ul.inline {
53+
margin-left: 0;
54+
padding: 0;
55+
}
56+
57+
form ul.inline li {
58+
float: left;
59+
padding-right: 7px;
60+
}
61+
62+
/* ALIGNED FIELDSETS */
63+
64+
.aligned label {
65+
display: block;
66+
padding: 3px 10px 0 0;
67+
float: left;
68+
width: 8em;
69+
}
70+
71+
.aligned ul label {
72+
display: inline;
73+
float: none;
74+
width: auto;
75+
}
76+
77+
.colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField {
78+
width: 350px;
79+
}
80+
81+
form .aligned p, form .aligned ul {
82+
margin-left: 7em;
83+
padding-left: 30px;
84+
}
85+
86+
form .aligned table p {
87+
margin-left: 0;
88+
padding-left: 0;
89+
}
90+
91+
form .aligned p.help {
92+
padding-left: 38px;
93+
}
94+
95+
.aligned .vCheckboxLabel {
96+
float: none !important;
97+
display: inline;
98+
padding-left: 4px;
99+
}
100+
101+
.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField {
102+
width: 610px;
103+
}
104+
105+
.checkbox-row p.help {
106+
margin-left: 0;
107+
padding-left: 0 !important;
108+
}
109+
110+
fieldset .field-box, fieldset .fieldBox {
111+
float: left;
112+
margin-right: 20px;
113+
}
114+
115+
/* WIDE FIELDSETS */
116+
117+
.wide label {
118+
width: 15em !important;
119+
}
120+
121+
form .wide p {
122+
margin-left: 15em;
123+
}
124+
125+
form .wide p.help {
126+
padding-left: 38px;
127+
}
128+
129+
.colM fieldset.wide .vLargeTextField, .colM fieldset.wide .vXMLLargeTextField {
130+
width: 450px;
131+
}
132+
133+
/* COLLAPSED FIELDSETS */
134+
135+
fieldset.collapsed * {
136+
display: none;
137+
}
138+
139+
fieldset.collapsed h2, fieldset.collapsed {
140+
display: block !important;
141+
}
142+
143+
fieldset.collapsed h2 {
144+
color: #999;
145+
}
146+
147+
fieldset.collapsed .collapse-toggle {
148+
background: transparent;
149+
display: inline !important;
150+
}
151+
152+
/* MONOSPACE TEXTAREAS */
153+
154+
fieldset.monospace textarea {
155+
font-family: "Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace;
156+
}
157+
158+
/* SUBMIT ROW */
159+
160+
.submit-row {
161+
padding: 5px 7px;
162+
text-align: right;
163+
background-color: white;
164+
border: 1px solid #ccc;
165+
margin: 5px 0;
166+
overflow: hidden;
167+
}
168+
169+
body.popup .submit-row {
170+
overflow: auto;
171+
}
172+
173+
.submit-row input {
174+
margin: 0 0 0 5px;
175+
}
176+
177+
.submit-row p {
178+
margin: 0.3em;
179+
}
180+
181+
.submit-row p.deletelink-box {
182+
float: left;
183+
}
184+
185+
.submit-row .deletelink {
186+
background: url(../img/icon-deletelink.svg) 0 50% no-repeat;
187+
padding-left: 14px;
188+
}
189+
190+
/* CUSTOM FORM FIELDS */
191+
192+
.vSelectMultipleField {
193+
vertical-align: top !important;
194+
}
195+
196+
.vCheckboxField {
197+
border: none;
198+
}
199+
200+
.vDateField, .vTimeField {
201+
margin-right: 2px;
202+
}
203+
204+
.vURLField {
205+
width: 30em;
206+
}
207+
208+
.vLargeTextField, .vXMLLargeTextField {
209+
width: 48em;
210+
}
211+
212+
.flatpages-flatpage #id_content {
213+
height: 40.2em;
214+
}
215+
216+
.module table .vPositiveSmallIntegerField {
217+
width: 2.2em;
218+
}
219+
220+
.vTextField {
221+
width: 20em;
222+
}
223+
224+
.vIntegerField {
225+
width: 5em;
226+
}
227+
228+
.vForeignKeyRawIdAdminField {
229+
width: 5em;
230+
}
231+
232+
/* INLINES */
233+
234+
.inline-group {
235+
padding: 0;
236+
border: 1px solid #ccc;
237+
margin: 10px 0;
238+
}
239+
240+
.inline-group .aligned label {
241+
width: 8em;
242+
}
243+
244+
.inline-related {
245+
position: relative;
246+
}
247+
248+
.inline-related h3 {
249+
margin: 0;
250+
color: #666;
251+
padding: 3px 5px;
252+
font-size: 11px;
253+
background-color: #e1e1e1;
254+
border-bottom: 1px solid #ddd;
255+
}
256+
257+
.inline-related h3 span.delete {
258+
float: right;
259+
}
260+
261+
.inline-related h3 span.delete label {
262+
margin-left: 2px;
263+
font-size: 11px;
264+
}
265+
266+
.inline-related fieldset {
267+
margin: 0;
268+
background: #fff;
269+
border: none;
270+
}
271+
272+
.inline-related fieldset.module h3 {
273+
margin: 0;
274+
padding: 2px 5px 3px 5px;
275+
font-size: 11px;
276+
text-align: left;
277+
font-weight: bold;
278+
background: #bcd;
279+
color: #fff;
280+
}
281+
282+
.inline-group .tabular > fieldset.module {
283+
border: none;
284+
border-bottom: 1px solid #ddd;
285+
}
286+
287+
.inline-related.tabular fieldset.module table {
288+
width: 100%;
289+
}
290+
291+
.last-related fieldset {
292+
border: none;
293+
}
294+
295+
.inline-group .tabular tr.has_original td {
296+
padding-top: 2em;
297+
}
298+
299+
.inline-group .tabular tr td.original {
300+
padding: 2px 0 0 0;
301+
width: 0;
302+
_position: relative;
303+
}
304+
305+
.inline-group .tabular th.original {
306+
width: 0px;
307+
padding: 0;
308+
}
309+
310+
.inline-group .tabular td.original p {
311+
position: absolute;
312+
left: 0;
313+
height: 1.1em;
314+
padding: 2px 7px;
315+
overflow: hidden;
316+
font-size: 9px;
317+
font-weight: bold;
318+
color: #666;
319+
_width: 700px;
320+
}
321+
322+
.inline-group ul.tools {
323+
padding: 0;
324+
margin: 0;
325+
list-style: none;
326+
}
327+
328+
.inline-group ul.tools li {
329+
display: inline;
330+
padding: 0 5px;
331+
}
332+
333+
.inline-group div.add-row,
334+
.inline-group .tabular tr.add-row td {
335+
color: #666;
336+
padding: 3px 5px;
337+
border-bottom: 1px solid #ddd;
338+
background-color: #e1e1e1;
339+
}
340+
341+
.inline-group .tabular tr.add-row td {
342+
padding: 4px 5px 3px;
343+
border-bottom: none;
344+
}
345+
346+
.inline-group ul.tools a.add,
347+
.inline-group div.add-row a,
348+
.inline-group .tabular tr.add-row td a {
349+
background: url(../img/icon-addlink.svg) 0 50% no-repeat;
350+
padding-left: 14px;
351+
font-size: 11px;
352+
outline: 0; /* Remove dotted border around link */
353+
}
354+
355+
.nested-inline {
356+
margin: 5px;
357+
}
358+
359+
td > .nested-inline {
360+
margin: 0px;
361+
}
362+
363+
.nested-inline-bottom-border {
364+
border-bottom: 1px solid #DDDDDD;
365+
}
366+
367+
.no-bottom-border.row1 > td {
368+
border-bottom: solid #EDF3FE 1px;
369+
}
370+
371+
.no-bottom-border.row2 > td {
372+
border-bottom: solid white 1px;
373+
}
374+
375+
.empty-form {
376+
display: none;
377+
}

0 commit comments

Comments
 (0)