nk20/note/views.py

29 lines
902 B
Python
Raw Normal View History

2019-07-17 11:34:07 +00:00
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
2019-07-17 11:53:58 +00:00
from django.contrib.auth.mixins import LoginRequiredMixin
2019-07-17 11:34:07 +00:00
from django.utils.translation import gettext_lazy as _
2019-07-17 11:53:58 +00:00
from django.views.generic.edit import CreateView
2019-07-17 11:34:07 +00:00
2019-07-17 11:53:58 +00:00
from .models import Transaction
2019-07-17 11:34:07 +00:00
2019-07-17 11:53:58 +00:00
class TransactionCreate(LoginRequiredMixin, CreateView):
2019-07-17 11:34:07 +00:00
"""
Show transfer page
TODO: If user have sufficient rights, they can transfer from an other note
"""
2019-07-17 11:53:58 +00:00
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