Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

500 error when deleting pages from admin list view #254

Open
markfinger opened this issue Jun 22, 2017 · 1 comment
Open

500 error when deleting pages from admin list view #254

markfinger opened this issue Jun 22, 2017 · 1 comment

Comments

@markfinger
Copy link
Member

Seems to be related to everyone's old friend, MPTT: https://sentry.ixcsandbox.com/ic/agsa-staging/group/6564/

I'm getting the same errors in my local dev env, which is running latest icekit on develop

If you go into the page's admin detail, you can still delete the page. Deleting from the page admin list will fail though

CantDisableUpdates: You can't disable/delay mptt updates on Page, it's a proxy model. Call the concrete model instead.
  File "django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/utils/decorators.py", line 145, in inner
    return func(*args, **kwargs)
  File "django/contrib/admin/options.py", line 618, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "django/utils/decorators.py", line 34, in _wrapper
    return bound_func(*args, **kwargs)
  File "django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/utils/decorators.py", line 30, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "django/contrib/admin/options.py", line 1592, in changelist_view
    response = self.response_action(request, queryset=cl.get_queryset(request))
  File "django/contrib/admin/options.py", line 1335, in response_action
    response = func(self, request, queryset)
  File "mptt/admin.py", line 79, in delete_selected_tree
    with queryset.model._tree_manager.delay_mptt_updates():
  File "python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "mptt/managers.py", line 353, in delay_mptt_updates
    with self.disable_mptt_updates():
  File "python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "mptt/managers.py", line 287, in disable_mptt_updates
    % self.model.__name__
jmurty added a commit that referenced this issue Jun 23, 2017
The `make_published` and `delete_selected` bulk actions
offered on the GLAMkit pages admin listing/parent page
do not work, so this change removes them.

`make_published` provided by upstream Fluent Pages
does not work because it's for Fluent's publishing
mechanism, not GLAMkit's draft-and-copy mechanism.

`delete_selected` does not work because Pages are
polymorphic models with a proxy `Page` model at the
root, but they are also based on MPTT which requires
custom bulk delete behaviour to avoid corrupting
the MPTT tree properties on bulk deletes. MPTT's
custom behaviour does not work with proxy models.
jmurty added a commit that referenced this issue Jun 23, 2017
Relocate the publish and unpublish bulk actions
implementations and definitions to make them
available in GLAMkit's default page parent admin.
@jmurty jmurty self-assigned this Jun 23, 2017
@jmurty
Copy link
Contributor

jmurty commented Jun 23, 2017

@markfinger @cogat I have "fixed" the issue at hand by removing bulk admin actions that are broken or actively harmful for GLAMkit pages (make published, delete selected) and fixing the publish/unpublish bulk actions to be available on the parent admin page.

I don't know if fixing the bulk delete action properly is worth the (probably very high) effort. The fundamental problem is that MPTT does some custom magic on bulk deletes to avoid the tree structure getting trashed, but this magic is incompatible with admin views based on proxy models like our Pages admin. The only fix I can think of is to do a stupid-simple delete, then trigger something to try and repair any damage done to the MPTT data.

@jmurty jmurty removed their assignment Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants