core: rename GenericContentPermission into GenericContentPermissionMixinBuilder

This commit is contained in:
Antoine Bartuccio 2019-10-17 11:56:02 +02:00
parent 566dcc7aee
commit 9278419345
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -140,7 +140,7 @@ def can_view(obj, user):
return can_edit(obj, user) return can_edit(obj, user)
class GenericContentPermission(View): class GenericContentPermissionMixinBuilder(View):
""" """
Used to build permission mixins Used to build permission mixins
This view protect any child view that would be showing an object that is restricted based This view protect any child view that would be showing an object that is restricted based
@ -165,7 +165,7 @@ class GenericContentPermission(View):
self.object = self.get_object() self.object = self.get_object()
if not self.get_permission_function(self.object, request.user): if not self.get_permission_function(self.object, request.user):
raise self.raised_error raise self.raised_error
return super(GenericContentPermission, self).dispatch( return super(GenericContentPermissionMixinBuilder, self).dispatch(
request, *arg, **kwargs request, *arg, **kwargs
) )
@ -181,7 +181,9 @@ class GenericContentPermission(View):
return self2._get_queryset().filter(id__in=l_id) return self2._get_queryset().filter(id__in=l_id)
self.get_queryset = types.MethodType(get_qs, self) self.get_queryset = types.MethodType(get_qs, self)
return super(GenericContentPermission, self).dispatch(request, *arg, **kwargs) return super(GenericContentPermissionMixinBuilder, self).dispatch(
request, *arg, **kwargs
)
class CanCreateMixin(View): class CanCreateMixin(View):
@ -205,7 +207,7 @@ class CanCreateMixin(View):
raise PermissionDenied raise PermissionDenied
class CanEditPropMixin(GenericContentPermission): class CanEditPropMixin(GenericContentPermissionMixinBuilder):
""" """
This view is made to protect any child view that would be showing some properties of an object that are restricted This view is made to protect any child view that would be showing some properties of an object that are restricted
to only the owner group of the given object. to only the owner group of the given object.
@ -218,7 +220,7 @@ class CanEditPropMixin(GenericContentPermission):
permission_function = can_edit_prop permission_function = can_edit_prop
class CanEditMixin(GenericContentPermission): class CanEditMixin(GenericContentPermissionMixinBuilder):
""" """
This view makes exactly the same thing as its direct parent, but checks the group on the edit_groups field of the This view makes exactly the same thing as its direct parent, but checks the group on the edit_groups field of the
object object
@ -229,7 +231,7 @@ class CanEditMixin(GenericContentPermission):
permission_function = can_edit permission_function = can_edit
class CanViewMixin(GenericContentPermission): class CanViewMixin(GenericContentPermissionMixinBuilder):
""" """
This view still makes exactly the same thing as its direct parent, but checks the group on the view_groups field of This view still makes exactly the same thing as its direct parent, but checks the group on the view_groups field of
the object the object