| ... | @@ -100,3 +100,24 @@ class Circle(Model): |
... | @@ -100,3 +100,24 @@ class Circle(Model): |
|
|
class Meta(Model.Meta):
|
|
class Meta(Model.Meta):
|
|
|
permission_classes = [CirclePermissions]
|
|
permission_classes = [CirclePermissions]
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Custom FilterBackends
|
|
|
|
|
|
|
|
In DjangoLDP 1.3.0, permissions are changing so that `user_permissions` are not resolved on the model-level during serialization, to improve extensibility and performance
|
|
|
|
|
|
|
|
Users familiar with Django Rest Framework will be familiar with [FilterBackends](https://www.django-rest-framework.org/api-guide/filtering/#generic-filtering), which are used in a view's `filter_queryset` to remove objects which a user shouldn't see. In DjangoLDP, filter backends can be included on a permission class, and the result will be automatically applied to any views and models using the permission class
|
|
|
|
|
|
|
|
By default, `LDPPermissions` subclasses include a filter backend which applies model-level permissions (`owner_perms`, `auth_perms`, `anon_perms`) object-level permissions and group-level permissions:
|
|
|
|
```python
|
|
|
|
filter_backends = [LDPPermissionsFilterBackend]
|
|
|
|
```
|
|
|
|
|
|
|
|
This functionality can be disabled by setting the `filter_backends` of your permissions class to an empty list
|
|
|
|
```python
|
|
|
|
filter_backends = []
|
|
|
|
```
|
|
|
|
|
|
|
|
It can be extended by writing a custom `FilterBackend`, and applying it to the list
|
|
|
|
```python
|
|
|
|
filter_backends = [MyCustomFilterBackend, LDPPermissionsFilterBackend]
|
|
|
|
``` |
|
|
|
\ No newline at end of file |