Пример #1
0
Файл: web.py Проект: rf9/robox
    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}))
Пример #2
0
Файл: web.py Проект: rf9/robox
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}))
Пример #3
0
Файл: web.py Проект: rf9/robox
    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}))
Пример #4
0
    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)
Пример #5
0
Файл: web.py Проект: rf9/robox
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}))