diff --git a/foerderbarometer/settings.py b/foerderbarometer/settings.py index 69b0a66..45deeae 100644 --- a/foerderbarometer/settings.py +++ b/foerderbarometer/settings.py @@ -15,9 +15,6 @@ from pathlib import Path # mails in development go to stdout EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -# mail for IF-OTRS -IF_EMAIL = 'if-test@wikimedia.de' - # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -44,9 +41,12 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + # 'django.contrib.sites', 'formtools', ] +# SITE_ID = 1 # needed for contrib.sites + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/input/settings.py b/input/settings.py new file mode 100644 index 0000000..3e5815d --- /dev/null +++ b/input/settings.py @@ -0,0 +1,5 @@ +# mail for IF-OTRS +IF_EMAIL = 'if-test@wikimedia.de' + +# prefix for urls +URLPREFIX = 'http://127.0.0.1:8000' diff --git a/input/templates/input/if_mail.txt b/input/templates/input/if_mail.txt index ce2d7a4..6891967 100644 --- a/input/templates/input/if_mail.txt +++ b/input/templates/input/if_mail.txt @@ -1,6 +1,3 @@ -{{data}} - - Hallo Team Ideenförderung, es gab einen neuen Antrag von {{data.realname}}. @@ -13,8 +10,9 @@ Der Nutzer mit dem Username {{data.username}} fragt ein {% if data.choice == 'LI {% elif data.choice == 'VIS' %} Visitenkarten, Mailingliste oder E-Mail-Adresse {% else %} ERROR UNKNOWN FORMTYPE {% endif %} an. -Genehmigen: http://127.0.0.1:8000/authorize/{{data.choice}}/{{data.pk}} -Ablehnen: http://127.0.0.1:8000/deny/{{data.choice}}/{{data.pk}} +Genehmigen: {{data.urlprefix}}{% url 'authorize' data.choice data.pk %} + +Ablehnen: {{data.urlprefix}}{% url 'deny' data.choice data.pk %} {% comment %} diff --git a/input/views.py b/input/views.py index 087476f..afa9b8c 100644 --- a/input/views.py +++ b/input/views.py @@ -6,9 +6,11 @@ from django.core.mail import send_mail, BadHeaderError from django.conf import settings from django.template.loader import get_template from django.template import Context +# from django.contrib.sites.models import Site from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm from .models import Project, TYPE_CHOICES, Library +from .settings import URLPREFIX, IF_EMAIL def set_granted_in_lib(key,b): @@ -123,8 +125,9 @@ class ExternView(CookieWizardView): form.type = data['choice'] form.save() - # add primary key to context + # add some data to context for mail templates data['pk'] = form.pk + data['urlprefix'] = URLPREFIX # we need to send the following mails here: context = { 'data': data } @@ -134,7 +137,7 @@ class ExternView(CookieWizardView): send_mail( 'form filled', mail_template.render(context), - settings.IF_EMAIL, + IF_EMAIL, [form.email], fail_silently=False, ) @@ -143,8 +146,8 @@ class ExternView(CookieWizardView): send_mail( 'form filled', mail_template.render(context), - settings.IF_EMAIL, - [settings.IF_EMAIL], + IF_EMAIL, + [IF_EMAIL], fail_silently=False, )