Пример #1
0
def saveOrder(request):
    from website.models import Order

    if request.method == 'POST':
        formset = forms.newEditTransactionsForm(request.POST, request.FILES)
        if formset.is_valid():
            formset.save()

    return HttpResponse('saved!')
Пример #2
0
def index(request):
    from website.models import Product, Order
    
    context = dict()

    context["orderTable"] = Order.objects.values()
    context["productTable"] = Product.objects.values()

    newEditTransactionsForm = forms.newEditTransactionsForm()
    context["newEditTransactionsForm"] = newEditTransactionsForm

    newEditStockForm = forms.newEditStockForm()
    context["newEditStockForm"] = newEditStockForm
    
    return render(request, 'storeManagement/management.html', context)
Пример #3
0
def editOrder(request):
    from website.models import Order
    from dateutil.parser import parse

    dateTimeString = request.POST['order_date']
    parsedString = parse(dateTimeString)
    request.POST['order_date'] = parsedString

    if request.method == 'POST':
        idToEdit = int(request.POST['hiddenInput'])
        instance = Order.objects.get(pk=idToEdit)
        f = forms.newEditTransactionsForm(request.POST, request.FILES, instance=instance)
        if f.is_valid():
            f.save()
            return HttpResponse('saved!')
        else:
            return HttpResponse(str(f.errors))

    return HttpResponse('error!')