From 9ba037ec1251a0fdde346f133528cd0dc1cd5911 Mon Sep 17 00:00:00 2001 From: nanoy Date: Sun, 23 Jun 2019 11:06:39 +0200 Subject: [PATCH] Add reason field on whitelists --- users/admin.py | 4 ++-- users/forms.py | 2 +- users/migrations/0008_auto_20190623_1105.py | 23 +++++++++++++++++++++ users/models.py | 4 ++++ users/templates/users/profile.html | 2 ++ 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 users/migrations/0008_auto_20190623_1105.py diff --git a/users/admin.py b/users/admin.py index 3ee28d9..0ba9f9d 100644 --- a/users/admin.py +++ b/users/admin.py @@ -50,9 +50,9 @@ class WhiteListHistoryAdmin(SimpleHistoryAdmin): """ The admin class for :class:`Consumptions `. """ - list_display = ('user', 'paymentDate', 'endDate', 'duration') + list_display = ('user', 'paymentDate', 'endDate', 'duration', 'reason') ordering = ('user', 'duration', 'paymentDate', 'endDate') - search_fields = ('user__username', 'user__first_name', 'user__last_name') + search_fields = ('user__username', 'user__first_name', 'user__last_name', 'reason') admin.site.register(Permission, SimpleHistoryAdmin) admin.site.register(School, SimpleHistoryAdmin) diff --git a/users/forms.py b/users/forms.py index f1b7e4c..ae4481a 100644 --- a/users/forms.py +++ b/users/forms.py @@ -99,7 +99,7 @@ class addWhiteListHistoryForm(forms.ModelForm): """ class Meta: model = WhiteListHistory - fields = ("duration", ) + fields = ("duration", "reason") class SchoolForm(forms.ModelForm): """ diff --git a/users/migrations/0008_auto_20190623_1105.py b/users/migrations/0008_auto_20190623_1105.py new file mode 100644 index 0000000..de39a20 --- /dev/null +++ b/users/migrations/0008_auto_20190623_1105.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1 on 2019-06-23 09:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0007_auto_20190623_0957'), + ] + + operations = [ + migrations.AddField( + model_name='historicalwhitelisthistory', + name='reason', + field=models.CharField(blank=True, max_length=255, verbose_name='Raison'), + ), + migrations.AddField( + model_name='whitelisthistory', + name='reason', + field=models.CharField(blank=True, max_length=255, verbose_name='Raison'), + ), + ] diff --git a/users/models.py b/users/models.py index 824bd92..45390e1 100644 --- a/users/models.py +++ b/users/models.py @@ -99,6 +99,10 @@ class WhiteListHistory(models.Model): """ User (:class:`django.contrib.auth.models.User`) who registered the cotisation. """ + reason = models.CharField(max_length=255, verbose_name="Raison", blank=True) + """ + Reason of the whitelist + """ history = HistoricalRecords() class Profile(models.Model): diff --git a/users/templates/users/profile.html b/users/templates/users/profile.html index e369a31..45ede49 100644 --- a/users/templates/users/profile.html +++ b/users/templates/users/profile.html @@ -263,6 +263,7 @@ Date de l'ajout Date de fin Durée + Raison @@ -271,6 +272,7 @@ {{whitelist.paymentDate}} {{whitelist.endDate}} {{whitelist.duration}} jours + {{ whitelist.reason }} {% endfor %}