strategies for adding a custom group permission

29 views
Skip to first unread message

Larry Martell

unread,
Nov 8, 2016, 9:56:56 AM11/8/16
to django...@googlegroups.com
I posed a question yesterday asking how to separate the group editing
permissions from the permission to edit a new custom group permission
that I added. I did not get any replies to that and in researching it
I am thinking perhaps that is not possible. So I want to pose the
question differently - here is my use case:

I need to add a configurable data filter that will be used in my app
and I want that filter to be specifiable at the django group level. I
want to be able to give users permission, both at the group level and
the user level, to edit this filter. But I want that permission to be
separate and distinct from the general change group permission.

Anyone have a method to do this?

Matthew Pava

unread,
Nov 8, 2016, 10:00:42 AM11/8/16
to django...@googlegroups.com
Hi Larry,

I would just write my own custom view using my own custom forms to do this. I would add my own custom permissions to apply to my custom view. I would avoid using DjangoAdmin to handle such a customized use case.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACwCsY5obPixfPnFtZxR3z46d5nbdqvFV5%2B-uz9K9XF-RxHLww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Melvyn Sopacua

unread,
Nov 9, 2016, 8:32:37 AM11/9/16
to django...@googlegroups.com
On Tuesday 08 November 2016 09:55:51 Larry Martell wrote:

> I need to add a configurable data filter that will be used in my app
> and I want that filter to be specifiable at the django group level. I
> want to be able to give users permission, both at the group level and
> the user level, to edit this filter. But I want that permission to be
> separate and distinct from the general change group permission.
>
> Anyone have a method to do this?

By design, you cannot relax permissions. You can grant and re-deny
though or re-implement how change permission is determined. Wether you
can determine "I should grant Change permission, even though the group
doesn't have it, because the request is for editing the filter *only*"
is tricky.

To grant change permission and then override it later, use the "user
passes test" mechanism:
<https://docs.djangoproject.com/en/1.10/topics/auth/default/#django.contrib.auth.decorators.user_passes_test>

--
Melvyn Sopacua

Larry Martell

unread,
Nov 9, 2016, 12:47:26 PM11/9/16
to django...@googlegroups.com
I was able to do this by adding a custom admin index page, change_form
and some javascript.
Reply all
Reply to author
Forward
0 new messages