Ejemplo n.º 1
0
def ListView(request):
    account_permit(request)
    content = {
        'items': Item.objects.all()
    }

    return render(request, 'stock/Item/list.html', content)
Ejemplo n.º 2
0
def CreateView(request):
    account_permit(request)
    if not is_superior(request):
        return redirect('account_control:permit_denied')
    content = {}
    if request.method == 'POST':
        makenewitem = create(request)
        content['createnewitem'] = makenewitem
    return render(request, 'stock/Item/create.html', content)
Ejemplo n.º 3
0
def EditView(request, pk=None):
    account_permit(request)
    if not is_superior(request):
        return redirect('account_control:permit_denied')
    if id is not None:
        if request.POST:
            edit(request, pk)
        elif Item.objects.filter(id=pk).count() == 1:
            content = {'item': Item.objects.get(id=pk) }
            return render(request, 'stock/Item/edit.html', content)
    return redirect('stock:list_item')
Ejemplo n.º 4
0
def IndexView(request):
    if not script.account_permit(
            request):  # check user permit before do other thing
        return redirect('account_control:logout')
    if request.POST:  # if Post Update data
        if 'startdate' in request.POST:
            content = calculater.text2date(request)
            return render(request, 'stock/display/index.html', content)
        else:
            content = data2view.setdisplay(request)
            return render(request, 'stock/display/index.html', content)

    else:  # login and get view list
        if Item.objects.all().count() == 0:
            return redirect('stock:create_item')  # send to create item
        else:
            content = calculater.normal_get_log(request)
            return render(request, 'stock/display/index.html', content)