oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 83 forks source link

Incorporate django-guardian (object permissions) #74

Open Lionqueen94 opened 6 years ago

Lionqueen94 commented 6 years ago

Hi there! I'm trying to use this framework together with django guardian to be able to use object permissions instead of global ones. I was wondering if any of you have tips on how to go about this. Thanks in advance! With kind regards, Ellen

luisza commented 6 years ago

Well, basically you have three options, first using decorators and overwrite those methods.

    def decorator_create(self, viewclass):
    def decorator_detail(self, viewclass):
    def decorator_list(self, viewclass):
    def decorator_update(self, viewclass):
    def decorator_delete(self, viewclass):

Second, overwriting views see http://django-cruds-adminlte.readthedocs.io/en/latest/usage.html#overwrite-views

Also you can add a function wrapper to permission system http://django-cruds-adminlte.readthedocs.io/en/latest/usage.html#permissions

Lionqueen94 commented 6 years ago

I've been looking into this and the decorators are only called with the setup and not whenever a view is called right? So I don't see how I can use those to check for object permissions every time. Overwriting the views is definitely an option but probably the most time consuming. I can't seem to figure out how to write my own permission system, when I follow the example in the docs my own perm function never gets called...