diff --git a/djangoldp/permissions.py b/djangoldp/permissions.py index cd40ca0bd6730261ac13642a63ddd774c2d79dfc..df77f65ff4b4faadbd55a1692c5e9c3e6c1e4986 100644 --- a/djangoldp/permissions.py +++ b/djangoldp/permissions.py @@ -121,7 +121,7 @@ class ReadAndCreate(LDPBasePermission): """Users can only view and create""" permissions = {'view', 'add'} -class LDPPermissions(DjangoObjectPermissions, LDPBasePermission): +class ACLPermissions(DjangoObjectPermissions, LDPBasePermission): """Permissions based on the rights given in db, on model for container requests or on object for resource requests""" filter_backend = ObjectPermissionsFilter perms_map = permission_map diff --git a/djangoldp/tests/djangoldp_urls.py b/djangoldp/tests/djangoldp_urls.py index 9299af9756de1d5208ca485e4ce1b3b108d79cc1..6f1da2f517d41e6e7e84db1d7e4db329f93fba48 100644 --- a/djangoldp/tests/djangoldp_urls.py +++ b/djangoldp/tests/djangoldp_urls.py @@ -1,15 +1,13 @@ from django.urls import path from djangoldp.tests.models import Message, Conversation, Dummy, PermissionlessDummy, Task, DateModel, LDPDummy -from djangoldp.permissions import LDPPermissions,AnonymousReadOnly,ReadAndCreate,OwnerPermissions +from djangoldp.permissions import ACLPermissions from djangoldp.views import LDPViewSet urlpatterns = [ path('messages/', LDPViewSet.urls(model=Message, fields=["@id", "text", "conversation"], nested_fields=['conversation'])), path('tasks/', LDPViewSet.urls(model=Task)), - # # path('dates/', LDPViewSet.urls(model=DateModel)), path('conversations/', LDPViewSet.urls(model=Conversation, nested_fields=["message_set", "observers"])), path('dummys/', LDPViewSet.urls(model=Dummy, lookup_field='slug',)), - # path('ldpdummys/', LDPViewSet.urls(model=LDPDummy, nested_fields=['anons'], permission_classes=[AnonymousReadOnly,ReadAndCreate|OwnerPermissions])), - path('permissionless-dummys/', LDPViewSet.urls(model=PermissionlessDummy, lookup_field='slug', permission_classes=[LDPPermissions])), + path('permissionless-dummys/', LDPViewSet.urls(model=PermissionlessDummy, lookup_field='slug', permission_classes=[ACLPermissions])), ] diff --git a/djangoldp/tests/models.py b/djangoldp/tests/models.py index 11fb55682e4068269798528f27093e64de8ec12a..6a6548ada34087dee709b086856df5122cca1679 100644 --- a/djangoldp/tests/models.py +++ b/djangoldp/tests/models.py @@ -4,7 +4,7 @@ from django.db import models from django.utils.datetime_safe import date from djangoldp.models import Model -from djangoldp.permissions import LDPPermissions, AuthenticatedOnly, ReadOnly, \ +from djangoldp.permissions import ACLPermissions, AuthenticatedOnly, ReadOnly, \ ReadAndCreate, AnonymousReadOnly, OwnerPermissions, InheritPermissions from .permissions import Only2WordsForToto, ReadOnlyStartsWithA @@ -193,7 +193,7 @@ class PermissionlessDummy(Model): class Meta(Model.Meta): ordering = ['pk'] - permission_classes = [LDPPermissions] + permission_classes = [ACLPermissions] lookup_field='slug' permissions = (('custom_permission_permissionlessdummy', 'Custom Permission'),) @@ -264,7 +264,7 @@ class Circle(Model): ordering = ['pk'] auto_author = 'owner' depth = 1 - permission_classes = [AnonymousReadOnly,ReadAndCreate|OwnerPermissions|LDPPermissions] + permission_classes = [AnonymousReadOnly,ReadAndCreate|OwnerPermissions|ACLPermissions] permission_roles = { 'members': {'perms': ['view'], 'add_author': True}, 'admins': {'perms': ['view', 'change', 'control'], 'add_author': True}, @@ -283,7 +283,7 @@ class RestrictedCircle(Model): class Meta(Model.Meta): ordering = ['pk'] auto_author = 'owner' - permission_classes = [LDPPermissions] + permission_classes = [ACLPermissions] permission_roles = { 'members': {'perms': ['view'], 'add_author': True}, 'admins': {'perms': ['view', 'change', 'control'], 'add_author': True}, @@ -370,7 +370,7 @@ class MyAbstractModel(Model): class Meta(Model.Meta): ordering = ['pk'] - permission_classes = [LDPPermissions] + permission_classes = [ACLPermissions] abstract = True rdf_type = "wow:defaultrdftype" @@ -378,4 +378,4 @@ class MyAbstractModel(Model): class NoSuperUsersAllowedModel(Model): class Meta(Model.Meta): ordering = ['pk'] - permission_classes = [LDPPermissions] \ No newline at end of file + permission_classes = [ACLPermissions] \ No newline at end of file diff --git a/docs/create_model.md b/docs/create_model.md index 63a9314febc26e063818e07d6059677488c24473..90039cd07f0c88b54b545649377bfe804e4bf073 100644 --- a/docs/create_model.md +++ b/docs/create_model.md @@ -331,7 +331,7 @@ class MyModel(models.Model): author_user = models.ForeignKey(settings.AUTH_USER_MODEL) related = models.ForeignKey(SomeOtherModel) class Meta: - permission_classes = [InheritPermissions, AuthenticatedOnly&(ReadOnly|OwnerPermissions|LDPPermissions)] + permission_classes = [InheritPermissions, AuthenticatedOnly&(ReadOnly|OwnerPermissions|ACLPermissions)] inherit_permissions = 'related owner_field = 'author_user' auto_author_field = 'profile' @@ -339,7 +339,7 @@ class MyModel(models.Model): ### Role based permissions -Permissions can also be defind through roles defined in the Meta option `permission_roles`. When set, DjangoLDP will automatically create groups and assigne permissions on these groups when the object is created. The author can also be added automatically using the option `add_author`. The permission class `LDPPermissions` must be applied in order for the data base permission to be taken into account. +Permissions can also be defind through roles defined in the Meta option `permission_roles`. When set, DjangoLDP will automatically create groups and assigne permissions on these groups when the object is created. The author can also be added automatically using the option `add_author`. The permission class `ACLPermissions` must be applied in order for the data base permission to be taken into account. ```python class Circle(Model): @@ -350,7 +350,7 @@ class Circle(Model): class Meta(Model.Meta): auto_author = 'owner' - permission_classes = [LDPPermissions] + permission_classes = [ACLPermissions] permission_roles = { 'members': {'perms': ['view'], 'add_author': True}, 'admins': {'perms': ['view', 'change', 'control'], 'add_author': True},