Exemple #1
0
def search(request):
    if request.method == 'POST':
        form = BomSearchForm(request.POST)

        #
        # verify we have a valid part number
        #

        if form.is_valid():
            part_number = form.cleaned_data['part_number']
            
            form.fields['possibilities'].choices = get_partchoices(part_number)

            #
            # drop through and render the search form with the new parts
            #
    else:
        form = BomSearchForm()

    #
    # Render the search form
    #

    return render(request,'bommanage/search.html', { 
        'form' : form, 
        'parts_to_select' : len(form.fields['possibilities'].choices)>0
    })
Exemple #2
0
def move(request):
    if request.method == 'POST':
        form = BomSearchForm(request.POST)

        #
        # Allow any possible directory for validation of the form
        #

        form.fields['possibilities'].choices = get_partchoices('55')

        if form.is_valid():
            status = True
            log = ""

            #
            # Grab the parts to process. For each part see if the
            # move would be successful and accumulate the log
            #

            possibilities = form.cleaned_data['possibilities']

            for part_number in possibilities:
                (part_status, part_log) = ready_move(part_number)

                status &= part_status
                log += "<hr>"+part_log

            #
            # Execute the move
            #

            if status:
                for part_number in possibilities:
                    print "move %s from pending to released" % part_number

            #
            # Display the result 
            #

            return render(request,'bommanage/move_result.html', {
                'status':status,
                'log':log
            })
                
        else:
            
            #
            # if we received an invalid form render the 
            # search form.
            #

            return render(request,'bommanage/search.html', { 
                'form':form, 
                'parts_to_select':len(form.fields['possibilities'].choices)>0
            })

    return render(request,'bommanage/success.html')