def form_valid(self, form): files = self.request.FILES barcode = form.cleaned_data['barcode'] database_files = upload_files(barcode, [file for file_key in files.keys() for file in files.getlist(file_key)]) return HttpResponseRedirect(reverse('view', kwargs={'barcode': database_files[0].barcode}))
def upload_by_barcode(request, barcode): files = request.FILES database_files = upload_files(barcode, [ file for file_key in files.keys() for file in files.getlist(file_key) ]) return HttpResponseRedirect( reverse('view', kwargs={'barcode': database_files[0].barcode}))
def form_valid(self, form): files = self.request.FILES barcode = form.cleaned_data['barcode'] database_files = upload_files(barcode, [ file for file_key in files.keys() for file in files.getlist(file_key) ]) return HttpResponseRedirect( reverse('view', kwargs={'barcode': database_files[0].barcode}))
def create(self, request, *args, **kwargs): barcode = request.data.get('barcode') files = request.FILES try: validate_barcode(barcode) database_files = upload_files(barcode, [file for file in files.values()]) return Response({"results": [FileSerializer(database_file).data for database_file in database_files]}, status=client.CREATED) except ValidationError: return Response({'error': 'Invalid barcode', 'barcode': barcode}, status=client.UNPROCESSABLE_ENTITY)
def upload_by_barcode(request, barcode): files = request.FILES database_files = upload_files(barcode, [file for file_key in files.keys() for file in files.getlist(file_key)]) return HttpResponseRedirect(reverse('view', kwargs={'barcode': database_files[0].barcode}))