Browse Source

more work on MAIL, LIST and VIS modells and forms

master
Benni Baermann 4 years ago
parent
commit
34936c7ef2
4 changed files with 88 additions and 8 deletions
  1. +4
    -2
      input/forms.py
  2. +3
    -0
      input/management/commands/sendmails.py
  3. +55
    -0
      input/migrations/0028_auto_20201027_1131.py
  4. +26
    -6
      input/models.py

+ 4
- 2
input/forms.py View File

@ -63,7 +63,8 @@ class IFGForm(ModelForm):
class HonoraryCertificateForm(ModelForm): class HonoraryCertificateForm(ModelForm):
class Meta: class Meta:
model = HonoraryCertificate 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): class EmailForm(ModelForm):
# TODO: add some javascript to show/hide other-field # TODO: add some javascript to show/hide other-field
@ -73,4 +74,5 @@ class EmailForm(ModelForm):
class Meta: class Meta:
model = Email 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')

+ 3
- 0
input/management/commands/sendmails.py View File

@ -85,6 +85,8 @@ class Command(BaseCommand):
self.stdout.write(self.style.SUCCESS(f'surveymails for object type {type} sent')) 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): def surveymails_to_lib(self):
'''get all library objects which where granted two weeks ago''' '''get all library objects which where granted two weeks ago'''
@ -123,6 +125,7 @@ class Command(BaseCommand):
typefield = ('MAIL','VIS','LIST') typefield = ('MAIL','VIS','LIST')
count = 0 count = 0
for c in ('Email', 'BusinessCard', 'List'): for c in ('Email', 'BusinessCard', 'List'):
# get class via string
supported = getattr(sys.modules[__name__], c).objects.filter(granted=True)\ supported = getattr(sys.modules[__name__], c).objects.filter(granted=True)\
.filter(granted_date__lt = lastdate)\ .filter(granted_date__lt = lastdate)\
.exclude(survey_mail_send=True) .exclude(survey_mail_send=True)

+ 55
- 0
input/migrations/0028_auto_20201027_1131.py View File

@ -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),
),
]

+ 26
- 6
input/models.py View File

@ -136,13 +136,33 @@ MAIL_CHOICES = {'REALNAME': 'Vorname.Nachname',
'OTHER': 'Sonstiges:'} 'OTHER': 'Sonstiges:'}
class Email(Domain): class Email(Domain):
adress = models.CharField(max_length=50,
address = models.CharField(max_length=50,
choices=MAIL_CHOICES.items(), choices=MAIL_CHOICES.items(),
default='USERNAME')
default='USERNAME', verbose_name='Adressbestandteil')
other = models.CharField(max_length=50,blank=True,null=True) other = models.CharField(max_length=50,blank=True,null=True)
class List(Domain): 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')

Loading…
Cancel
Save