Commit a19ed8ae authored by Brian Rosner's avatar Brian Rosner
Browse files

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
parent dc375fb0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ answer newbie questions, and generally made Django that much better:
    Arvis Bickovskis <viestards.lists@gmail.com>
    Paul Bissex <http://e-scribe.com/>
    Simon Blanchard
    David Blewett <david@dawninglight.net>
    Matt Boersma <ogghead@gmail.com>
    boobsd@gmail.com
    Andrew Brehaut <http://brehaut.net/blog>
@@ -172,6 +173,7 @@ answer newbie questions, and generally made Django that much better:
    Espen Grindhaug <http://grindhaug.org/>
    Thomas Güttler <hv@tbz-pariv.de>
    dAniel hAhler
    hambaloney
    Brian Harring <ferringb@gmail.com>
    Brant Harris
    Hawkeye
@@ -194,6 +196,7 @@ answer newbie questions, and generally made Django that much better:
    Baurzhan Ismagulov <ibr@radix50.net>
    james_027@yahoo.com
    jcrasta@gmail.com
    jdetaeye
    Zak Johnson <zakj@nox.cx>
    Nis Jørgensen <nis@superlativ.dk>
    Michael Josephson <http://www.sdjournal.com/>
@@ -241,11 +244,13 @@ answer newbie questions, and generally made Django that much better:
    Waylan Limberg <waylan@gmail.com>
    limodou
    Philip Lindborg <philip.lindborg@gmail.com>
    Simon Litchfield <simon@quo.com.au>
    Daniel Lindsley <polarcowz@gmail.com>
    Trey Long <trey@ktrl.com>
    msaelices <msaelices@gmail.com>
    Matt McClanahan <http://mmcc.cx/>
    Martin Maney <http://www.chipy.org/Martin_Maney>
    Petr Marhoun <petr.marhoun@gmail.com>
    masonsimon+django@gmail.com
    Manuzhai
    Petr Marhoun <petr.marhoun@gmail.com>
@@ -258,6 +263,7 @@ answer newbie questions, and generally made Django that much better:
    mattycakes@gmail.com
    Jason McBrayer <http://www.carcosa.net/jason/>
    mccutchen@gmail.com
    Christian Metts
    michael.mcewan@gmail.com
    michal@plovarna.cz
    Slawek Mikula <slawek dot mikula at gmail dot com>
@@ -270,6 +276,7 @@ answer newbie questions, and generally made Django that much better:
    Eric Moritz <http://eric.themoritzfamily.com/>
    mrmachine <real.human@mrmachine.net>
    Robin Munn <http://www.geekforgod.com/>
    msundstr
    Robert Myers <myer0052@gmail.com>
    Nebojša Dorđević
    Doug Napoleone <doug@dougma.com>
@@ -290,6 +297,7 @@ answer newbie questions, and generally made Django that much better:
    peter@mymart.com
    pgross@thoughtworks.com
    phaedo <http://phaedo.cx/>
    Julien Phalip <http://www.julienphalip.com>
    phil@produxion.net
    phil.h.smith@gmail.com
    Gustavo Picon
@@ -298,6 +306,7 @@ answer newbie questions, and generally made Django that much better:
    Mihai Preda <mihai_preda@yahoo.com>
    Daniel Poelzleithner <http://poelzi.org/>
    polpak@yahoo.com
    Matthias Pronk <django@masida.nl>
    Jyrki Pulliainen <jyrki.pulliainen@gmail.com>
    Johann Queuniet <johann.queuniet@adh.naellia.eu>
    Jan Rademaker
@@ -314,6 +323,7 @@ answer newbie questions, and generally made Django that much better:
    Matt Riggott
    Henrique Romano <onaiort@gmail.com>
    Armin Ronacher
    Daniel Roseman <http://roseman.org.uk/>    
    Brian Rosner <brosner@gmail.com>
    Oliver Rutherfurd <http://rutherfurd.net/>
    ryankanno
+1 −1
Original line number Diff line number Diff line
VERSION = (0, 97, 'pre')
VERSION = (0, 97, 'newforms-admin')

def get_version():
    "Returns the version as a human-format string."
+7 −1
Original line number Diff line number Diff line
from django.conf.urls.defaults import *

# Uncomment this for admin:
#from django.contrib import admin

urlpatterns = patterns('',
    # Example:
    # (r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')),

    # Uncomment this for admin docs:
    #(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment this for admin:
#     (r'^admin/', include('django.contrib.admin.urls')),
    #('^admin/(.*)', admin.site.root),
)
+16 −0
Original line number Diff line number Diff line
from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
from django.contrib.admin.options import StackedInline, TabularInline
from django.contrib.admin.sites import AdminSite, site

def autodiscover():
    """
    Auto-discover INSTALLED_APPS admin.py modules and fail silently when 
    not present. This forces an import on them to register any admin bits they
    may want.
    """
    from django.conf import settings
    for app in settings.INSTALLED_APPS:
        try:
            __import__("%s.admin" % app)
        except ImportError:
            pass
+14 −14
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ import datetime

class FilterSpec(object):
    filter_specs = []
    def __init__(self, f, request, params, model):
    def __init__(self, f, request, params, model, model_admin):
        self.field = f
        self.params = params

@@ -23,10 +23,10 @@ class FilterSpec(object):
        cls.filter_specs.append((test, factory))
    register = classmethod(register)

    def create(cls, f, request, params, model):
    def create(cls, f, request, params, model, model_admin):
        for test, factory in cls.filter_specs:
            if test(f):
                return factory(f, request, params, model)
                return factory(f, request, params, model, model_admin)
    create = classmethod(create)

    def has_output(self):
@@ -52,8 +52,8 @@ class FilterSpec(object):
        return mark_safe("".join(t))

class RelatedFilterSpec(FilterSpec):
    def __init__(self, f, request, params, model):
        super(RelatedFilterSpec, self).__init__(f, request, params, model)
    def __init__(self, f, request, params, model, model_admin):
        super(RelatedFilterSpec, self).__init__(f, request, params, model, model_admin)
        if isinstance(f, models.ManyToManyField):
            self.lookup_title = f.rel.to._meta.verbose_name
        else:
@@ -81,8 +81,8 @@ class RelatedFilterSpec(FilterSpec):
FilterSpec.register(lambda f: bool(f.rel), RelatedFilterSpec)

class ChoicesFilterSpec(FilterSpec):
    def __init__(self, f, request, params, model):
        super(ChoicesFilterSpec, self).__init__(f, request, params, model)
    def __init__(self, f, request, params, model, model_admin):
        super(ChoicesFilterSpec, self).__init__(f, request, params, model, model_admin)
        self.lookup_kwarg = '%s__exact' % f.name
        self.lookup_val = request.GET.get(self.lookup_kwarg, None)

@@ -98,8 +98,8 @@ class ChoicesFilterSpec(FilterSpec):
FilterSpec.register(lambda f: bool(f.choices), ChoicesFilterSpec)

class DateFieldFilterSpec(FilterSpec):
    def __init__(self, f, request, params, model):
        super(DateFieldFilterSpec, self).__init__(f, request, params, model)
    def __init__(self, f, request, params, model, model_admin):
        super(DateFieldFilterSpec, self).__init__(f, request, params, model, model_admin)

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

@@ -133,8 +133,8 @@ class DateFieldFilterSpec(FilterSpec):
FilterSpec.register(lambda f: isinstance(f, models.DateField), DateFieldFilterSpec)

class BooleanFieldFilterSpec(FilterSpec):
    def __init__(self, f, request, params, model):
        super(BooleanFieldFilterSpec, self).__init__(f, request, params, model)
    def __init__(self, f, request, params, model, model_admin):
        super(BooleanFieldFilterSpec, self).__init__(f, request, params, model, model_admin)
        self.lookup_kwarg = '%s__exact' % f.name
        self.lookup_kwarg2 = '%s__isnull' % f.name
        self.lookup_val = request.GET.get(self.lookup_kwarg, None)
@@ -159,10 +159,10 @@ FilterSpec.register(lambda f: isinstance(f, models.BooleanField) or isinstance(f
# if a field is eligible to use the BooleanFieldFilterSpec, that'd be much
# more appropriate, and the AllValuesFilterSpec won't get used for it.
class AllValuesFilterSpec(FilterSpec):
    def __init__(self, f, request, params, model):
        super(AllValuesFilterSpec, self).__init__(f, request, params, model)
    def __init__(self, f, request, params, model, model_admin):
        super(AllValuesFilterSpec, self).__init__(f, request, params, model, model_admin)
        self.lookup_val = request.GET.get(f.name, None)
        self.lookup_choices = model._meta.admin.manager.distinct().order_by(f.name).values(f.name)
        self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)

    def title(self):
        return self.field.verbose_name
Loading