mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #6191, #11296 -- Modified the admin deletion confirmation page to use the same object collection scheme as the actual deletion. This ensures that all objects that may be deleted are actually deleted, and that cyclic display problems are avoided. Thanks to carljm for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12598 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
126ca330e2
commit
e12b3199d0
10 changed files with 415 additions and 141 deletions
|
@ -2,16 +2,69 @@ from datetime import datetime
|
|||
import unittest
|
||||
|
||||
from django.db import models
|
||||
from django.utils.formats import localize
|
||||
from django.test import TestCase
|
||||
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.util import display_for_field, label_for_field, lookup_field
|
||||
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
|
||||
from django.contrib.sites.models import Site
|
||||
from django.utils.formats import localize
|
||||
from django.contrib.admin.util import NestedObjects
|
||||
|
||||
from models import Article
|
||||
from models import Article, Count
|
||||
|
||||
|
||||
class NestedObjectsTests(TestCase):
|
||||
"""
|
||||
Tests for ``NestedObject`` utility collection.
|
||||
|
||||
"""
|
||||
def setUp(self):
|
||||
self.n = NestedObjects()
|
||||
self.objs = [Count.objects.create(num=i) for i in range(5)]
|
||||
|
||||
def _check(self, target):
|
||||
self.assertEquals(self.n.nested(lambda obj: obj.num), target)
|
||||
|
||||
def _add(self, obj, parent=None):
|
||||
# don't bother providing the extra args that NestedObjects ignores
|
||||
self.n.add(None, None, obj, None, parent)
|
||||
|
||||
def test_unrelated_roots(self):
|
||||
self._add(self.objs[0])
|
||||
self._add(self.objs[1])
|
||||
self._add(self.objs[2], self.objs[1])
|
||||
|
||||
self._check([0, 1, [2]])
|
||||
|
||||
def test_siblings(self):
|
||||
self._add(self.objs[0])
|
||||
self._add(self.objs[1], self.objs[0])
|
||||
self._add(self.objs[2], self.objs[0])
|
||||
|
||||
self._check([0, [1, 2]])
|
||||
|
||||
def test_duplicate_instances(self):
|
||||
self._add(self.objs[0])
|
||||
self._add(self.objs[1])
|
||||
dupe = Count.objects.get(num=1)
|
||||
self._add(dupe, self.objs[0])
|
||||
|
||||
self._check([0, 1])
|
||||
|
||||
def test_non_added_parent(self):
|
||||
self._add(self.objs[0], self.objs[1])
|
||||
|
||||
self._check([0])
|
||||
|
||||
def test_cyclic(self):
|
||||
self._add(self.objs[0], self.objs[2])
|
||||
self._add(self.objs[1], self.objs[0])
|
||||
self._add(self.objs[2], self.objs[1])
|
||||
self._add(self.objs[0], self.objs[2])
|
||||
|
||||
self._check([0, [1, [2]]])
|
||||
|
||||
|
||||
class UtilTests(unittest.TestCase):
|
||||
def test_values_from_lookup_field(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue