コード例 #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,
    })
コード例 #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,
    })
コード例 #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(),
    })
コード例 #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 (),
    })
コード例 #5
0
ファイル: views.py プロジェクト: themarti/numbles
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(),
        })
コード例 #6
0
ファイル: views.py プロジェクト: themarti/numbles
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 (),
        })
コード例 #7
0
ファイル: views.py プロジェクト: themarti/numbles
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,
        })
コード例 #8
0
ファイル: views.py プロジェクト: themarti/numbles
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,
        })