Commit 3ef0798e by Bodor Máté

Fix flake8 error

parent 65508250
Pipeline #794 failed with stages
in 59 seconds
......@@ -101,12 +101,12 @@ class Image(models.Model):
for attr, value in new_image.__dict__.items():
setattr(remote_image, attr, value)
return remote_image
def delete(self):
interface = OpenstackImageManager(settings.CONNECTION)
if interface.delete(self.remote_id):
super().delete()
def get(self):
interface = OpenstackImageManager(settings.CONNECTION)
image = interface.get(self.remote_id)
......@@ -118,4 +118,4 @@ class Image(models.Model):
for (key, value) in data.items():
setattr(self, key, value)
self.save()
return self.get()
\ No newline at end of file
return self.get()
# from django.shortcuts import render
from rest_framework.viewsets import ViewSet
from rest_framework.response import Response
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from rest_framework import status
from django.core.exceptions import ObjectDoesNotExist
......@@ -34,7 +33,7 @@ class ImageViewSet(ViewSet):
)
serializer = ImageSerializer(instance=new_image)
return Response(serializer.data)
def retrieve(self, request, pk=None):
queryset = Image.objects.all()
image = get_object_or_404(queryset, pk=pk)
......@@ -43,7 +42,6 @@ class ImageViewSet(ViewSet):
serializer = ImageSerializer(instance=image)
return Response(serializer.data)
def update(self, request, pk=None):
serializer = ImageUpdateSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
......
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