If Page admin has multiple inline admins, the page breaks #1487

kux opened this Issue Oct 18, 2012 · 0 comments


None yet

2 participants

kux commented Oct 18, 2012

Reproduced on django-cms 2.3.3

Steps to reproduce:

  1. Install an app that adds additional content on the Page admin (ex: https://github.com/pbs/django-cms-pagetags)
    -- OR--
    Fork django-cms and add an additional InlineModelAdmin to the Page admin
  2. Create a user using the 'Users (page)' section of the admin interface, and tick all the permissions (Page permissions, User & Group permissions, Page permissions management)
  3. Give the new user 'Page permissions' to a specific page, BUT DON"T GIVE HIM 'Can change permissions'
  4. Log in again with thew newly created user
  5. Try to open the page to which you gave permissions to the new users at step 3

Expected: page admin opens
KeyError at /admin/cms/page/119/
Request Method: GET
Request URL: http://pbs.org/admin/cms/page/119/

Why this happens:
Looking at django.contrib.admin.options.ModelAdmin.change_view

    inline_admin_formsets = []
    for inline, formset in zip(inline_instances, formsets):
        fieldsets = list(inline.get_fieldsets(request, obj))

Each inline admin has an associated formset.
Now looking at cms.admin.pageadmin.PageAdmin.get_formsets. This method excludes the formset that belongs to PagePermissionInlineAdmin.

Because of the excluded formset, because there will be an offset between the inline admins and their corresponding formsets, the page will obviously break.

@digi604 digi604 closed this Dec 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment