Exemple #1
0
Fichier : web.py Projet : rf9/robox
def view_by_barcode(request, barcode):
    barcode = barcode
    try:
        validate_barcode(barcode)
        files = DataFile.objects.filter(barcode__iexact=barcode)

        return render(request, "robox/web/view.html", {'files': files, 'barcode': barcode})
    except ValidationError:
        return render(request, "robox/web/view.html", {'invalid': True, 'barcode': barcode})
Exemple #2
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)
Exemple #3
0
Fichier : web.py Projet : rf9/robox
def view_by_barcode(request, barcode):
    barcode = barcode
    try:
        validate_barcode(barcode)
        files = DataFile.objects.filter(barcode__iexact=barcode)

        return render(request, "robox/web/view.html", {
            'files': files,
            'barcode': barcode
        })
    except ValidationError:
        return render(request, "robox/web/view.html", {
            'invalid': True,
            'barcode': barcode
        })
Exemple #4
0
 def validate(self, value):
     validate_barcode(value)