def EditView(request, form, pk): content = {'form': form} if not is_superior(request): return redirect('account_control:permit_denied') if form == 1: if Income.objects.filter(id=pk).count() == 0: return redirect('stock:list_statement', form=1) else: content["statement"] = Income.objects.get(id=pk) if form == 2: if Expense.objects.filter(id=pk).count() == 0: return redirect('stock:list_statement', form=2) else: content["statement"] = Expense.objects.get(id=pk) if form == 3: if TempExpense.objects.filter(id=pk).count() == 0: return redirect('stock:list_statement', form=3) else: content["statement"] = TempExpense.objects.get(id=pk) if request.POST: result = edit(request) if result == 'updated' or result == 'deleted': return redirect('stock:list_statement', form=form) else: content['message'] = result return render(request, 'stock/statement/edit.html', content)
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)
def Top_up_Edit_View(request,pk): if not is_superior(request): return redirect('account_control:permit_denied') if TopUp.objects.filter(id=pk).count() == 1: if request.POST: edit(request,pk) else: content = {'top_up': TopUp.objects.get(id=pk)} return render(request, 'stock/top_up/edit.html', content) return redirect('stock:list_top_up')
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')
def EditExpenseView(request, pk): if not is_superior(request): return redirect('account_control:permit_denied') expense = Expense.objects.get(id=pk) content = {'expense': expense} if Expense.objects.filter(id=pk).count() == 0: return redirect('stock:list_expense') if request.POST: result = editexpense(request) if result == 'updated' or result == 'deleted': return redirect('stock:list_expense') else: content['message'] = result return render(request, 'stock/statement/edit_expense.html', content)
def ResetIndexView(request): if is_superior(request): user_superior(request, hard_mode=1) return redirect('stock:index') else: return redirect('account_control:permit_denied')