Skip to content

Fix read-only change view#110

Open
OskarPersson wants to merge 4 commits into
masterfrom
read-only-change-view
Open

Fix read-only change view#110
OskarPersson wants to merge 4 commits into
masterfrom
read-only-change-view

Conversation

@OskarPersson

Copy link
Copy Markdown
Owner

Fixes #109

@gascarcella

gascarcella commented Feb 20, 2020

Copy link
Copy Markdown

@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

@OskarPersson

Copy link
Copy Markdown
Owner Author

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

@gascarcella

gascarcella commented Feb 21, 2020

Copy link
Copy Markdown

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

@OskarPersson

Copy link
Copy Markdown
Owner Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE] 403:Forbidden instead of Read-Only View when has_change_permission() returns False

2 participants