added new modell field Project.end_mail_send to assure that mails will be only send once
This commit is contained in:
parent
2bb8ee517d
commit
73b41066e9
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
purpose: gather data from intern(WMDE) and extern(volunteers) forms to create a database ('förderdatenbank') and send emails with links for a questionary.
|
purpose: gather data from intern(WMDE) and extern(volunteers) forms to create a database ('förderdatenbank') and send emails with links for a questionary.
|
||||||
|
|
||||||
used versions:
|
versions used in development:
|
||||||
|
|
||||||
python 3.8.2
|
python 3.8.2
|
||||||
django 3.1.1
|
django 3.1.1
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ProjectForm(ModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Project
|
model = Project
|
||||||
exclude = ('pid', 'granted', 'username', 'realname', 'email')
|
exclude = ('pid', 'granted', 'username', 'realname', 'email', 'project_end_mail')
|
||||||
widgets = {'start': AdminDateWidget(),
|
widgets = {'start': AdminDateWidget(),
|
||||||
'end': AdminDateWidget(),}
|
'end': AdminDateWidget(),}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,10 @@ class Command(BaseCommand):
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
|
||||||
# get all projects which ended 3 weeks ago
|
# get all projects which ended 3 weeks ago
|
||||||
old = Project.objects.filter(end__lt = date.today() - timedelta(days=30))
|
old = Project.objects.filter(end__lt = date.today() - timedelta(days=21))\
|
||||||
|
.exclude(end_mail_send = True)
|
||||||
|
|
||||||
|
|
||||||
print(old)
|
print(old)
|
||||||
mail_template = get_template('input/if_end_of_project.txt')
|
mail_template = get_template('input/if_end_of_project.txt')
|
||||||
for project in old:
|
for project in old:
|
||||||
|
@ -39,6 +42,8 @@ class Command(BaseCommand):
|
||||||
IF_EMAIL,
|
IF_EMAIL,
|
||||||
[IF_EMAIL],
|
[IF_EMAIL],
|
||||||
fail_silently=False)
|
fail_silently=False)
|
||||||
|
project.end_mail_send = True
|
||||||
|
project.save()
|
||||||
except BadHeaderError:
|
except BadHeaderError:
|
||||||
return HttpResponse('Invalid header found.')
|
return HttpResponse('Invalid header found.')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.1.1 on 2020-10-22 09:07
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('input', '0019_auto_20201021_1148'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='project',
|
||||||
|
name='project_end_mail',
|
||||||
|
field=models.BooleanField(null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.1.1 on 2020-10-22 09:34
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('input', '0020_project_project_end_mail'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='project',
|
||||||
|
old_name='project_end_mail',
|
||||||
|
new_name='end_mail_send',
|
||||||
|
),
|
||||||
|
]
|
|
@ -2,6 +2,7 @@ from django.db import models
|
||||||
|
|
||||||
from .settings import ACCOUNTS
|
from .settings import ACCOUNTS
|
||||||
|
|
||||||
|
|
||||||
class Volunteer(models.Model):
|
class Volunteer(models.Model):
|
||||||
realname = models.CharField(max_length=200, null=True)
|
realname = models.CharField(max_length=200, null=True)
|
||||||
email = models.CharField(max_length=200, null=True)
|
email = models.CharField(max_length=200, null=True)
|
||||||
|
@ -17,6 +18,7 @@ class Volunteer(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class Project(Volunteer):
|
class Project(Volunteer):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
start = models.DateField('Startdatum', null=True)
|
start = models.DateField('Startdatum', null=True)
|
||||||
|
@ -24,7 +26,9 @@ class Project(Volunteer):
|
||||||
account = models.CharField('Kostenstelle', max_length=5,
|
account = models.CharField('Kostenstelle', max_length=5,
|
||||||
choices=ACCOUNTS.items(), null=True,)
|
choices=ACCOUNTS.items(), null=True,)
|
||||||
|
|
||||||
pid = models.IntegerField(null=True, blank=True) # automaticly generated
|
# the following Fields are not supposed to be editet by users
|
||||||
|
pid = models.IntegerField(null=True, blank=True)
|
||||||
|
end_mail_send = models.BooleanField(null=True)
|
||||||
|
|
||||||
def save(self,*args,**kwargs):
|
def save(self,*args,**kwargs):
|
||||||
# is there a way to call super().save() only once?
|
# is there a way to call super().save() only once?
|
||||||
|
@ -35,6 +39,7 @@ class Project(Volunteer):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.pid} {self.name}"
|
return f"{self.pid} {self.name}"
|
||||||
|
|
||||||
|
|
||||||
class HonoraryCertificate(Volunteer):
|
class HonoraryCertificate(Volunteer):
|
||||||
request_url = models.CharField(max_length=2000)
|
request_url = models.CharField(max_length=2000)
|
||||||
project = models.ForeignKey(Project, null = True, on_delete = models.SET_NULL)
|
project = models.ForeignKey(Project, null = True, on_delete = models.SET_NULL)
|
||||||
|
@ -42,7 +47,8 @@ class HonoraryCertificate(Volunteer):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Certificate for " + self.realname
|
return "Certificate for " + self.realname
|
||||||
|
|
||||||
#abstract class for Library, IFG, ...
|
|
||||||
|
#abstract base class for Library, IFG, ...
|
||||||
class Grant(Volunteer):
|
class Grant(Volunteer):
|
||||||
cost = models.CharField(max_length=10)
|
cost = models.CharField(max_length=10)
|
||||||
notes = models.CharField(max_length=500)
|
notes = models.CharField(max_length=500)
|
||||||
|
@ -60,6 +66,7 @@ TYPE_CHOICES = {'BIB': 'Bibliotheksstipendium',
|
||||||
'IFG': 'Kostenübernahme IFG-Anfrage',
|
'IFG': 'Kostenübernahme IFG-Anfrage',
|
||||||
'LIT': 'Literaturstipendium',}
|
'LIT': 'Literaturstipendium',}
|
||||||
|
|
||||||
|
|
||||||
# same model is used for Library, ELitStip and Software!
|
# same model is used for Library, ELitStip and Software!
|
||||||
class Library(Grant):
|
class Library(Grant):
|
||||||
|
|
||||||
|
@ -74,6 +81,7 @@ class Library(Grant):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.library
|
return self.library
|
||||||
|
|
||||||
|
|
||||||
class IFG(Grant):
|
class IFG(Grant):
|
||||||
url = models.CharField(max_length=2000)
|
url = models.CharField(max_length=2000)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue