diff --git a/note/admin.py b/note/admin.py index d51fb180..ac17be4e 100644 --- a/note/admin.py +++ b/note/admin.py @@ -8,8 +8,7 @@ from polymorphic.admin import PolymorphicChildModelAdmin, \ PolymorphicChildModelFilter, PolymorphicParentModelAdmin from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser -from .models.transactions import MembershipTransaction, Transaction, \ - TransactionTemplate +from .models.transactions import Transaction, TransactionTemplate class AliasInlines(admin.TabularInline): diff --git a/note/locale/fr/LC_MESSAGES/django.po b/note/locale/fr/LC_MESSAGES/django.po index e229be12..125efe0c 100644 --- a/note/locale/fr/LC_MESSAGES/django.po +++ b/note/locale/fr/LC_MESSAGES/django.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-17 13:32+0200\n" +"POT-Creation-Date: 2019-07-17 13:48+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -13,11 +13,11 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: admin.py:113 models/transactions.py:46 +#: admin.py:112 models/transactions.py:46 msgid "source" msgstr "source" -#: admin.py:121 admin.py:139 models/transactions.py:25 +#: admin.py:120 admin.py:138 models/transactions.py:25 #: models/transactions.py:52 msgid "destination" msgstr "destination" @@ -136,33 +136,37 @@ msgid "quantity" msgstr "quantité" #: models/transactions.py:69 -msgid "description" -msgstr "description" +msgid "reason" +msgstr "raison" -#: models/transactions.py:72 +#: models/transactions.py:73 msgid "valid" msgstr "valide" -#: models/transactions.py:76 +#: models/transactions.py:77 msgid "transaction" msgstr "transaction" -#: models/transactions.py:77 +#: models/transactions.py:78 msgid "transactions" msgstr "transactions" -#: models/transactions.py:88 +#: models/transactions.py:89 msgid "membership transaction" msgstr "transaction d'adhésion" -#: models/transactions.py:89 +#: models/transactions.py:90 msgid "membership transactions" msgstr "transactions d'adhésion" -#: templates/note/transfer.html:7 +#: templates/note/transaction_form.html:10 msgid "Home" msgstr "Accueil" -#: views.py:21 +#: templates/note/transaction_form.html:53 +msgid "Transfer" +msgstr "Virement" + +#: views.py:26 msgid "Transfer money from your account to one or others" msgstr "Transfert d'argent de ton compte vers un ou plusieurs autres" diff --git a/note/models/transactions.py b/note/models/transactions.py index dba5e4bd..e27b3e11 100644 --- a/note/models/transactions.py +++ b/note/models/transactions.py @@ -65,8 +65,9 @@ class Transaction(models.Model): verbose_name=_('type'), max_length=31, ) - description = models.TextField( - verbose_name=_('description'), + reason = models.CharField( + verbose_name=_('reason'), + max_length=255, ) valid = models.NullBooleanField( verbose_name=_('valid'), diff --git a/note/templates/note/transaction_form.html b/note/templates/note/transaction_form.html new file mode 100644 index 00000000..2fbff905 --- /dev/null +++ b/note/templates/note/transaction_form.html @@ -0,0 +1,55 @@ +{% extends "admin/base_site.html" %} +{% comment %} +SPDX-License-Identifier: GPL-2.0-or-later +{% endcomment %} + +{% load i18n static %} + +{% block breadcrumbs %} + +{% endblock %} + +{% block extrahead %}{{ block.super }} + {# Load Django Admin datetime widget #} + + + {{ form.media }} +{% endblock %} + +{% block extrastyle %}{{ block.super }} + +{% endblock %} + +{% block content %} +
{% csrf_token %} + {% if form.non_field_errors %} +

+ {% for error in form.non_field_errors %} + {{ error }} + {% endfor %} +

+ {% endif %} +
+ {% for field in form %} +
+ {{ field.errors }} +
+ {{ field.label_tag }} + {% if field.is_readonly %} +
{{ field.contents }}
+ {% else %} + {{ field }} + {% endif %} + {% if field.field.help_text %} +
{{ field.field.help_text|safe }}
+ {% endif %} +
+
+ {% endfor %} +
+ +
+{% endblock %} \ No newline at end of file diff --git a/note/templates/note/transfer.html b/note/templates/note/transfer.html deleted file mode 100644 index 26183576..00000000 --- a/note/templates/note/transfer.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "admin/base_site.html" %} - -{% load i18n %} - -{% block breadcrumbs %} - -{% endblock %} diff --git a/note/urls.py b/note/urls.py index 360e97ff..aaa6b160 100644 --- a/note/urls.py +++ b/note/urls.py @@ -8,5 +8,5 @@ from . import views app_name = 'note' urlpatterns = [ - path('transfer/', views.transfer, name='transfer'), + path('transfer/', views.TransactionCreate.as_view(), name='transfer'), ] diff --git a/note/views.py b/note/views.py index a0a37082..e60ec203 100644 --- a/note/views.py +++ b/note/views.py @@ -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 diff --git a/theme/templates/registration/logged_out.html b/theme/templates/registration/logged_out.html index 3ecc65e2..48949e84 100644 --- a/theme/templates/registration/logged_out.html +++ b/theme/templates/registration/logged_out.html @@ -9,3 +9,8 @@ SPDX-License-Identifier: GPL-3.0-or-later {% trans 'Home' %} {% endblock %} + +{% block content %} +

{% trans "Thanks for spending some quality time with the Web site today." %}

+

{% trans 'Log in again' %}

+{% endblock %} \ No newline at end of file diff --git a/theme/templates/registration/login.html b/theme/templates/registration/login.html new file mode 100644 index 00000000..8d10a1b9 --- /dev/null +++ b/theme/templates/registration/login.html @@ -0,0 +1,8 @@ +{% extends "admin/login.html" %} +{% comment %} +SPDX-License-Identifier: GPL-2.0-or-later +{% endcomment %} + +{% load i18n %} + +{% block title %}{% trans "Log in" %}{% endblock %} \ No newline at end of file