Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#30097 closed Bug (fixed)

InlineModelAdmin.has_add_permission() broke backwards compatibility by requiring obj argument

Reported by: Maxim Zemskov Owned by: Maxim Zemskov
Component: contrib.admin Version: 2.1
Severity: Release blocker Keywords: contrib.admin, admin, inline
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

InlineModelAdmin.has_add_permission() requires obj argument:

def has_add_permission(self, request, obj):
    if self.opts.auto_created:
        return self.has_view_permission(request, obj)
    return super().has_add_permission(request)

But implementation of InlineModelAdmin._has_add_permission() says obj will be required in django 3.0:

def _has_add_permission(self, request, obj):
    # RemovedInDjango30Warning: obj will be a required argument.
    args = get_func_args(self.has_add_permission)
    return self.has_add_permission(request, obj) if 'obj' in args else self.has_add_permission(request)

So, code will crush at self.has_add_permission(request) in return statement with missing 1 required positional argument: 'obj'.

Change History (8)

comment:1 by Maxim Zemskov, 6 years ago

Has patch: set
Version 0, edited 6 years ago by Maxim Zemskov (next)

comment:2 by Carlton Gibson, 6 years ago

Cc: Jon Dufresne added
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

This looks related to #27991. The new test case on the PR looks right and fails without the patch, so pending review I'm going to accept this as a Release Blocker on v2.1.

comment:3 by Maxim Zemskov, 6 years ago

Owner: changed from nobody to Maxim Zemskov
Status: newassigned

comment:4 by Tim Graham, 6 years ago

Cc: Jon Dufresne removed
Summary: InlineModelAdmin.has_add_permission() requires obj argumentInlineModelAdmin.has_add_permission() broke backwards compatibility by requiring obj argument
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 3c01fe30:

Fixed #30097 -- Made 'obj' arg of InlineModelAdmin.has_add_permission() optional.

Restored backwards compatibility after refs #27991.
Regression in be6ca89396c031619947921c81b8795d816e3285.

comment:6 by Tim Graham <timograham@…>, 6 years ago

In 3df13847:

[2.1.x] Fixed #30097 -- Made 'obj' arg of InlineModelAdmin.has_add_permission() optional.

Restored backwards compatibility after refs #27991.
Regression in be6ca89396c031619947921c81b8795d816e3285.

Backport of 3c01fe30f3dd4dc1c8bb4fec816bd277d1ae5fa6 from master.

comment:7 by Tim Graham <timograham@…>, 6 years ago

In ee9bd8c:

[2.2.x] Refs #30097 -- Fixed typos in InlineModelAdmin.has_add_permission() deprecation comments.

comment:8 by Tim Graham <timograham@…>, 6 years ago

In 1bb31708:

[2.1.x] Refs #30097 -- Fixed typos in InlineModelAdmin.has_add_permission() deprecation comments.

Backport of ee9bd8c31024ec424157798b2a60a7f52f9353ee from stable/2.2.x.

Note: See TracTickets for help on using tickets.
Back to Top