Re: superuser having all permissions makes perm checking messy

2017-03-20 Thread guettli
Am Samstag, 18. März 2017 06:00:14 UTC+1 schrieb Melvyn Sopacua: > > On Thursday 16 March 2017 02:29:21 guettli wrote: > > > > > In our custom code we already skip check1 and do only check2. > > > > Why do you even do these checks? > Good question. I want to get all users which have a given

Re: superuser having all permissions makes perm checking messy

2017-03-17 Thread Melvyn Sopacua
On Thursday 16 March 2017 02:29:21 guettli wrote: > In our custom code we already skip check1 and do only check2. Why do you even do these checks? There's a view decorator and class-based view mixin. All you need to do is make good groups and users and the rest follows. If you want to define a

Re: superuser having all permissions makes perm checking messy

2017-03-17 Thread James Schneider
On Mar 17, 2017 1:53 AM, "guettli" wrote: It's not a problem. It something else. I am missing the right words ... I know how to use conditions in python or the equivalent sql operations. I am sure that my code would be simpler if the superuser would not have all permissions. If you're coding y

Re: superuser having all permissions makes perm checking messy

2017-03-17 Thread Andréas Kühne
I also think you are talking about to different things. Thomas, I get a feeling you are not using the default permissions system built into django, but rather using your own. Regardless of how you do it - you could just add a method on the user object that is : def has_permission(self, permission

Re: superuser having all permissions makes perm checking messy

2017-03-17 Thread guettli
It's not a problem. It something else. I am missing the right words ... I know how to use conditions in python or the equivalent sql operations. I am sure that my code would be simpler if the superuser would not have all permissions. I am sure if I want to go this way, since django does it diff

Re: superuser having all permissions makes perm checking messy

2017-03-16 Thread Jani Tiainen
Hi, You don't need to check for superuser explicitly Django does that when you check does user have a permission and returns true for all perm checks. So it's just simple check. Unless you meant something else, maybe giving a sample code would help understand your problem better. On 16.03.

superuser having all permissions makes perm checking messy

2017-03-16 Thread guettli
This is not a question, just a feeling. I want to know if you feel the same pain. Checking for permission in django is done in two steps: check1: check if user is superuser, then user is allowed. check2: check if user has the given permission. This OR is solvable. It's easy to code. It is jus