diff --git a/input/forms.py b/input/forms.py index 72e8791..15ad72d 100644 --- a/input/forms.py +++ b/input/forms.py @@ -63,7 +63,8 @@ class IFGForm(ModelForm): class HonoraryCertificateForm(ModelForm): class Meta: model = HonoraryCertificate - exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') + fields = ['request_url', 'project'] + # exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') class EmailForm(ModelForm): # TODO: add some javascript to show/hide other-field @@ -73,4 +74,5 @@ class EmailForm(ModelForm): class Meta: model = Email - exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') + fields = ['domain', 'address', 'other'] + # exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send') diff --git a/input/management/commands/sendmails.py b/input/management/commands/sendmails.py index 3264850..9987088 100644 --- a/input/management/commands/sendmails.py +++ b/input/management/commands/sendmails.py @@ -85,6 +85,8 @@ class Command(BaseCommand): self.stdout.write(self.style.SUCCESS(f'surveymails for object type {type} sent')) + ''' TODO: there could be some more removing of duplicated code in the following functions ''' + def surveymails_to_lib(self): '''get all library objects which where granted two weeks ago''' @@ -123,6 +125,7 @@ class Command(BaseCommand): typefield = ('MAIL','VIS','LIST') count = 0 for c in ('Email', 'BusinessCard', 'List'): + # get class via string supported = getattr(sys.modules[__name__], c).objects.filter(granted=True)\ .filter(granted_date__lt = lastdate)\ .exclude(survey_mail_send=True) diff --git a/input/migrations/0028_auto_20201027_1131.py b/input/migrations/0028_auto_20201027_1131.py new file mode 100644 index 0000000..3a6f57f --- /dev/null +++ b/input/migrations/0028_auto_20201027_1131.py @@ -0,0 +1,55 @@ +# Generated by Django 3.1.1 on 2020-10-27 11:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0027_businesscard_email_list'), + ] + + operations = [ + migrations.RemoveField( + model_name='businesscard', + name='cost', + ), + migrations.RemoveField( + model_name='businesscard', + name='notes', + ), + migrations.RemoveField( + model_name='email', + name='adress', + ), + migrations.AddField( + model_name='businesscard', + name='data', + field=models.CharField(default='NODATA', max_length=1000, verbose_name='Persönliche Daten'), + ), + migrations.AddField( + model_name='businesscard', + name='project', + field=models.CharField(choices=[('PEDIA', 'Wikipedia'), ('SOURCE', 'Wikisource'), ('BOOKS', 'Wikibooks'), ('QUOTE', 'Wikiquote'), ('VERSITY', 'Wikiversity'), ('VOYAGE', 'Wikivoyage'), ('DATA', 'Wikidata'), ('NEWS', 'Wikinews'), ('COMMONS', 'Wikimedia Commons')], default='PEDIA', max_length=20, verbose_name='Wikimedia Projekt'), + ), + migrations.AddField( + model_name='businesscard', + name='sent_to', + field=models.CharField(default='NOADRESS', max_length=1000, verbose_name='Sendungsadresse'), + ), + migrations.AddField( + model_name='businesscard', + name='variant', + field=models.CharField(choices=[('PIC', 'Mit Bild'), ('NOPIC', 'Ohne Bild')], default='NOPIC', max_length=5, verbose_name='Variante'), + ), + migrations.AddField( + model_name='email', + name='address', + field=models.CharField(choices=[('REALNAME', 'Vorname.Nachname'), ('USERNAME', 'Username'), ('OTHER', 'Sonstiges:')], default='USERNAME', max_length=50, verbose_name='Adressbestandteil'), + ), + migrations.AddField( + model_name='list', + name='address', + field=models.CharField(default='NO_ADDRESS', max_length=50), + ), + ] diff --git a/input/models.py b/input/models.py index b09d06d..ee444aa 100644 --- a/input/models.py +++ b/input/models.py @@ -136,13 +136,33 @@ MAIL_CHOICES = {'REALNAME': 'Vorname.Nachname', 'OTHER': 'Sonstiges:'} class Email(Domain): - adress = models.CharField(max_length=50, + address = models.CharField(max_length=50, choices=MAIL_CHOICES.items(), - default='USERNAME') + default='USERNAME', verbose_name='Adressbestandteil') other = models.CharField(max_length=50,blank=True,null=True) class List(Domain): - pass - -class BusinessCard(Grant): - pass + address = models.CharField(max_length=50, default='NO_ADDRESS') + +PROJECT_CHOICE = {'PEDIA': 'Wikipedia', + 'SOURCE': 'Wikisource', + 'BOOKS': 'Wikibooks', + 'QUOTE': 'Wikiquote', + 'VERSITY': 'Wikiversity', + 'VOYAGE': 'Wikivoyage', + 'DATA': 'Wikidata', + 'NEWS': 'Wikinews', + 'COMMONS': 'Wikimedia Commons'} + +BC_VARIANT = {'PIC': 'Mit Bild', + 'NOPIC': 'Ohne Bild'} + +class BusinessCard(Extern): + project = models.CharField(max_length=20, choices=PROJECT_CHOICE.items(), + default='PEDIA', verbose_name='Wikimedia Projekt') + + data = models.CharField(max_length=1000, verbose_name='Persönliche Daten', default='NODATA') + variant = models.CharField(max_length=5, choices=BC_VARIANT.items(), + default='NOPIC', verbose_name='Variante') + sent_to = models.CharField(max_length=1000, verbose_name='Sendungsadresse', + default='NOADRESS')