Fixed #14424 -- corrected a NameError when instantiating a RelatedFieldWidgetWrapper.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14683 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
07ba3220ba
commit
3498849532
|
@ -203,7 +203,7 @@ class RelatedFieldWidgetWrapper(forms.Widget):
|
||||||
# Backwards compatible check for whether a user can add related
|
# Backwards compatible check for whether a user can add related
|
||||||
# objects.
|
# objects.
|
||||||
if can_add_related is None:
|
if can_add_related is None:
|
||||||
can_add_related = rel_to in self.admin_site._registry
|
can_add_related = rel.to in admin_site._registry
|
||||||
self.can_add_related = can_add_related
|
self.can_add_related = can_add_related
|
||||||
# so we can check if the related object is registered with this AdminSite
|
# so we can check if the related object is registered with this AdminSite
|
||||||
self.admin_site = admin_site
|
self.admin_site = admin_site
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
class MyFileField(models.FileField):
|
class MyFileField(models.FileField):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.admin import widgets
|
from django.contrib.admin import widgets
|
||||||
from django.contrib.admin.widgets import FilteredSelectMultiple, AdminSplitDateTime
|
from django.contrib.admin.widgets import (FilteredSelectMultiple,
|
||||||
from django.contrib.admin.widgets import (AdminFileWidget, ForeignKeyRawIdWidget,
|
AdminSplitDateTime, AdminFileWidget, ForeignKeyRawIdWidget, AdminRadioSelect,
|
||||||
ManyToManyRawIdWidget)
|
RelatedFieldWidgetWrapper, ManyToManyRawIdWidget)
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.db.models import DateField
|
from django.db.models import DateField
|
||||||
|
@ -31,7 +31,8 @@ class AdminFormfieldForDBFieldTests(TestCase):
|
||||||
and verify that the returned formfield is appropriate.
|
and verify that the returned formfield is appropriate.
|
||||||
"""
|
"""
|
||||||
# Override any settings on the model admin
|
# Override any settings on the model admin
|
||||||
class MyModelAdmin(admin.ModelAdmin): pass
|
class MyModelAdmin(admin.ModelAdmin):
|
||||||
|
pass
|
||||||
for k in admin_overrides:
|
for k in admin_overrides:
|
||||||
setattr(MyModelAdmin, k, admin_overrides[k])
|
setattr(MyModelAdmin, k, admin_overrides[k])
|
||||||
|
|
||||||
|
@ -314,3 +315,11 @@ class ManyToManyRawIdWidgetTest(DjangoTestCase):
|
||||||
self.assertEqual(w._has_changed([1, 2], [u'1', u'2']), False)
|
self.assertEqual(w._has_changed([1, 2], [u'1', u'2']), False)
|
||||||
self.assertEqual(w._has_changed([1, 2], [u'1']), True)
|
self.assertEqual(w._has_changed([1, 2], [u'1']), True)
|
||||||
self.assertEqual(w._has_changed([1, 2], [u'1', u'3']), True)
|
self.assertEqual(w._has_changed([1, 2], [u'1', u'3']), True)
|
||||||
|
|
||||||
|
class RelatedFieldWidgetWrapperTests(DjangoTestCase):
|
||||||
|
def test_no_can_add_related(self):
|
||||||
|
rel = models.Inventory._meta.get_field('parent').rel
|
||||||
|
w = AdminRadioSelect()
|
||||||
|
# Used to fail with a name error.
|
||||||
|
w = RelatedFieldWidgetWrapper(w, rel, admin.site)
|
||||||
|
self.assertFalse(w.can_add_related)
|
||||||
|
|
Loading…
Reference in New Issue