Ticket #10922: patch10784-r11027-regressiontests.diff
File patch10784-r11027-regressiontests.diff, 2.7 KB (added by , 15 years ago) |
---|
-
tests/regressiontests/admin_views/tests.py
16 16 from models import Article, BarAccount, CustomArticle, EmptyModel, \ 17 17 ExternalSubscriber, FooAccount, Gallery, ModelWithStringPrimaryKey, \ 18 18 Person, Persona, Picture, Podcast, Section, Subscriber, Vodcast, \ 19 Language, Collector, Widget, Grommet, DooHickey, FancyDoodad, Whatsit 19 Language, Collector, Widget, Grommet, DooHickey, FancyDoodad, Whatsit, Category 20 20 21 21 try: 22 22 set … … 921 921 922 922 self.failUnlessEqual(Person.objects.get(name="John Mauchly").alive, False) 923 923 924 def test_list_editable_ordering(self): 925 926 Category.objects.create(id=1, order=1) 927 Category.objects.create(id=2, order=2) 928 Category.objects.create(id=3, order=0) 929 Category.objects.create(id=4, order=0) 930 931 # NB: The order values must be changed so that the items are reordered. 932 data = { 933 "form-TOTAL_FORMS": "4", 934 "form-INITIAL_FORMS": "4", 935 936 "form-0-order": "14", 937 "form-0-id": "1", 938 939 "form-1-order": "13", 940 "form-1-id": "2", 941 942 "form-2-order": "1", 943 "form-2-id": "3", 944 945 "form-3-order": "0", 946 "form-3-id": "4", 947 } 948 self.client.post('/test_admin/admin/admin_views/category/', data) 949 950 self.failUnlessEqual(Category.objects.get(id=1).order, 14) 951 self.failUnlessEqual(Category.objects.get(id=2).order, 13) 952 self.failUnlessEqual(Category.objects.get(id=3).order, 1) 953 self.failUnlessEqual(Category.objects.get(id=4).order, 0) 954 955 924 956 class AdminSearchTest(TestCase): 925 957 fixtures = ['admin-views-users','multiple-child-classes'] 926 958 -
tests/regressiontests/admin_views/models.py
326 326 class PictureAdmin(admin.ModelAdmin): 327 327 pass 328 328 329 class Category(models.Model): 330 order = models.PositiveIntegerField() 329 331 332 class Meta: 333 ordering = ('order',) 334 335 class CategoryAdmin(admin.ModelAdmin): 336 list_display = ('id', 'order') 337 list_editable = ('order',) 338 330 339 class Language(models.Model): 331 340 iso = models.CharField(max_length=5, primary_key=True) 332 341 name = models.CharField(max_length=50) … … 439 448 admin.site.register(Book, inlines=[ChapterInline]) 440 449 admin.site.register(Promo) 441 450 admin.site.register(ChapterXtra1) 451 admin.site.register(Category, CategoryAdmin)