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.forms import ContactForm # Create your views here. def index(request): termine=Termin.objects.filter(date__gt=timezone.now()).order_by( 'date') context ={ "termine":termine, "data":"Gfg is the best", "list":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] } # return response with template and context 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 = ContactForm() else: form = ContactForm(request.POST) if form.is_valid(): subject = form.cleaned_data['subject'] from_email = form.cleaned_data['from_email'] message = form.cleaned_data['message'] try: send_mail(subject, message, from_email, ['tanja@kuntner.de']) except BadHeaderError: return HttpResponse('Invalid header found.') return redirect('success') return render(request, "email.html", {'form': form}) def successView(request): return HttpResponse('Success! Thank you for your message.')