From bb2b40e50dfad836d414f5a2f967e5dcc5e8e8fe Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 22 Oct 2020 16:02:59 +0200 Subject: [PATCH] granted_date added --- input/forms.py | 12 ++++---- input/migrations/0023_auto_20201022_1400.py | 33 +++++++++++++++++++++ input/models.py | 8 ++++- 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 input/migrations/0023_auto_20201022_1400.py diff --git a/input/forms.py b/input/forms.py index 6c2d8c7..b204594 100644 --- a/input/forms.py +++ b/input/forms.py @@ -13,7 +13,7 @@ class ProjectForm(ModelForm): class Meta: model = Project - exclude = ('pid', 'granted', 'username', 'realname', 'email', 'project_end_mail', 'survey_mail_send') + exclude = ('pid', 'granted', 'granted_date', 'username', 'realname', 'email', 'project_end_mail', 'survey_mail_send') widgets = {'start': AdminDateWidget(), 'end': AdminDateWidget(),} @@ -28,7 +28,7 @@ class VolunteerForm(ModelForm): class Meta: model = Volunteer - exclude = ('granted','survey_mail_send') + exclude = ('granted', 'granted_date', 'survey_mail_send') INTERN_CHOICES = [('PRO', 'Projektsteckbrief'), ('HON', 'Ehrenamtsbescheinigung'), @@ -41,21 +41,21 @@ class InternForm(ModelForm): class Meta: model = Volunteer - exclude = ('granted','survey_mail_send') + exclude = ('granted', 'granted_date', 'survey_mail_send') class LibraryForm(ModelForm): class Meta: model = Library - exclude = ('realname', 'email', 'username', 'type', 'granted', 'survey_mail_send') + exclude = ('realname', 'email', 'username', 'type', 'granted', 'granted_date', 'survey_mail_send') class IFGForm(ModelForm): class Meta: model = IFG - exclude = ('realname', 'email', 'username', 'granted', 'survey_mail_send') + exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') class HonoraryCertificateForm(ModelForm): class Meta: model = HonoraryCertificate - exclude = ('realname', 'email', 'username', 'granted', 'survey_mail_send') + exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') diff --git a/input/migrations/0023_auto_20201022_1400.py b/input/migrations/0023_auto_20201022_1400.py new file mode 100644 index 0000000..407b6a8 --- /dev/null +++ b/input/migrations/0023_auto_20201022_1400.py @@ -0,0 +1,33 @@ +# Generated by Django 3.1.1 on 2020-10-22 14:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0022_auto_20201022_1233'), + ] + + operations = [ + migrations.AddField( + model_name='honorarycertificate', + name='granted_date', + field=models.DateField(null=True), + ), + migrations.AddField( + model_name='ifg', + name='granted_date', + field=models.DateField(null=True), + ), + migrations.AddField( + model_name='library', + name='granted_date', + field=models.DateField(null=True), + ), + migrations.AddField( + model_name='project', + name='granted_date', + field=models.DateField(null=True), + ), + ] diff --git a/input/models.py b/input/models.py index 7f9a9ec..3c3619a 100644 --- a/input/models.py +++ b/input/models.py @@ -1,3 +1,5 @@ +from datetime import date + from django.db import models from .settings import ACCOUNTS @@ -7,13 +9,17 @@ class Volunteer(models.Model): realname = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True) username = models.CharField(max_length=200, null=True) + + # the following Fields are not supposed to be edited by users granted = models.BooleanField(null=True) + granted_date = models.DateField(null=True) survey_mail_send = models.BooleanField(null=True) @classmethod def set_granted(cl, key, b): obj = cl.objects.get(pk=key) obj.granted = b + obj.granted_date = date.today() obj.save() class Meta: @@ -27,7 +33,7 @@ class Project(Volunteer): account = models.CharField('Kostenstelle', max_length=5, choices=ACCOUNTS.items(), null=True,) - # the following Fields are not supposed to be editet by users + # the following Fields are not supposed to be edited by users pid = models.IntegerField(null=True, blank=True) end_mail_send = models.BooleanField(null=True)