2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-12 07:54:14 +00:00
Oliver Walters
2019-05-06 21:49:01 +10:00
parent eec0fc34d2
commit c88149b9aa
3 changed files with 71 additions and 1 deletions

View File

@ -7,6 +7,7 @@ from __future__ import unicode_literals
from django.shortcuts import get_object_or_404
from django.http import JsonResponse
from django.urls import reverse_lazy
from django.views.generic import DetailView, ListView
from django.forms.models import model_to_dict
@ -268,6 +269,31 @@ class PartImage(AjaxUpdateView):
}
class UploadPartImage(AjaxView):
""" View for uploading a Part image """
model = Part
def post(self, request, *args, **kwargs):
try:
part = Part.objects.get(pk=kwargs.get('pk'))
except Part.DoesNotExist:
error_dict = {
'error': 'Part not found',
}
return JsonResponse(error_dict, status=404)
print("Files:", request.FILES)
uploaded_file = request.FILES['file']
response_dict = {
'success': 'File was uploaded successfully',
}
return JsonResponse(response_dict, status=200)
class PartEdit(AjaxUpdateView):
""" View for editing Part object """