from django.shortcuts import render
from django.shortcuts import HttpResponse
from .models import Ad
from .forms import ResumeForm


# Create your views here.
def contact(request):
    return render(request,'contact.html')


def recruit(request):
    # html = '<html><body>加入恒达</body></html>'
    # return HttpResponse(html)
    AdList = Ad.objects.all().order_by('-publishDate')
    if request.method == 'POST':
        resumeForm = ResumeForm(data=request.POST,files=request.FILES)
        if resumeForm.is_valid():
            resumeForm.save()
            return render(request,'success.html',{
                'active_menu':'contactus',
                'sub_menu':'recruit',
            })
    else:
        resumeForm = ResumeForm()
    return render(request, 'recruit.html',{
        'active_menu':'contactus',
        'sub_menu':'recruit',
        'AdList':AdList,
        'resumeForm':resumeForm,
    })