survey mails send (for Library only in the moment)

This commit is contained in:
Benni Bärmann 2020-10-22 14:17:34 +02:00
parent af68b71018
commit 7fa5110865
2 changed files with 40 additions and 23 deletions

View File

@ -5,7 +5,7 @@ from django.template.loader import get_template
from django.core.mail import send_mail, BadHeaderError from django.core.mail import send_mail, BadHeaderError
from input.models import Project, Library from input.models import Project, Library
from input.settings import URLPREFIX, IF_EMAIL from input.settings import URLPREFIX, IF_EMAIL, SURVEYPREFIX
class Command(BaseCommand): class Command(BaseCommand):
''' mails will be send here: ''' mails will be send here:
@ -26,7 +26,22 @@ class Command(BaseCommand):
after some amount of time.''' after some amount of time.'''
def survey_link(self, email, type, pid, name, realname): def survey_link(self, email, type, pid, name, realname):
print(f'send surveylinkemail to {email}...') context = {'realname': realname,
'type': type,
'name': name,
'pid': pid,
'SURVEYPREFIX': SURVEYPREFIX, }
mail_template = get_template('input/survey_mail.txt')
try:
send_mail('Projektende erreicht',
mail_template.render(context),
IF_EMAIL,
[email],
fail_silently=False)
except BadHeaderError:
return HttpResponse('Invalid header found.')
print(f'send surveylinkemail to {email}...')
def end_of_projects_reached(self): def end_of_projects_reached(self):
''' end of project reached ''' ''' end of project reached '''
@ -66,5 +81,7 @@ class Command(BaseCommand):
pid=9999, ## TODO pid=9999, ## TODO
name=item.library, name=item.library,
realname=item.realname) realname=item.realname)
# project.end_mail_send = True
# project.save()
self.stdout.write(self.style.SUCCESS('sendmails custom command executed')) self.stdout.write(self.style.SUCCESS('sendmails custom command executed'))

View File

@ -1,28 +1,28 @@
Hallo {{data.realname}}, Hallo {{realname}},
Vor einiger Zeit durfte Wikimedia Deutschland Deine Aktivität für Freies Wissen Vor einiger Zeit durfte Wikimedia Deutschland Deine Aktivität für Freies Wissen
unterstützen. unterstützen.
{% if data.type == 'PRO' %} {% if type == 'PRO' %}
Deine Aktivitäten werden von uns unter dem Projekttitel {{data.name}} geführt. Deine Aktivitäten werden von uns unter dem Projekttitel {{name}} geführt.
{% elif data.type == 'HON' %} {% elif type == 'HON' %}
Du hast von uns eine Bescheinigung ({{data.name}}) erhalten. Du hast von uns eine Bescheinigung ({{name}}) erhalten.
{% elif data.type == 'BIB' %} {% elif type == 'BIB' %}
Du hast von uns ein Bibliotheksstipendium für {{data.name}} erhalten. Du hast von uns ein Bibliotheksstipendium für {{name}} erhalten.
{% elif data.type == 'ELIT' %} {% elif type == 'ELIT' %}
Du hast von uns ein eLiteraturstipendium für {{data.name}} erhalten. Du hast von uns ein eLiteraturstipendium für {{name}} erhalten.
{% elif data.type == 'IFG'} {% elif type == 'IFG'}
Wir haben Dich bei einer IFG-Anfrage unterstützt: {{data.name}} Wir haben Dich bei einer IFG-Anfrage unterstützt: {{name}}
{% elif data.type == 'LIT' %} {% elif type == 'LIT' %}
Du hast von uns ein Literaturstipendium für {{data.name}} erhalten. Du hast von uns ein Literaturstipendium für {{name}} erhalten.
{% elif data.type == 'TRAV' %} {% elif type == 'TRAV' %}
Wir haben Dich mit Reisekostenübernahme für {{data.name}} unterstützt. Wir haben Dich mit Reisekostenübernahme für {{name}} unterstützt.
{% elif data.type == 'SOFT' %} {% elif type == 'SOFT' %}
Du hast von uns ein Softwarestipendium für {{data.name}} erhalten. Du hast von uns ein Softwarestipendium für {{name}} erhalten.
{% elif data.type == 'MAIL' %} {% elif type == 'MAIL' %}
Du hast von uns eine E-Mail-Adresse erhalten. Du hast von uns eine E-Mail-Adresse erhalten.
{% elif data.type == 'LIST' %} {% elif type == 'LIST' %}
Wir haben Dir eine Mailingliste bereit gestellt. Wir haben Dir eine Mailingliste bereit gestellt.
{% elif data.type == 'VIS' %} {% elif type == 'VIS' %}
Du hast von uns Visitenkarten erhalten. Du hast von uns Visitenkarten erhalten.
{% endif %} {% endif %}
@ -32,7 +32,7 @@ Förderprogramme im Sinne der Communitys weiter zu verbessern. Wir freuen uns,
wenn du dir kurz die Zeit dafür nehmen würdest. Die Umfrage mit weiteren wenn du dir kurz die Zeit dafür nehmen würdest. Die Umfrage mit weiteren
Informationen findest du unter dem folgenden Link: Informationen findest du unter dem folgenden Link:
{{SURVEYPREFIX}}{{data.pid}}=1 {{SURVEYPREFIX}}{{pid}}=1
Da dies eine automatisch erzeugte Nachricht ist, wende dich bei Rückfragen zur Umfrage bitte an community@wikimedia.de Da dies eine automatisch erzeugte Nachricht ist, wende dich bei Rückfragen zur Umfrage bitte an community@wikimedia.de