Ejemplo n.º 1
0
def barcode_submit(request):
    if request.method == 'POST':
        print request.POST
        barcode_form = BarcodeForm(request.POST, instance=Barcode())
        new_barcodes = []
        existing_barcodes = []
        req = Barcode()
        req.name = request.POST['name']
        req.sequence = request.POST['sequence']
        if barcode_form.is_valid():
            try:
                Barcode.objects.get(sequence=request.POST['sequence'])
                existing_barcodes.append(req)
            except:
                new_barcodes.append(req)
                new_barcode = barcode_form.save(commit=False)
                new_barcode.created_by = request.user
                new_barcode.save()

        context = barcode_status(request, new_barcodes, existing_barcodes)
        return render(request, 'seqConfig/barcode/barcode_status.html', context)
    else:
        barcode_form = BarcodeForm(instance=Barcode())
        context = {
            'barcode_form': barcode_form
        }
        context.update(csrf(request))
        return render(request, 'seqConfig/barcode/barcode_submit.html', context)
Ejemplo n.º 2
0
def barcode_edit(request, barcode_id):
    barcode = Barcode.objects.get(pk=barcode_id)
    if request.method == 'POST':
        updated_barcode_form = BarcodeForm(request.POST, instance=barcode)
        if updated_barcode_form.is_valid():
            updated_barcode_form.save()
            return HttpResponseRedirect('/seq-config/barcode/manage/')
    else:
        barcode_form = BarcodeForm(instance=barcode)
        context = {'barcode_form': barcode_form,
                   'barcode_id': barcode.pk}
        context.update(csrf(request))
        return render(request, 'seqConfig/barcode/barcode_edit.html', context)
Ejemplo n.º 3
0
def uploadBarcode(request):
        
    if request.method == 'POST':
        form = BarcodeForm(request.POST, request.FILES)
        
        if form.is_valid():
            machineID = urllib2.unquote( request.POST['machineID'] )
            barcode = urllib2.unquote( request.POST['barcode'] )
            scanner = Scanner.objects.get(uniqueId=machineID)
            person =  scanner.owner
                
            response = updateRecords(barcode, person)
            status = 'success'
        else:
            response = 'form is not valid'
            status = 'error'
    
    response_data = {'status': status,'response': response}
    
    return HttpResponse(json.dumps(response_data), mimetype="application/json")