1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-12-14 07:15:16 +01:00

Create view for transaction

This commit is contained in:
Alexandre Iooss
2019-07-17 13:53:58 +02:00
parent 7bafbeb93a
commit 51ad354e0b
9 changed files with 105 additions and 38 deletions

View File

@@ -2,22 +2,27 @@
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from django.contrib.auth.mixins import LoginRequiredMixin
from django.utils.translation import gettext_lazy as _
from django.views.generic.edit import CreateView
from .models import Transaction
@login_required
def transfer(request):
class TransactionCreate(LoginRequiredMixin, CreateView):
"""
Show transfer page
TODO: If user have sufficient rights, they can transfer from an other note
"""
return render(
request,
'note/transfer.html',
{
'title': _('Transfer money from your account to one or others')
}
)
model = Transaction
fields = ('destination', 'amount', 'reason')
def get_context_data(self, **kwargs):
"""
Add some context variables in template such as page title
"""
context = super().get_context_data(**kwargs)
context['title'] = _('Transfer money from your account '
'to one or others')
return context