Ticket #7758: 7758.patch

File 7758.patch, 2.3 KB (added by krzysztof.szczesny@…, 12 years ago)

form_url is now passed to change_view in admin

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 3a0ad74..83cb4eb 100644
    a b class ModelAdmin(BaseModelAdmin):  
    10091009
    10101010    @csrf_protect_m
    10111011    @transaction.commit_on_success
    1012     def change_view(self, request, object_id, extra_context=None):
     1012    def change_view(self, request, object_id, form_url='', extra_context=None):
    10131013        "The 'change' admin view for this model."
    10141014        model = self.model
    10151015        opts = model._meta
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index b0120ce..24c5d85 100644
    a b class AdminViewBasicTest(TestCase):  
    573573        except SuspiciousOperation:
    574574            self.fail("Filters should be allowed if they are defined on a ForeignKey pointing to this model")
    575575
     576class AdminViewFormUrlTest(TestCase):
     577    urls = "regressiontests.admin_views.urls"
     578    fixtures = ["admin-views-users.xml"]
     579    urlbit = "admin3"
     580
     581    def setUp(self):
     582        self.client.login(username='super', password='secret')
     583
     584    def tearDown(self):
     585        self.client.logout()
     586
     587    def testChangeFormUrlHasCorrectValue(self):
     588        """
     589        Tests whether change_view has form_url in request.context
     590        """
     591        response = self.client.get('/test_admin/%s/admin_views/section/1/' % self.urlbit)
     592        self.assertTrue('form_url' in response.context, msg='form_url not present in response.context')
     593        self.assertEqual(response.context['form_url'], 'pony')
     594
    576595class AdminJavaScriptTest(AdminViewBasicTest):
    577596    urls = "regressiontests.admin_views.urls"
    578597
  • tests/regressiontests/admin_views/urls.py

    diff --git a/tests/regressiontests/admin_views/urls.py b/tests/regressiontests/admin_views/urls.py
    index 03bfbf0..da6e2cb 100644
    a b urlpatterns = patterns('',  
    1010    (r'^test_admin/admin/secure-view/$', views.secure_view),
    1111    (r'^test_admin/admin/', include(admin.site.urls)),
    1212    (r'^test_admin/admin2/', include(customadmin.site.urls)),
     13    (r'^test_admin/admin3/', include(admin.site.urls), dict(form_url='pony')),
    1314)
Back to Top