Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix read-only change view #110

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

OskarPersson
Copy link
Owner

Fixes #109

@gascarcella
Copy link

gascarcella commented Feb 20, 2020

@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
Owner Author

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

@gascarcella
Copy link

gascarcella commented Feb 21, 2020

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
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