Escape hatch if role not required

This commit is contained in:
Oliver Walters 2021-02-26 14:26:37 +11:00
parent 0e971c468b
commit 81e9fd7a44
2 changed files with 4 additions and 1 deletions

View File

@ -63,7 +63,8 @@ class RolePermission(permissions.BasePermission):
role = getattr(view, 'role_required', None)
if not role:
raise AttributeError(f"'role_required' not specified for view {type(view).__name__}")
# Role not specified - allow access
return True
roles = []

View File

@ -373,6 +373,8 @@ class PartList(generics.ListCreateAPIView):
queryset = Part.objects.all()
role_required = 'part'
starred_parts = None
def get_serializer(self, *args, **kwargs):