Ticket #6191: admin_delete.3.patch

File admin_delete.3.patch, 4.0 KB (added by nicklane, 17 years ago)
  • tests/regressiontests/views/fixtures/testdata.json

    diff -r 3a7741ce97b7 tests/regressiontests/views/fixtures/testdata.json
    a b  
    2828            "slug": "future_article",
    2929            "date_created": "3000-01-01 21:22:23"
    3030        }
    31     },
    32 
     31    },
    3332    {
    3433        "pk": 1,
    3534        "model": "views.author",
    3635        "fields": {
    3736            "name": "Boris"
    3837        }
    39     },
     38    },
     39    {
     40        "pk": 2,
     41        "model": "views.author",
     42        "fields": {
     43                "name": "Natasha"
     44        }
     45    },
     46    {
     47        "pk": 1,
     48        "model": "views.reviewedarticle",
     49        "fields": {
     50                "author": 1,
     51                "reviewer": 2,
     52                "title": "Reviewed Article"
     53                }
     54    },
    4055    {
    4156        "pk": 1,
    4257        "model": "sites.site",
     
    4459            "domain": "testserver",
    4560            "name": "testserver"
    4661        }
    47     }
     62    },
     63        {
     64                "pk": 1,
     65                "model": "auth.user",
     66                "fields": {
     67                        "username": "root",
     68                        "first_name": "Super",
     69                        "last_name": "User",
     70                        "is_active": true,
     71                        "is_superuser": true,
     72                        "is_staff": true,
     73                        "last_login": "2007-12-13 11:49:43",
     74                        "groups": [],
     75                        "user_permissions": [],
     76                        "password": "sha1$3435d$f45ddc0acfa0db94de8ba06d2546d1661dffe6db",
     77                        "email": "root@localhost",
     78                        "date_joined": "2007-12-13 11:49:43"
     79                }
     80        }
    4881]
  • tests/regressiontests/views/models.py

    diff -r 3a7741ce97b7 tests/regressiontests/views/models.py
    a b class Author(models.Model):  
    88class Author(models.Model):
    99    name = models.CharField(max_length=100)
    1010
     11    class Admin:
     12        pass
     13
    1114    def __unicode__(self):
    1215        return self.name
    1316
    1417    def get_absolute_url(self):
    1518        return '/views/authors/%s/' % self.id
    16 
    1719
    1820class Article(models.Model):
    1921    title = models.CharField(max_length=100)
    class Article(models.Model):  
    2426    def __unicode__(self):
    2527        return self.title
    2628
     29class ReviewedArticle(models.Model):
     30    title = models.CharField(max_length=100)
     31    author = models.ForeignKey(Author, related_name='authors')
     32    reviewer = models.ForeignKey(Author, related_name='reviewers')
     33
     34    class Admin:
     35        pass
     36
     37    def __unicode__(self):
     38        return self.title
  • tests/regressiontests/views/tests/__init__.py

    diff -r 3a7741ce97b7 tests/regressiontests/views/tests/__init__.py
    a b from defaults import *  
    11from defaults import *
    22from i18n import *
    33from static import *
    4 from generic.date_based import *
    5  No newline at end of file
     4from generic.date_based import *
     5from admin import *
     6 No newline at end of file
  • new file tests/regressiontests/views/tests/admin.py

    diff -r 3a7741ce97b7 tests/regressiontests/views/tests/admin.py
    - +  
     1from django.test import TestCase
     2
     3class AdminTests(TestCase):
     4    fixtures = ['testdata.json']
     5
     6    def test_delete_stage(self):
     7        "Delete stage includes all objects to be deleted"
     8        self.assertTrue(self.client.login(username='root', password='password'))
     9        response = self.client.get('/views/admin/views/author/2/delete/')
     10        self.assertContains(response, "Reviewed Article")
  • tests/regressiontests/views/urls.py

    diff -r 3a7741ce97b7 tests/regressiontests/views/urls.py
    a b urlpatterns = patterns('',  
    4444        dict(allow_future=True, slug_field='slug', **date_based_info_dict)),
    4545    (r'^date_based/archive_month/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
    4646        'django.views.generic.date_based.archive_month',
    47         date_based_info_dict),     
     47        date_based_info_dict),
     48
     49    # Admin views
     50    (r'^admin/', include('django.contrib.admin.urls')),
    4851)
Back to Top