Ticket #7758: 7758_2.patch

File 7758_2.patch, 2.7 KB (added by krzysztof.szczesny@…, 13 years ago)

same as previous but works this time :P

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 3a0ad74..b3e6077 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
    class ModelAdmin(BaseModelAdmin):  
    10971097            'app_label': opts.app_label,
    10981098        }
    10991099        context.update(extra_context or {})
    1100         return self.render_change_form(request, context, change=True, obj=obj)
     1100        return self.render_change_form(request, context, change=True, obj=obj, form_url=form_url)
    11011101
    11021102    @csrf_protect_m
    11031103    def changelist_view(self, request, extra_context=None):
  • 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