Example #1
0
def saveProduct(request):
    from website.models import Product

    if request.method == 'POST':
        f = forms.newEditStockForm(request.POST, request.FILES)
        if f.is_valid():
            f.save()
            return HttpResponse('saved!')
        else:
            return HttpResponse(str(f.errors))

    return HttpResponse('error!')
Example #2
0
def editProduct(request):
    from website.models import Product

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

    return HttpResponse('error!')
Example #3
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)