django-nested-inline icon indicating copy to clipboard operation
django-nested-inline copied to clipboard

Fix read-only change view

Open OskarPersson opened this issue 5 years ago • 4 comments

Fixes #109

OskarPersson avatar Feb 20 '20 17:02 OskarPersson

@OskarPersson i'm testing it, and still having the same output. I will try to debug to check if "read_only" variable is True in wrap_nested_inline_formsets

EDIT: I set up a Breakpoint at line 100 of admin.py, and found out that wrap_nested_inline_formsets() is not beign called

image

gascarcella avatar Feb 20 '20 22:02 gascarcella

Okay. Feel free to add a PR to the read-only-change-view branch if you figure something out :)

OskarPersson avatar Feb 20 '20 22:02 OskarPersson

I just had some time and took another look. Looks like the method that you've fixed is only called when a Nested Inline inside another Inline is added. After noting that, i did a test (adding a Nested Inline inside my inline).

As you can see in the result, your code worked (the nested-inline is read only), but the parent container still editable.

image

EDIT

Adding "has_change_permission" keyword argument to InlineAdminFormSet will make the Inline Formset ReadOnly as expected. Also i fixed and error in your last commit; Read only should be TRUE if has_change_permission is false.

I'm still having a problem, As you can see in the next picture, the + buttons are shown. Clicking them will pop new read-only empty entries. I will try to keep digging the solution image

EDIT @OskarPersson i tried to push my changes to this branch (also to a new one) and looks like i don't have permissions to do it. I get 403 Forbidden Error

gascarcella avatar Feb 21 '20 12:02 gascarcella

@gascarcella You need to make a fork of this repository and push to a branch there. From there you can create a PR to merge your branch into read-only-change-view. See here for more information: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork

OskarPersson avatar Feb 21 '20 13:02 OskarPersson