Django-guardian: Admin integration: Unable to get working

Created on 16 May 2017  Â·  6Comments  Â·  Source: django-guardian/django-guardian

Are there any gotchas for Admin integration? I'm able to get the .has_perm checks to pass correctly using the examples in the docs, but the admin site passes 403 forbidden when trying to use them. I've set up GuardedModelAdmin in my admin.py page as per the docs. Example code: (I'm assuming this type of looping through every user and object is how you set rules; the docs only show doing it with single objects)

for user in User.objects.all():
    for person in Person.objects.all():
        # Only allow view/change/edit/add for people in the same section as the user.
        if person.section == user.person.section:
            UserObjectPersmission.objects.assign('change_person', user, obj=person)
            UserObjectPersmission.objects.assign('add_person', user, obj=person)
            UserObjectPersmission.objects.assign('delete_person', user, obj=person)

# These checks work as intended, but the admin page doesn't provide links to view/edit Person objects, 
and manually going to the url results in 403: Forbidden.
section_a_user.has_perm('myapp.add_person', section_a_person)  # True
section_a_user.has_perm('myapp.add_person', section_b_person)  # False

All 6 comments

I need to integrate in the admin panel the multiple choices for groups and members.

screen shot 2017-11-28 at 09 40 20

Make a better user experience

If i add manually the groups and member it works fine
screen shot 2017-11-28 at 09 57 16

Thanks for support

@Allan-Nava , your problem is a separate problem from the initial problem in this issue.

Sorry, but how can i handle and administrate this functionality?

Thanks for support

2017-11-28 16:13 GMT+01:00 Adam Dobrawy notifications@github.com:

@Allan-Nava https://github.com/allan-nava , your problem is a separate
problem from the initial problem in this issue.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/django-guardian/django-guardian/issues/506#issuecomment-347554200,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVdMg8NrGik7wcSewjluFyZtu3qPVyE5ks5s7CL-gaJpZM4NcH1s
.

@Allan-Nava , create a seperate issue instead of cluttering other issues that are not related to your problem.

Sorry @ad-m,
I have create an issue #536 .
I don't understand why it needs to specify the object(group) when the breadcrumb specify the group. I attach the example
screen shot 2017-11-28 at 16 46 42

Hi, do we have any update on the actual issue? I'm not getting it to work too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukaszb picture lukaszb  Â·  14Comments

xuhcc picture xuhcc  Â·  10Comments

brianmay picture brianmay  Â·  16Comments

BenDevelopment picture BenDevelopment  Â·  5Comments

Allan-Nava picture Allan-Nava  Â·  35Comments