Browse Source

new local settings file.

master
Benni Baermann 4 years ago
parent
commit
a31d4edc44
4 changed files with 18 additions and 12 deletions
  1. +3
    -3
      foerderbarometer/settings.py
  2. +5
    -0
      input/settings.py
  3. +3
    -5
      input/templates/input/if_mail.txt
  4. +7
    -4
      input/views.py

+ 3
- 3
foerderbarometer/settings.py View File

@ -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',

+ 5
- 0
input/settings.py 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'

+ 3
- 5
input/templates/input/if_mail.txt View File

@ -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 %}

+ 7
- 4
input/views.py View File

@ -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,
)

Loading…
Cancel
Save