Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #7179 -- Changed breadcrumbs on the add page so that a …

…link to the change view is not included when the user doesn't have permission for that view. Also added tests to ensure the link is not there when it shouldn't be, and there when it should be. Thanks for the report & patch alen__ribic.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9277 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bffc238a2f83dc0573a3592baf843d1499e373a6 1 parent d323ef2
Karen Tracey authored October 24, 2008
2  django/contrib/admin/templates/admin/change_form.html
@@ -16,7 +16,7 @@
16 16
 <div class="breadcrumbs">
17 17
      <a href="../../../">{% trans "Home" %}</a> &rsaquo;
18 18
      <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo; 
19  
-     <a href="../">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
  19
+     {% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo; 
20 20
      {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
21 21
 </div>
22 22
 {% endif %}{% endblock %}
9  tests/regressiontests/admin_views/tests.py
@@ -327,6 +327,11 @@ def testAddView(self):
327 327
         # Add user may login and POST to add view, then redirect to admin root
328 328
         self.client.get('/test_admin/admin/')
329 329
         self.client.post('/test_admin/admin/', self.adduser_login)
  330
+        addpage = self.client.get('/test_admin/admin/admin_views/article/add/')
  331
+        self.failUnlessEqual(addpage.status_code, 200)
  332
+        change_list_link = '<a href="../">Articles</a> &rsaquo;'
  333
+        self.failIf(change_list_link in addpage.content,
  334
+                    'User restricted to add permission is given link to change list view in breadcrumbs.')
330 335
         post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
331 336
         self.assertRedirects(post, '/test_admin/admin/')
332 337
         self.failUnlessEqual(Article.objects.all().count(), 4)
@@ -335,6 +340,10 @@ def testAddView(self):
335 340
         # Super can add too, but is redirected to the change list view
336 341
         self.client.get('/test_admin/admin/')
337 342
         self.client.post('/test_admin/admin/', self.super_login)
  343
+        addpage = self.client.get('/test_admin/admin/admin_views/article/add/')
  344
+        self.failUnlessEqual(addpage.status_code, 200)
  345
+        self.failIf(change_list_link not in addpage.content,
  346
+                    'Unrestricted user is not given link to change list view in breadcrumbs.')
338 347
         post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
339 348
         self.assertRedirects(post, '/test_admin/admin/admin_views/article/')
340 349
         self.failUnlessEqual(Article.objects.all().count(), 5)

0 notes on commit bffc238

Please sign in to comment.
Something went wrong with that request. Please try again.