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