dfunckt / django-rules

Awesome Django authorization, without the database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Many reader of an object

Bastilla123 opened this issue · comments

I have a class model class:

class Address(models.Model):
lastname = models.CharField(max_length=255, default="", )

now i want set different user read rights and other write rights and other delete rights.

I have really 0 idea how i can set my views, models etc.pp.

In your documentation there are many python code but 0 django code and when i used the mixin AutoPermissionRequiredMixin then i get error:

type object 'Address' has no attribute 'get_perm'

Hey @Bastilla123, you'll have to be more specific about the issues you're having -- maybe share some code related to what you're trying to do and also the exact code you have that triggers that error.

I guess I'm also sorry I didn't anticipate your usecase and you found the docs lacking -- maybe you can PR improvements as you figure things out so other users can benefit in the future.

Hello dfunckt,

thanks for your fast response. In many documentations there are examples in models, views, template.

I can write you for your documentation an example.

I have a model:

class Address(models.Model):
lastname = models.CharField(max_length=255, default="", )

owner or user that have permission to write can edit this addressobject. In Edit or Updateview there are a multiselect field to set user where have then permission to read and another multiselectfield to set permission to edit . When permisson ist set then i want to filter all addressobject where the user have read rights. And in listtemplate there are a icon for edit this object. I want to insert editicon when user have on this object edit this object.

That's all. Can i do this with your app? When i setup on my model then i write you the documentation.

Regards

In short, no, rules cannot do this -- it's just not made for this job. rules does not maintain state in the database and cannot filter querysets. django-guardian may work better for you.

For the longer answer, I'll have to point you to read the docs of the project again and understand them.