new modell field survey_mail_send to make sure every mail is sendet only once

This commit is contained in:
Benni Bärmann 2020-10-22 14:38:23 +02:00
parent 7fa5110865
commit d3ba817b09
4 changed files with 49 additions and 14 deletions

View File

@ -13,7 +13,7 @@ class ProjectForm(ModelForm):
class Meta:
model = Project
exclude = ('pid', 'granted', 'username', 'realname', 'email', 'project_end_mail')
exclude = ('pid', 'granted', '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',)
exclude = ('granted','survey_mail_send')
INTERN_CHOICES = [('PRO', 'Projektsteckbrief'),
('HON', 'Ehrenamtsbescheinigung'),
@ -41,21 +41,21 @@ class InternForm(ModelForm):
class Meta:
model = Volunteer
exclude = ('granted',)
exclude = ('granted','survey_mail_send')
class LibraryForm(ModelForm):
class Meta:
model = Library
exclude = ('realname', 'email', 'username', 'type', 'granted')
exclude = ('realname', 'email', 'username', 'type', 'granted', 'survey_mail_send')
class IFGForm(ModelForm):
class Meta:
model = IFG
exclude = ('realname', 'email', 'username', 'granted')
exclude = ('realname', 'email', 'username', 'granted', 'survey_mail_send')
class HonoraryCertificateForm(ModelForm):
class Meta:
model = HonoraryCertificate
exclude = ('realname', 'email', 'username', 'granted')
exclude = ('realname', 'email', 'username', 'granted', 'survey_mail_send')

View File

@ -64,7 +64,7 @@ class Command(BaseCommand):
project.end_mail_send = True
project.save()
except BadHeaderError:
return HttpResponse('Invalid header found.')
self.stdout.write(self.style.ERROR('Invalid header found.'))
self.stdout.write(self.style.SUCCESS('end_of_projects_reached() executed.'))
@ -73,15 +73,16 @@ class Command(BaseCommand):
self.end_of_projects_reached()
supported = Library.objects.filter(granted=True)
supported = Library.objects.filter(granted=True)\
.exclude(survey_mail_send=True)
print(supported)
for item in supported:
self.survey_link(email=item.email,
type=item.type,
pid=9999, ## TODO
name=item.library,
realname=item.realname)
# project.end_mail_send = True
# project.save()
type=item.type,
pid=9999, ## TODO
name=item.library,
realname=item.realname)
item.survey_mail_send = True
item.save()
self.stdout.write(self.style.SUCCESS('sendmails custom command executed'))

View File

@ -0,0 +1,33 @@
# Generated by Django 3.1.1 on 2020-10-22 12:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('input', '0021_auto_20201022_0934'),
]
operations = [
migrations.AddField(
model_name='honorarycertificate',
name='survey_mail_send',
field=models.BooleanField(null=True),
),
migrations.AddField(
model_name='ifg',
name='survey_mail_send',
field=models.BooleanField(null=True),
),
migrations.AddField(
model_name='library',
name='survey_mail_send',
field=models.BooleanField(null=True),
),
migrations.AddField(
model_name='project',
name='survey_mail_send',
field=models.BooleanField(null=True),
),
]

View File

@ -8,6 +8,7 @@ class Volunteer(models.Model):
email = models.CharField(max_length=200, null=True)
username = models.CharField(max_length=200, null=True)
granted = models.BooleanField(null=True)
survey_mail_send = models.BooleanField(null=True)
@classmethod
def set_granted(cl, key, b):