Django

Code

Show
Ignore:
Timestamp:
07/02/08 03:32:55 (6 months ago)
Author:
simon
Message:

newforms-admin: custom URL handling in admin now redirects to add trailing slash if needed - this fixes several bugs that occurred when you navigated to an admin page and omitted the trailing slash.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/django/contrib/admin/sites.py

    r7737 r7825  
    101101        `url` is the remainder of the URL -- e.g. 'comments/comment/'. 
    102102        """ 
     103        if request.method == 'GET' and not request.path.endswith('/'): 
     104            return http.HttpResponseRedirect(request.path + '/') 
     105         
    103106        # Figure out the admin base URL path and stash it for later use 
    104107        self.root_path = re.sub(re.escape(url) + '$', '', request.path) 
  • django/branches/newforms-admin/tests/regressiontests/admin_views/tests.py

    r7708 r7825  
    7575                     'password': 'secret'} 
    7676            
    77          
     77    def testTrailingSlashRequired(self): 
     78        """ 
     79        If you leave off the trailing slash, app should redirect and add it. 
     80        """ 
     81        self.client.post('/test_admin/admin/', self.super_login) 
     82         
     83        request = self.client.get( 
     84            '/test_admin/admin/admin_views/article/add' 
     85        ) 
     86        self.assertRedirects(request, 
     87            '/test_admin/admin/admin_views/article/add/' 
     88        ) 
     89     
    7890    def testLogin(self): 
    7991        """