Exemplo n.º 1
0
def delete_tag(request, id):
    """
    Delete a tag.
    """
    tag = get_object_or_404(Tag, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            tag.delete()
            return redirect('home')
    else:
        form = DeleteForm()
    return render(request, 'ledger/pages/delete.html', {
        'title': "Delete Tag",
        'description': "You are about to remove the {} tag from all transactions and delete it.".format(tag),
        'form': form,
    })
Exemplo n.º 2
0
def delete_attachment(request, id):
    """
    Delete an attachment.
    """
    attachment = get_object_or_404(Attachment, pk=id, transaction__user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            attachment.delete()
            return redirect(attachment.transaction)
    else:
        form = DeleteForm()
    return render(request, 'ledger/pages/delete.html', {
        'title': "Delete Attachment",
        'description': "You are about to delete {}.".format(attachment),
        'breadcrumbs': [attachment.transaction.account, attachment.transaction],
        'form': form,
    })
Exemplo n.º 3
0
def delete_account(request, id):
    """
    Delete an account.
    """
    account = get_object_or_404(Account, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            account.delete()
            return redirect('home')
    else:
        form = DeleteForm()
    return render(request, 'ledger/pages/delete.html', {
        'title': "Delete Account",
        'description': "You are about to delete {}.".format(account),
        'breadcrumbs': [account],
        'form': form,
        'related': account.transactions.all(),
    })
Exemplo n.º 4
0
def delete_transaction(request, id):
    """
    Delete a transaction.
    """
    transaction = get_object_or_404(Transaction, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            transaction.delete()
            return redirect(transaction.account)
    else:
        form = DeleteForm()
    return render(request, 'ledger/pages/delete.html', {
        'title': "Delete Transaction",
        'description': "You are about to delete {}.".format(transaction),
        'breadcrumbs': [transaction.account, transaction],
        'form': form,
        'related': (transaction.linked,) if transaction.linked else (),
    })
Exemplo n.º 5
0
def delete_account(request, id):
    """
    Delete an account.
    """
    account = get_object_or_404(Account, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            account.delete()
            return redirect('home')
    else:
        form = DeleteForm()
    return render(
        request, 'ledger/pages/delete.html', {
            'title': "Delete Account",
            'description': "You are about to delete {}.".format(account),
            'breadcrumbs': [account],
            'form': form,
            'related': account.transactions.all(),
        })
Exemplo n.º 6
0
def delete_transaction(request, id):
    """
    Delete a transaction.
    """
    transaction = get_object_or_404(Transaction, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            transaction.delete()
            return redirect(transaction.account)
    else:
        form = DeleteForm()
    return render(
        request, 'ledger/pages/delete.html', {
            'title': "Delete Transaction",
            'description': "You are about to delete {}.".format(transaction),
            'breadcrumbs': [transaction.account, transaction],
            'form': form,
            'related': (transaction.linked, ) if transaction.linked else (),
        })
Exemplo n.º 7
0
def delete_tag(request, id):
    """
    Delete a tag.
    """
    tag = get_object_or_404(Tag, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            tag.delete()
            return redirect('home')
    else:
        form = DeleteForm()
    return render(
        request, 'ledger/pages/delete.html', {
            'title':
            "Delete Tag",
            'description':
            "You are about to remove the {} tag from all transactions and delete it."
            .format(tag),
            'form':
            form,
        })
Exemplo n.º 8
0
def delete_attachment(request, id):
    """
    Delete an attachment.
    """
    attachment = get_object_or_404(Attachment,
                                   pk=id,
                                   transaction__user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            attachment.delete()
            return redirect(attachment.transaction)
    else:
        form = DeleteForm()
    return render(
        request, 'ledger/pages/delete.html', {
            'title': "Delete Attachment",
            'description': "You are about to delete {}.".format(attachment),
            'breadcrumbs':
            [attachment.transaction.account, attachment.transaction],
            'form': form,
        })