new local settings file.

This commit is contained in:
Benni Bärmann 2020-10-20 10:36:15 +02:00
parent e0c20c5d64
commit a31d4edc44
4 changed files with 18 additions and 12 deletions

View File

@ -15,9 +15,6 @@ from pathlib import Path
# mails in development go to stdout # mails in development go to stdout
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 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'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -44,9 +41,12 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
# 'django.contrib.sites',
'formtools', 'formtools',
] ]
# SITE_ID = 1 # needed for contrib.sites
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',

5
input/settings.py Normal file
View File

@ -0,0 +1,5 @@
# mail for IF-OTRS
IF_EMAIL = 'if-test@wikimedia.de'
# prefix for urls
URLPREFIX = 'http://127.0.0.1:8000'

View File

@ -1,6 +1,3 @@
{{data}}
Hallo Team Ideenförderung, Hallo Team Ideenförderung,
es gab einen neuen Antrag von {{data.realname}}. 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 {% elif data.choice == 'VIS' %} Visitenkarten, Mailingliste oder E-Mail-Adresse
{% else %} ERROR UNKNOWN FORMTYPE {% endif %} an. {% else %} ERROR UNKNOWN FORMTYPE {% endif %} an.
Genehmigen: http://127.0.0.1:8000/authorize/{{data.choice}}/{{data.pk}} Genehmigen: {{data.urlprefix}}{% url 'authorize' data.choice data.pk %}
Ablehnen: http://127.0.0.1:8000/deny/{{data.choice}}/{{data.pk}}
Ablehnen: {{data.urlprefix}}{% url 'deny' data.choice data.pk %}
{% comment %} {% comment %}

View File

@ -6,9 +6,11 @@ from django.core.mail import send_mail, BadHeaderError
from django.conf import settings from django.conf import settings
from django.template.loader import get_template from django.template.loader import get_template
from django.template import Context from django.template import Context
# from django.contrib.sites.models import Site
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm
from .models import Project, TYPE_CHOICES, Library from .models import Project, TYPE_CHOICES, Library
from .settings import URLPREFIX, IF_EMAIL
def set_granted_in_lib(key,b): def set_granted_in_lib(key,b):
@ -123,8 +125,9 @@ class ExternView(CookieWizardView):
form.type = data['choice'] form.type = data['choice']
form.save() form.save()
# add primary key to context # add some data to context for mail templates
data['pk'] = form.pk data['pk'] = form.pk
data['urlprefix'] = URLPREFIX
# we need to send the following mails here: # we need to send the following mails here:
context = { 'data': data } context = { 'data': data }
@ -134,7 +137,7 @@ class ExternView(CookieWizardView):
send_mail( send_mail(
'form filled', 'form filled',
mail_template.render(context), mail_template.render(context),
settings.IF_EMAIL, IF_EMAIL,
[form.email], [form.email],
fail_silently=False, fail_silently=False,
) )
@ -143,8 +146,8 @@ class ExternView(CookieWizardView):
send_mail( send_mail(
'form filled', 'form filled',
mail_template.render(context), mail_template.render(context),
settings.IF_EMAIL, IF_EMAIL,
[settings.IF_EMAIL], [IF_EMAIL],
fail_silently=False, fail_silently=False,
) )