示例#1
0
def addGraph(request):
    try:
        g_t=request.POST.get('graph_text', False)
    except (KeyError, Graph.DoesNotExist):
        return render(request, 'callsorder/callsorder.html')
    else:
        b = Graph(graph_text=g_t)
        b.save()

        return HttpResponseRedirect(reverse('callsorder:index',))
示例#2
0
def addItem(request):
    try:
        #c_t = request.POST.get('call_type')
        r = request.POST.get('ring')
        g = request.POST.get('graph')
        g_t = request.POST.get('graph_text')
        #c_m = request.POST.get('call_model')
        h_c = request.POST.get('horn_color')
        m_c = request.POST.get('mouthpiece_color')
        #b = request.POST.get('bone')
    except (KeyError, Item.DoesNotExist):
        return render(request, 'callsorder/callsorder.html')
    else:
        if r == "1":
            ring_mat = Material.objects.get(pk=int(r))
            ring = Ring(ring_material=ring_mat, pk=1)
            ring.save()
        else:
            ring = None
        if g == "2":
            graph = Graph(graph_text=g_t, pk=1)
        elif g == "1":
            graph = Graph(graph_text="Ketner", pk=1)
        else:
            graph = Graph(graph_text="0", pk=1)
        graph.save()
        horn_color = ColorHorn.objects.get(pk=h_c).id
        mouthpiece_color = ColorMouthpiece.objects.get(pk=m_c).id
        item = CallItem(
            release_date=timezone.now(),
            ring_id = (ring.id if ring else None),
            graph_id=graph.id,
            horn_color_id=horn_color,
            mouthpiece_color_id=mouthpiece_color,
        )
        item.save()

        return HttpResponseRedirect(reverse('callsorder:index',))