You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.5 KiB
142 lines
4.5 KiB
from django.shortcuts import render,redirect,reverse
|
|
from django.http import HttpResponse, HttpResponseNotFound, Http404,HttpResponseRedirect
|
|
|
|
#zeitgeraffel
|
|
from django.utils import timezone
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
import datetime
|
|
import pytz
|
|
|
|
from hpst.models import Termin
|
|
from hpst.models import Kontakt
|
|
from hpst.forms import KontaktForm
|
|
#Email
|
|
from django.core.mail import BadHeaderError,send_mail
|
|
|
|
|
|
# Hauptseite
|
|
def index(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
"form":KontaktForm(initial={'subject': 'Kontaktformular - Index - sinnestau.de',})
|
|
}
|
|
return render(request, "index.html", context)
|
|
|
|
def wildnispaedagogik(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
# return response with template and context
|
|
return render(request, "wildnispaedagogik.html", context)
|
|
|
|
def kinderfreizeit(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).filter(termintyp__in=['K','W']).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
# return response with template and context
|
|
return render(request, "kinderfreizeit.html", context)
|
|
|
|
def lamatour(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).filter(termintyp='L').order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
# return response with template and context
|
|
return render(request, "lamatour.html", context)
|
|
|
|
def externereferentin(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
# return response with template and context
|
|
return render(request, "externereferentin.html", context)
|
|
|
|
def honigmassage(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
return render(request, "honigmassage.html", context)
|
|
|
|
def psychologischeberatung(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
return render(request, "psychologischeberatung.html", context)
|
|
|
|
def pflanzenheilkunde(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
return render(request, "pflanzenheilkunde.html", context)
|
|
|
|
def ohrakupunktur(request):
|
|
termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date')
|
|
context ={
|
|
"termine":termine,
|
|
}
|
|
return render(request, "ohrakupunktur.html", context)
|
|
|
|
def termin(request,tid):
|
|
#print (tid)
|
|
error=""
|
|
try:
|
|
termin=Termin.objects.get(id=tid)
|
|
except ObjectDoesNotExist:
|
|
error="Dieser Termin existiert nicht"
|
|
context ={
|
|
"termin":termin,
|
|
"error":error,
|
|
}
|
|
# return response with template and context
|
|
return render(request, "termin.html", context)
|
|
|
|
def impressum(request):
|
|
cookies=request.COOKIES
|
|
#print(cookies)
|
|
error="Kein Impressum"
|
|
context ={
|
|
"cookies":cookies,
|
|
}
|
|
# return response with template and context
|
|
return render(request, "impressum.html", context)
|
|
|
|
def contactView(request):
|
|
if request.method == 'GET':
|
|
form = KontaktForm()
|
|
else:
|
|
print("havepost")
|
|
r_message=""
|
|
form = KontaktForm(request.POST)
|
|
if form.is_valid():
|
|
print("form valid")
|
|
subject = form.cleaned_data['subject']
|
|
from_email = form.cleaned_data['from_email']
|
|
message = form.cleaned_data['message']
|
|
name = form.cleaned_data['name']
|
|
text=from_email+'\n.........................\n'+message
|
|
newkon=Kontakt.objects.create(
|
|
name=name,
|
|
subject=subject,
|
|
email=from_email,
|
|
text=text
|
|
)
|
|
r_message="Vielen Dank! Wir haben Ihre Email erhalten!"
|
|
try:
|
|
send_mail(subject, text, 'formular@sinnes-tau.de', ['tanja@kuntner.de'])
|
|
except BadHeaderError:
|
|
return HttpResponse('Invalid header found.')
|
|
#return redirect('success')
|
|
else:
|
|
print(form.errors)
|
|
r_message="Form invalid"
|
|
return render(request, "email.html", {'form': form,'message':r_message})
|
|
|
|
def successView(request):
|
|
return HttpResponse('Success! Thank you for your message.')
|
|
|