from django.shortcuts import render, redirect
from backend.models import Patient

# Create your views here.

def index(request):
    if request.method == "POST":
        print(request.POST)
        print(request.FILES)
        p = Patient()
        p.first_name = request.POST.get('firstName')
        p.last_name = request.POST.get('lastName')
        #p.idcard = request.POST.get('idCard')
        p.address = request.POST.get('address')
        p.geolocation = request.POST.get('geo')
        p.birth_date = request.POST.get('bd')
        p.comment = request.POST.get('comment')
        p.tel = request.POST.get('tel')
        p.line_id = request.POST.get('line_id')
        p.photo = request.FILES.get('photo')
        p.patient_status = "request"
        p.save()
        return redirect('success')
    return render(request, 'front/index.html')

def success(request):
    return render(request, 'front/success.html')

def my404(request,exception):
    return render(request, 'front/404.html')
    #return redirect("index")

