Commit 09c74eb0 by Belákovics Ádám

Fix flake8 and other problems

parent 22dbafd0
Pipeline #824 passed with stage
in 1 minute 20 seconds
from django.contrib import admin
# Register your models here.
......@@ -27,7 +27,7 @@ class AuthorizationMixin():
def has_perms_for_model(self, user, method, model):
auth_params = self.authorization[method]
if auth_params:
if auth_params:
pass
else:
logger.error(f"Invalid method for authorization: {method}")
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
from instance.models import Instance
from guardian.shortcuts import get_objects_for_user
test_user = User.objects.get(username="test")
get_objects_for_user(test_user, "use_instance", Instance)
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
......@@ -51,8 +51,6 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
# flavor = Flavor.objects.get(pk=data["flavor"])
# lease = Lease.objects.get(pk=data["lease"])
newInstance = Instance.create_instance_from_template(
params={"name": data["name"],
"description": data["description"],
......@@ -79,14 +77,14 @@ class InstanceViewSet(AuthorizationMixin, ViewSet):
return Response(merged_dict)
# I think we need separate actions for this behaviour because of the access control - BAdam
# def update(self, request, pk, format=None):
# instance = self.get_object(pk)
# serializer = InstanceSerializer(instance, data=request.data)
# if serializer.is_valid():
# serializer.save()
# return Response(serializer.data)
# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def update(self, request, pk, format=None):
instance = self.get_object(pk)
serializer = InstanceSerializer(instance, data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, pk, format=None):
instance = self.get_object(pk)
......
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