Commit bdd288f8 authored by Jean-Baptiste's avatar Jean-Baptiste

update: Add a way to customize User and Group permissions classes

parent 83f3e734
Pipeline #4505 passed with stage
in 27 seconds
......@@ -81,6 +81,15 @@ Because `/user/1` is an account of an external user with webid `https://theother
djangoldp_account use `django.contribs.auth.User` and mange its serialization into JsonLd format
If you need to extends it with you own relation use `USER_NESTED_FIELDS` on settings.py :
````
```
USER_NESTED_FIELDS=['skills']
```
\ No newline at end of file
```
Also, if you need to override the default permission (AnonymousReadOnly) on User or Group use :
```
GROUP_PERMISSION_CLASSES=[CustomGroupPermission]
USER_PERMISSION_CLASSES=[CustomUserPermission]
```
On the server settings (should be override only one time)
......@@ -17,16 +17,17 @@ user_fields = ['@id', 'first_name', 'groups', 'last_name', 'username', 'email',
user_nested_fields = ['account', 'groups', 'chatProfile']
for dldp_module in djangoldp_modules:
try:
user_fields += import_module(dldp_module + '.settings').USER_NESTED_FIELDS
user_nested_fields += import_module(dldp_module + '.settings').USER_NESTED_FIELDS
module_user_nested_fields = import_module(dldp_module + '.settings').USER_NESTED_FIELDS
user_fields += module_user_nested_fields
user_nested_fields += module_user_nested_fields
except:
pass
urlpatterns = [
url(r'^groups/',
LDPViewSet.urls(model=Group, fields=['@id', 'name', 'user_set'], permission_classes=[AnonymousReadOnly])),
LDPViewSet.urls(model=Group, fields=['@id', 'name', 'user_set'], permission_classes=getattr(settings, 'GROUP_PERMISSION_CLASSES', [AnonymousReadOnly]))),
url(r'^users/',
LDPViewSet.urls(model=settings.AUTH_USER_MODEL, fields=user_fields, permission_classes=[AnonymousReadOnly],
LDPViewSet.urls(model=settings.AUTH_USER_MODEL, fields=user_fields, permission_classes=getattr(settings, 'USER_PERMISSION_CLASSES', [AnonymousReadOnly]),
nested_fields=user_nested_fields)),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^accounts/', LDPViewSet.urls(model=Account, permission_classes=[AnonymousReadOnly])),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment