Browse Source

Add reason field on whitelists

pull/1/head
Yoann Piétri 7 years ago
parent
commit
9ba037ec12
  1. 4
      users/admin.py
  2. 2
      users/forms.py
  3. 23
      users/migrations/0008_auto_20190623_1105.py
  4. 4
      users/models.py
  5. 2
      users/templates/users/profile.html

4
users/admin.py

@ -50,9 +50,9 @@ class WhiteListHistoryAdmin(SimpleHistoryAdmin):
""" """
The admin class for :class:`Consumptions <users.models.WhiteListHistory>`. The admin class for :class:`Consumptions <users.models.WhiteListHistory>`.
""" """
list_display = ('user', 'paymentDate', 'endDate', 'duration') list_display = ('user', 'paymentDate', 'endDate', 'duration', 'reason')
ordering = ('user', 'duration', 'paymentDate', 'endDate') 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(Permission, SimpleHistoryAdmin)
admin.site.register(School, SimpleHistoryAdmin) admin.site.register(School, SimpleHistoryAdmin)

2
users/forms.py

@ -99,7 +99,7 @@ class addWhiteListHistoryForm(forms.ModelForm):
""" """
class Meta: class Meta:
model = WhiteListHistory model = WhiteListHistory
fields = ("duration", ) fields = ("duration", "reason")
class SchoolForm(forms.ModelForm): class SchoolForm(forms.ModelForm):
""" """

23
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'),
),
]

4
users/models.py

@ -99,6 +99,10 @@ class WhiteListHistory(models.Model):
""" """
User (:class:`django.contrib.auth.models.User`) who registered the cotisation. 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() history = HistoricalRecords()
class Profile(models.Model): class Profile(models.Model):

2
users/templates/users/profile.html

@ -263,6 +263,7 @@
<th>Date de l'ajout</th> <th>Date de l'ajout</th>
<th>Date de fin</th> <th>Date de fin</th>
<th>Durée</th> <th>Durée</th>
<th>Raison</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -271,6 +272,7 @@
<td>{{whitelist.paymentDate}}</td> <td>{{whitelist.paymentDate}}</td>
<td>{{whitelist.endDate}}</td> <td>{{whitelist.endDate}}</td>
<td>{{whitelist.duration}} jours</td> <td>{{whitelist.duration}} jours</td>
<td>{{ whitelist.reason }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

Loading…
Cancel
Save