Commit beb0809d by Belákovics Ádám

Fix flake8 errors

parent 84bace71
Pipeline #851 passed with stage
in 1 minute 21 seconds
......@@ -14,7 +14,7 @@ from authorization.mixins import AuthorizationMixin
authorization = {
"list": {"auth_type": "filter", "perms": ["use_instance"]},
"create": {"auth_type": "class", "perms": ["instance.create_instance"], "message": "No permission to create Virtual Machine."},
"create": {"auth_type": "class", "perms": ["instance.create_instance"]},
"retrieve": {"auth_type": "object", "perms": ["use_instance"]},
"destroy": {"auth_type": "object", "perms": ["administer_instance"]},
"template": {"auth_type": "object", "perms": ["use_instance"]},
......@@ -44,7 +44,8 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
def create(self, request):
# TODO: Put this logic in Mixin
if not self.has_perms_for_model(request.user, 'create'):
return Response({"error": "No permission to create Virtual Machine."}, status=status.HTTP_401_UNAUTHORIZED)
return Response({"error": "No permission to create Virtual Machine."},
status=status.HTTP_401_UNAUTHORIZED)
data = request.data
template = ImageTemplate.objects.get(pk=data["template"])
......@@ -73,7 +74,8 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
def retrieve(self, request, pk):
instance = self.get_object(pk)
if not self.has_perms_for_object(request.user, 'retrieve', instance):
return Response({"error": "No permission to access the Virtual Machine."}, status=status.HTTP_401_UNAUTHORIZED)
return Response({"error": "No permission to access the Virtual Machine."},
status=status.HTTP_401_UNAUTHORIZED)
instanceDict = InstanceSerializer(instance).data
remoteInstance = instance.get_remote_instance()
......
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 sign in to comment