From 9ef3f275022a111706356ba50d07a3c244c404ee Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 29 Oct 2020 15:05:11 +0100 Subject: [PATCH] service id added --- input/forms.py | 8 ++-- input/migrations/0033_auto_20201029_1338.py | 43 +++++++++++++++++++++ input/models.py | 10 +++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 input/migrations/0033_auto_20201029_1338.py diff --git a/input/forms.py b/input/forms.py index 8cd05f2..0ae050b 100644 --- a/input/forms.py +++ b/input/forms.py @@ -31,7 +31,7 @@ class ExternForm(ModelForm): class Meta: model = Extern - exclude = ('granted', 'granted_date', 'survey_mail_send') + exclude = ('granted', 'granted_date', 'survey_mail_send', 'service_id') INTERN_CHOICES = {'PRO': 'Projektsteckbrief', 'HON': 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung', @@ -55,12 +55,14 @@ class LibraryForm(ModelForm): class Meta: model = Library - exclude = ('realname', 'email', 'username', 'type', 'granted', 'granted_date', 'survey_mail_send') + exclude = ('realname', 'email', 'username', 'type', 'granted',\ + 'granted_date', 'survey_mail_send', 'service_id') class IFGForm(ModelForm): class Meta: model = IFG - exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') + exclude = ('realname', 'email', 'username', 'granted', 'granted_date',\ + 'service_id', 'survey_mail_send') class HonoraryCertificateForm(ModelForm): class Meta: diff --git a/input/migrations/0033_auto_20201029_1338.py b/input/migrations/0033_auto_20201029_1338.py new file mode 100644 index 0000000..a5b3a88 --- /dev/null +++ b/input/migrations/0033_auto_20201029_1338.py @@ -0,0 +1,43 @@ +# Generated by Django 3.1.1 on 2020-10-29 13:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0032_auto_20201029_1213'), + ] + + operations = [ + migrations.AddField( + model_name='businesscard', + name='service_id', + field=models.CharField(blank=True, max_length=15, null=True), + ), + migrations.AddField( + model_name='email', + name='service_id', + field=models.CharField(blank=True, max_length=15, null=True), + ), + migrations.AddField( + model_name='ifg', + name='service_id', + field=models.CharField(blank=True, max_length=15, null=True), + ), + migrations.AddField( + model_name='library', + name='service_id', + field=models.CharField(blank=True, max_length=15, null=True), + ), + migrations.AddField( + model_name='list', + name='service_id', + field=models.CharField(blank=True, max_length=15, null=True), + ), + migrations.AddField( + model_name='literature', + name='service_id', + field=models.CharField(blank=True, max_length=15, null=True), + ), + ] diff --git a/input/models.py b/input/models.py index e8e3af4..6c33327 100644 --- a/input/models.py +++ b/input/models.py @@ -30,6 +30,16 @@ class Extern(Volunteer): ''' abstract basis class for all data entered by extern volunteers ''' username = models.CharField(max_length=200, null=True) + # the following Fields are not supposed to be edited by users + service_id = models.CharField(max_length=15, null=True, blank=True) + + def save(self,*args,**kwargs): + # is there a way to call super().save() only once? + super().save(*args,*kwargs) + print('******EXTERNSAVE********') + self.service_id = type(self).__name__ + str(self.pk) + super().save(*args,*kwargs) + class Meta: abstract = True