forked from beba/foerderbarometer
new modell field survey_mail_send to make sure every mail is sendet only once
This commit is contained in:
parent
7fa5110865
commit
d3ba817b09
|
@ -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')
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue