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
Add/Remove member only for a specific group #533
Comments
No problem, you have to create such permissions and manually implement access control with django-guardian support. |
Access control like? How can I implement this functionality? |
Django-guardian is an access control library for any object. Such object may also be groups. See access control in example project. See https://github.com/django-guardian/django-guardian/blob/devel/example_project/articles/views.py#L35 . |
Perfect! This is my snippet code:
I need to have the permission to add/remove for all users of the group. |
I don't know where do you have a problem. You need something like: class ProtectedGroupUpdateView(PermissionRequiredMixin, GroupUpdateView):
permission_required = ['change_group', ]
... and assign permission to group when created. |
I tried to add the permission "can add member", but so it is possible for all groups and not for staff. |
I am not sure what do you mean. The django-guardian privileges are always granted to users or groups of users. It is not possible to grant privileges based on role or special conditions. If you want to grant staff members permission to manage the "X" group, create a "Staff" group, add staff members to it, add the "X" group, and give the "Staff" group the permission to manage "X" group. |
I would need a user who belongs to a group Sorry for my bad english |
Unfortunately, I can not understand your expectations. Examine the example project carefully. This should be sufficient in such a case. |
|
I actually need to make sure that a user who belongs to a group "x" would be able to add or remove only other users from his own group |
@Allan-Nava , The django-guardian privileges are always granted to users or groups of users. It is not possible to grant privileges based on role or special conditions. If you want users to manage their groups, give the group permission to manage that group as an object. Do you understand how to assign & check "X" group permission to manage "X" group? |
It should be like netflix(but all members have possibility to login): every user should have a personal group where he can add or remove the users according to what he preferes. The issue is that if you give this permission add users, and this influences all the other groups, not users who belong to that one |
It's definitly not true. This sentence is true for Django core. If you are using the correct Django-guardian permission granted to the management group X for the group X apply only to group X. Just as in an example project, giving the right to manage a particular article does not mean that other articles can be edited by that user. |
I want to create a single permission that allows to all the users to add other people to their membership group. Everytime i create a new user, with his membership group 'X', I want a new permission to be created , called 'Can add group for X', and that permission have to have the group 'X' as object. Like this:
|
Abnormal is the creation of a thousand permission. |
Ok perfect, but in the templare view how can i check? {{ perms.groups_manager.canaddmemberx2}} |
@Allan-Nava , again, examine the example project carefully, especially templates and RTFD. |
@ad-m Ok thanks, so my snippet code:
|
@ad-m I tried this code, but I got exception.
|
@Allan-Nava , what is not clear to you in the error message? |
@ad-m
|
@Allan-Nava , what is not clear to you in the error message? |
@ad-m I don't understand where is the problem |
@Allan-Nava , there is no this kind of permission. Read the docs what permission exists. |
Ok i read, but I need to create N permission for N groups/users when I create a new user?
|
As said before:
One permission per action type. |
Ok, but how can I create the general permission? |
As Django core docs said. Linked above. |
Ok, I use Django Groups Manager: This is my model Group:
And this is my model Profile:
|
Django-guardian is per single object permission management, so grant single user/group permission to single object. |
Ok perfect, but is still not working though I added the permission in model Group |
What doesn't work? |
This line:
instance is the user object but I add into the Group model the permission
I used this django-groups-manager |
I'm stupid, I have to makemigrations and migrate:
Thanks for patience 👍 @ad-m But in the template view, how can I check ? |
Hi,I need to have a permission, that let the users of a specific group to add, delete or remove only for the belonging group.
The text was updated successfully, but these errors were encountered: