Skip to content

Commit a19ed8a

Browse files
committed
Merged the newforms-admin branch into trunk.
This is a backward incompatible change. The admin contrib app has been refactored. The newforms module has several improvements including FormSets and Media definitions. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7967 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent dc375fb commit a19ed8a

File tree

121 files changed

+8050
-2680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+8050
-2680
lines changed

AUTHORS

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ answer newbie questions, and generally made Django that much better:
7474
Arvis Bickovskis <[email protected]>
7575
Paul Bissex <http://e-scribe.com/>
7676
Simon Blanchard
77+
David Blewett <[email protected]>
7778
Matt Boersma <[email protected]>
7879
7980
Andrew Brehaut <http://brehaut.net/blog>
@@ -172,6 +173,7 @@ answer newbie questions, and generally made Django that much better:
172173
Espen Grindhaug <http://grindhaug.org/>
173174
Thomas Güttler <[email protected]>
174175
dAniel hAhler
176+
hambaloney
175177
Brian Harring <[email protected]>
176178
Brant Harris
177179
Hawkeye
@@ -194,6 +196,7 @@ answer newbie questions, and generally made Django that much better:
194196
Baurzhan Ismagulov <[email protected]>
195197
196198
199+
jdetaeye
197200
Zak Johnson <[email protected]>
198201
Nis Jørgensen <[email protected]>
199202
Michael Josephson <http://www.sdjournal.com/>
@@ -241,11 +244,13 @@ answer newbie questions, and generally made Django that much better:
241244
Waylan Limberg <[email protected]>
242245
limodou
243246
Philip Lindborg <[email protected]>
247+
Simon Litchfield <[email protected]>
244248
Daniel Lindsley <[email protected]>
245249
Trey Long <[email protected]>
246250
msaelices <[email protected]>
247251
Matt McClanahan <http://mmcc.cx/>
248252
Martin Maney <http://www.chipy.org/Martin_Maney>
253+
Petr Marhoun <[email protected]>
249254
250255
Manuzhai
251256
Petr Marhoun <[email protected]>
@@ -258,6 +263,7 @@ answer newbie questions, and generally made Django that much better:
258263
259264
Jason McBrayer <http://www.carcosa.net/jason/>
260265
266+
Christian Metts
261267
262268
263269
Slawek Mikula <slawek dot mikula at gmail dot com>
@@ -270,6 +276,7 @@ answer newbie questions, and generally made Django that much better:
270276
Eric Moritz <http://eric.themoritzfamily.com/>
271277
mrmachine <[email protected]>
272278
Robin Munn <http://www.geekforgod.com/>
279+
msundstr
273280
Robert Myers <[email protected]>
274281
Nebojša Dorđević
275282
Doug Napoleone <[email protected]>
@@ -290,6 +297,7 @@ answer newbie questions, and generally made Django that much better:
290297
291298
292299
phaedo <http://phaedo.cx/>
300+
Julien Phalip <http://www.julienphalip.com>
293301
294302
295303
Gustavo Picon
@@ -298,6 +306,7 @@ answer newbie questions, and generally made Django that much better:
298306
Mihai Preda <[email protected]>
299307
Daniel Poelzleithner <http://poelzi.org/>
300308
309+
Matthias Pronk <[email protected]>
301310
Jyrki Pulliainen <[email protected]>
302311
Johann Queuniet <[email protected]>
303312
Jan Rademaker
@@ -314,6 +323,7 @@ answer newbie questions, and generally made Django that much better:
314323
Matt Riggott
315324
Henrique Romano <[email protected]>
316325
Armin Ronacher
326+
Daniel Roseman <http://roseman.org.uk/>
317327
Brian Rosner <[email protected]>
318328
Oliver Rutherfurd <http://rutherfurd.net/>
319329
ryankanno

django/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (0, 97, 'pre')
1+
VERSION = (0, 97, 'newforms-admin')
22

33
def get_version():
44
"Returns the version as a human-format string."

django/conf/project_template/urls.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
from django.conf.urls.defaults import *
22

3+
# Uncomment this for admin:
4+
#from django.contrib import admin
5+
36
urlpatterns = patterns('',
47
# Example:
58
# (r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')),
69

10+
# Uncomment this for admin docs:
11+
#(r'^admin/doc/', include('django.contrib.admindocs.urls')),
12+
713
# Uncomment this for admin:
8-
# (r'^admin/', include('django.contrib.admin.urls')),
14+
#('^admin/(.*)', admin.site.root),
915
)

django/contrib/admin/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
2+
from django.contrib.admin.options import StackedInline, TabularInline
3+
from django.contrib.admin.sites import AdminSite, site
4+
5+
def autodiscover():
6+
"""
7+
Auto-discover INSTALLED_APPS admin.py modules and fail silently when
8+
not present. This forces an import on them to register any admin bits they
9+
may want.
10+
"""
11+
from django.conf import settings
12+
for app in settings.INSTALLED_APPS:
13+
try:
14+
__import__("%s.admin" % app)
15+
except ImportError:
16+
pass

django/contrib/admin/filterspecs.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
class FilterSpec(object):
1717
filter_specs = []
18-
def __init__(self, f, request, params, model):
18+
def __init__(self, f, request, params, model, model_admin):
1919
self.field = f
2020
self.params = params
2121

2222
def register(cls, test, factory):
2323
cls.filter_specs.append((test, factory))
2424
register = classmethod(register)
2525

26-
def create(cls, f, request, params, model):
26+
def create(cls, f, request, params, model, model_admin):
2727
for test, factory in cls.filter_specs:
2828
if test(f):
29-
return factory(f, request, params, model)
29+
return factory(f, request, params, model, model_admin)
3030
create = classmethod(create)
3131

3232
def has_output(self):
@@ -52,8 +52,8 @@ def output(self, cl):
5252
return mark_safe("".join(t))
5353

5454
class RelatedFilterSpec(FilterSpec):
55-
def __init__(self, f, request, params, model):
56-
super(RelatedFilterSpec, self).__init__(f, request, params, model)
55+
def __init__(self, f, request, params, model, model_admin):
56+
super(RelatedFilterSpec, self).__init__(f, request, params, model, model_admin)
5757
if isinstance(f, models.ManyToManyField):
5858
self.lookup_title = f.rel.to._meta.verbose_name
5959
else:
@@ -81,8 +81,8 @@ def choices(self, cl):
8181
FilterSpec.register(lambda f: bool(f.rel), RelatedFilterSpec)
8282

8383
class ChoicesFilterSpec(FilterSpec):
84-
def __init__(self, f, request, params, model):
85-
super(ChoicesFilterSpec, self).__init__(f, request, params, model)
84+
def __init__(self, f, request, params, model, model_admin):
85+
super(ChoicesFilterSpec, self).__init__(f, request, params, model, model_admin)
8686
self.lookup_kwarg = '%s__exact' % f.name
8787
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
8888

@@ -98,8 +98,8 @@ def choices(self, cl):
9898
FilterSpec.register(lambda f: bool(f.choices), ChoicesFilterSpec)
9999

100100
class DateFieldFilterSpec(FilterSpec):
101-
def __init__(self, f, request, params, model):
102-
super(DateFieldFilterSpec, self).__init__(f, request, params, model)
101+
def __init__(self, f, request, params, model, model_admin):
102+
super(DateFieldFilterSpec, self).__init__(f, request, params, model, model_admin)
103103

104104
self.field_generic = '%s__' % self.field.name
105105

@@ -133,8 +133,8 @@ def choices(self, cl):
133133
FilterSpec.register(lambda f: isinstance(f, models.DateField), DateFieldFilterSpec)
134134

135135
class BooleanFieldFilterSpec(FilterSpec):
136-
def __init__(self, f, request, params, model):
137-
super(BooleanFieldFilterSpec, self).__init__(f, request, params, model)
136+
def __init__(self, f, request, params, model, model_admin):
137+
super(BooleanFieldFilterSpec, self).__init__(f, request, params, model, model_admin)
138138
self.lookup_kwarg = '%s__exact' % f.name
139139
self.lookup_kwarg2 = '%s__isnull' % f.name
140140
self.lookup_val = request.GET.get(self.lookup_kwarg, None)
@@ -159,10 +159,10 @@ def choices(self, cl):
159159
# if a field is eligible to use the BooleanFieldFilterSpec, that'd be much
160160
# more appropriate, and the AllValuesFilterSpec won't get used for it.
161161
class AllValuesFilterSpec(FilterSpec):
162-
def __init__(self, f, request, params, model):
163-
super(AllValuesFilterSpec, self).__init__(f, request, params, model)
162+
def __init__(self, f, request, params, model, model_admin):
163+
super(AllValuesFilterSpec, self).__init__(f, request, params, model, model_admin)
164164
self.lookup_val = request.GET.get(f.name, None)
165-
self.lookup_choices = model._meta.admin.manager.distinct().order_by(f.name).values(f.name)
165+
self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)
166166

167167
def title(self):
168168
return self.field.verbose_name

django/contrib/admin/media/css/forms.css

+21
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,24 @@ fieldset.monospace textarea { font-family:"Bitstream Vera Sans Mono",Monaco,"Cou
5858
.vLargeTextField, .vXMLLargeTextField { width:48em; }
5959
.flatpages-flatpage #id_content { height:40.2em; }
6060
.module table .vPositiveSmallIntegerField { width:2.2em; }
61+
62+
/* x unsorted */
63+
.inline-group {padding:10px; padding-bottom:5px; background:#eee; margin:10px 0;}
64+
.inline-group h3.header {margin:-5px -10px 5px -10px; background:#bbb; color:#fff; padding:2px 5px 3px 5px; font-size:11px}
65+
.inline-related {margin-bottom:15px; position:relative;}
66+
.last-related {margin-bottom:0px;}
67+
.inline-related h2 { margin:0; padding:2px 5px 3px 5px; font-size:11px; text-align:left; font-weight:bold; color:#888; }
68+
.inline-related h2 b {font-weight:normal; color:#aaa;}
69+
.inline-related h2 span.delete {padding-left:20px; position:absolute; top:0px; right:5px;}
70+
.inline-related h2 span.delete label {margin-left:2px; padding-top:1px;}
71+
.inline-related fieldset {background:#fbfbfb;}
72+
.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; }
73+
.inline-related.tabular fieldset.module table {width:100%;}
74+
75+
.inline-group .tabular tr.has_original td {padding-top:2em;}
76+
.inline-group .tabular tr td.original { padding:2px 0 0 0; width:0; _position:relative; }
77+
.inline-group .tabular th.original {width:0px; padding:0;}
78+
.inline-group .tabular td.original p {position:absolute; left:0; height:1.1em; padding:2px 7px; overflow:hidden; font-size:9px; font-weight:bold; color:#666; _width:700px; }
79+
.inline-group ul.tools {padding:0; margin: 0; list-style:none;}
80+
.inline-group ul.tools li {display:inline; padding:0 5px;}
81+
.inline-group ul.tools a.add {background:url(../img/admin/icon_addlink.gif) 0 50% no-repeat; padding-left:14px;}

django/contrib/admin/media/js/SelectFilter.js

-81
This file was deleted.

django/contrib/admin/media/js/admin/CollapsedFieldsets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var CollapsedFieldsets = {
4747
// Returns true if any fields in the fieldset have validation errors.
4848
var divs = fs.getElementsByTagName('div');
4949
for (var i=0; i<divs.length; i++) {
50-
if (divs[i].className.match(/\berror\b/)) {
50+
if (divs[i].className.match(/\berrors\b/)) {
5151
return true;
5252
}
5353
}

django/contrib/admin/media/js/admin/RelatedObjectLookups.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Handles related-objects functionality: lookup link for raw_id_admin=True
1+
// Handles related-objects functionality: lookup link for raw_id_fields
22
// and Add Another links.
33

44
function html_unescape(text) {
@@ -29,7 +29,7 @@ function showRelatedObjectLookupPopup(triggeringLink) {
2929
function dismissRelatedLookupPopup(win, chosenId) {
3030
var name = win.name.replace(/___/g, '.');
3131
var elem = document.getElementById(name);
32-
if (elem.className.indexOf('vRawIdAdminField') != -1 && elem.value) {
32+
if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
3333
elem.value += ',' + chosenId;
3434
} else {
3535
document.getElementById(name).value = chosenId;

django/contrib/admin/models.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.db import models
22
from django.contrib.contenttypes.models import ContentType
33
from django.contrib.auth.models import User
4+
from django.contrib.admin.util import quote
45
from django.utils.translation import ugettext_lazy as _
56
from django.utils.encoding import smart_unicode
67
from django.utils.safestring import mark_safe
@@ -50,4 +51,4 @@ def get_admin_url(self):
5051
Returns the admin URL to edit the object represented by this log entry.
5152
This is relative to the Django admin index page.
5253
"""
53-
return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id))
54+
return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, quote(self.object_id)))

0 commit comments

Comments
 (0)