Commit 2e681869 by Chif Gergő

Resolve merge conflict in gitignore and Pipfile.lock

parents 31723e86 12683431
Pipeline #820 failed with stage
in 1 minute 19 seconds
# IDEs # IDEs
.vscode/ .vscode/
<<<<<<< HEAD
.idea/ .idea/
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
...@@ -87,3 +88,10 @@ clouds.yaml ...@@ -87,3 +88,10 @@ clouds.yaml
=======
*.sqlite3
recircle/clouds.yaml
environment.sh
.idea/
__pycache__
>>>>>>> 126834316017d9a2654cc913e7eec8a47fee93e6
image: python:3.6 image: python:3.6
stages:
- lint
- test
before_script: before_script:
- pip install pipenv
- pipenv install -d
- git submodule sync --recursive - git submodule sync --recursive
- git submodule update --init --recursive - git submodule update --init --recursive
flake8: flake8:
stage: lint
script: script:
- pipenv run flake8 - pip install flake8
- flake8
test: test:
script: script:
- pip install pipenv
- pipenv install -d
- cd recircle - cd recircle
- pipenv run python manage.py test - pipenv run python manage.py test
...@@ -8,15 +8,16 @@ httpie = "*" ...@@ -8,15 +8,16 @@ httpie = "*"
flake8 = "*" flake8 = "*"
django-rest-swagger = "*" django-rest-swagger = "*"
coverage = "*" coverage = "*"
django-nose = "*"
[packages] [packages]
django = "*" django = "*"
djangorestframework = "*" djangorestframework = "*"
djoser = "*"
django-cors-headers = "*" django-cors-headers = "*"
openstacksdk = "*" openstacksdk = "*"
python-novaclient = "*" python-novaclient = "*"
keystoneauth1 = "*" keystoneauth1 = "*"
djoser = "*"
[requires] [requires]
python_version = "3.6" python_version = "3.6"
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "f991f85fb7c006559ee78cb35cc3a18089dfd0065a565f2b194c197cbf772a50" "sha256": "8cb2efb1cfa79de96297c90953faf757011ca1f1ff4784ac05226a249001e1f5"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
...@@ -500,6 +500,14 @@ ...@@ -500,6 +500,14 @@
"index": "pypi", "index": "pypi",
"version": "==4.5.4" "version": "==4.5.4"
}, },
"django-nose": {
"hashes": [
"sha256:58934a06a6932696e54c9e8af3fab49bf67ca9e9c840ad668cb7f51219808a07",
"sha256:f515d903cfaeda52c7a9198e0c8ed51563e82802b62a4e5fbd056fd830095318"
],
"index": "pypi",
"version": "==1.4.6"
},
"django-rest-swagger": { "django-rest-swagger": {
"hashes": [ "hashes": [
"sha256:48f6aded9937e90ae7cbe9e6c932b9744b8af80cc4e010088b3278c700e0685b", "sha256:48f6aded9937e90ae7cbe9e6c932b9744b8af80cc4e010088b3278c700e0685b",
...@@ -599,6 +607,14 @@ ...@@ -599,6 +607,14 @@
], ],
"version": "==0.6.1" "version": "==0.6.1"
}, },
"nose": {
"hashes": [
"sha256:9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac",
"sha256:dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a",
"sha256:f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"
],
"version": "==1.3.7"
},
"openapi-codec": { "openapi-codec": {
"hashes": [ "hashes": [
"sha256:1bce63289edf53c601ea3683120641407ff6b708803b8954c8a876fe778d2145" "sha256:1bce63289edf53c601ea3683120641407ff6b708803b8954c8a876fe778d2145"
......
...@@ -82,7 +82,9 @@ class Image(models.Model): ...@@ -82,7 +82,9 @@ class Image(models.Model):
uploaded_by_user=False, uploaded_by_user=False,
description=description description=description
) )
return new_image for attr, value in new_image.__dict__.items():
setattr(remote_image, attr, value)
return remote_image
@classmethod @classmethod
def create_from_user(cls, description, file_format, image_file, name, user): def create_from_user(cls, description, file_format, image_file, name, user):
...@@ -96,4 +98,24 @@ class Image(models.Model): ...@@ -96,4 +98,24 @@ class Image(models.Model):
uploaded_by_user=True, uploaded_by_user=True,
description=description description=description
) )
return new_image 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)
for attr, value in self.__dict__.items():
setattr(image, attr, value)
return image
def update(self, data):
for (key, value) in data.items():
setattr(self, key, value)
self.save()
return self.get()
...@@ -3,9 +3,15 @@ from rest_framework import serializers ...@@ -3,9 +3,15 @@ from rest_framework import serializers
from .models import Image from .models import Image
class ImageUpdateSerializer(serializers.Serializer):
name = serializers.CharField(required=False)
description = serializers.CharField(required=False)
class ImageSerializer(serializers.ModelSerializer): class ImageSerializer(serializers.ModelSerializer):
image_file = serializers.FileField(write_only=True) image_file = serializers.FileField(write_only=True)
file_format = serializers.CharField(max_length=10, write_only=True) file_format = serializers.CharField(max_length=10)
size = serializers.IntegerField()
class Meta: class Meta:
model = Image model = Image
...@@ -18,5 +24,7 @@ class ImageSerializer(serializers.ModelSerializer): ...@@ -18,5 +24,7 @@ class ImageSerializer(serializers.ModelSerializer):
"created_at", "created_at",
"uploaded_by_user", "uploaded_by_user",
"created_by", "created_by",
"id",
"size",
) )
read_only_fields = ("created_at", "uploaded_by_user", "created_by", "remote_id", ) read_only_fields = ("created_at", "uploaded_by_user", "created_by", "remote_id", "size", )
# from django.test import TestCase from django.test import TestCase
# Create your tests here.
class ImageTest(TestCase):
def test_test(self):
self.assertEqual("", "")
# from django.shortcuts import render # from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ViewSet
from rest_framework.response import Response from rest_framework.response import Response
from django.shortcuts import get_object_or_404
from rest_framework import status
from django.core.exceptions import ObjectDoesNotExist
from image.models import Image from image.models import Image
from image.serializers import ImageSerializer from image.serializers import ImageSerializer
from image.serializers import ImageUpdateSerializer
class ImageViewSet(ModelViewSet): class ImageViewSet(ViewSet):
serializer_class = ImageSerializer
queryset = Image.objects.all() def list(self, request):
# def list(self, request): image_list = []
# return HttpResponse("list") images = Image.objects.all()
for image in images:
image_list.append(image.get())
serializer = ImageSerializer(image_list, many=True)
return Response(serializer.data)
def create(self, request): def create(self, request):
serializer = ImageSerializer(data=request.data) serializer = ImageSerializer(data=request.data)
...@@ -26,14 +34,30 @@ class ImageViewSet(ModelViewSet): ...@@ -26,14 +34,30 @@ class ImageViewSet(ModelViewSet):
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):
# return HttpResponse("retrive") queryset = Image.objects.all()
image = get_object_or_404(queryset, pk=pk)
serializer = ImageSerializer(instance=image)
image = image.get()
serializer = ImageSerializer(instance=image)
return Response(serializer.data)
# def update(self, request, pk=None): def update(self, request, pk=None):
# return HttpResponse("update") serializer = ImageUpdateSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
queryset = Image.objects.all()
image = get_object_or_404(queryset, pk=pk)
image = image.update(serializer.validated_data)
serializer = ImageSerializer(instance=image)
return Response(serializer.data)
# def partial_update(self, request, pk=None): def partial_update(self, request, pk=None):
# return HttpResponse("patch") return self.update(request, pk)
# def destroy(self, request, pk=None): def destroy(self, request, pk=None):
# return HttpResponse("delete") try:
image = Image.objects.get(id=pk)
image.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
except ObjectDoesNotExist:
return Response(status=status.HTTP_204_NO_CONTENT)
# Generated by Django 2.2.3 on 2019-07-23 08:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('instance', '0009_auto_20190715_0929'),
('instance', '0009_auto_20190715_1354'),
]
operations = [
]
# Generated by Django 2.2.3 on 2019-07-31 12:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('instance', '0009_auto_20190715_0929'),
('instance', '0009_auto_20190715_1354'),
]
operations = [
]
# Generated by Django 2.2.3 on 2019-08-06 08:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('instance', '0010_merge_20190731_1215'),
('instance', '0010_merge_20190723_0841'),
]
operations = [
]
# from django.test import TestCase from django.test import TestCase
# Create your tests here.
class InstanceTest(TestCase):
def test_test(self):
self.assertEqual("", "")
...@@ -41,6 +41,7 @@ INSTALLED_APPS = [ ...@@ -41,6 +41,7 @@ INSTALLED_APPS = [
"djoser", "djoser",
"rest_framework_swagger", "rest_framework_swagger",
"corsheaders", "corsheaders",
"django_nose",
] ]
LOCAL_APPS = [ LOCAL_APPS = [
......
...@@ -11,3 +11,6 @@ for i in LOCAL_APPS: ...@@ -11,3 +11,6 @@ for i in LOCAL_APPS:
ADMIN_ENABLED = True ADMIN_ENABLED = True
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = LOCAL_APPS
\ No newline at end of file
# from django.test import TestCase from django.test import TestCase
# Create your tests here.
class StorageTest(TestCase):
def test_test(self):
self.assertEqual("", "")
# from django.test import TestCase from django.test import TestCase
# Create your tests here.
class TemplateTest(TestCase):
def test_test(self):
self.assertEqual("", "")
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