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.

397 lines
19 KiB

from django.http import HttpResponse
from django.shortcuts import render
from django.http import HttpResponseRedirect
from urllib.request import urlopen
from urllib.request import Request
from urllib import parse
import time
import json
import pymysql
import os
import datetime
# 表单
def team(request1):
request1.encoding='utf-8'
dateMatrix=['3月22日','3月23日','3月24日','3月25日','3月26日','3月27日','3月28日','3月29日','3月30日','3月31日','4月1日','4月2日','4月3日','4月4日']
timeMatrix=['10:00-11:00','11:00-12:00','15:00-16:00','16:00-17:00','17:00-18:00','19:00-20:00','20:00-21:00','21:00-22:00','22:00-23:00','9:30-10:45','10:45-12:00','13:30-14:45','15:00-16:15','16:45-18:00']
if 'username' in request1.POST:
username=request1.POST['username']
tel=request1.POST['tel']
context = {}
context["username"]=username
context["tel"]=tel
db = pymysql.connect(host='0.0.0.0', port=3306, user='0', passwd='0', db='0', charset='utf8')
cursor = db.cursor()
findSQL = "select * from teaminterview where username='"+username+"'and tel='"+tel+"'"
res = cursor.execute(findSQL)
if (res != 0):
data=cursor.fetchone()
admi=data[6]
if (admi!='1'):
cursor.close()
cursor = db.cursor()
context["display22"]=""
context["display23"]=""
context["display24"]=""
context["display25"]=""
context["display26"]=""
context["display27"]=""
context["display28"]=""
context["display29"]=""
context["display30"]=""
context["display31"]=""
context["display1"]=""
context["display2"]=""
context["display3"]=""
context["display4"]=""
S=datetime.datetime.strptime('3/22/2019 12:00:00','%m/%d/%Y %H:%M:%S')
a=datetime.datetime.now()
if a>S:
context["display22"]="none"
S=datetime.datetime.strptime('3/22/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display23"]="none"
S=datetime.datetime.strptime('3/23/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display24"]="none"
S=datetime.datetime.strptime('3/24/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display25"]="none"
S=datetime.datetime.strptime('3/25/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display26"]="none"
S=datetime.datetime.strptime('3/26/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display27"]="none"
S=datetime.datetime.strptime('3/27/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display28"]="none"
S=datetime.datetime.strptime('3/28/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display29"]="none"
S=datetime.datetime.strptime('3/29/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display30"]="none"
S=datetime.datetime.strptime('3/30/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display31"]="none"
S=datetime.datetime.strptime('3/31/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display1"]="none"
S=datetime.datetime.strptime('4/1/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display2"]="none"
S=datetime.datetime.strptime('4/2/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display3"]="none"
S=datetime.datetime.strptime('4/3/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S:
context["display4"]="none"
date=[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
time=[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
numberMatrix = [[0 for i in range(14)] for i in range(14)]
for i in date:
for j in time:
findSQL = "select * from teamtimes where date='"+str(i)+"'and time='"+str(j)+"'"
res = cursor.execute(findSQL)
if (res!=0):
number=(cursor.fetchone())[2]
numberMatrix[i][j]=number
context["numberMatrix"]=numberMatrix
cursor.close()
db.close()
return render(request1,'teaminterview.html',context)
else:
date = data[1]
time = data[2]
if (date!='' and time!=''):
context["date"]=dateMatrix[int(date)]
context["time"]=timeMatrix[int(time)]
context["type"]=data[7]
cursor.close()
db.close()
return render(request1,'info.html',context)
else:
updateSQL ="update teaminterview set admi = '0' where username='"+username+"'and tel='"+tel+"'"
try:
# 执行SQL语句
res=cursor.execute(updateSQL)
# 提交到数据库执行
db.commit()
except:
# 发生错误时回滚
db.rollback()
return render(request1,'Rechoose.html',context)
else:
cursor.close()
db.close()
return render(request1,'404.html',context)
else:
return render(request1,'404.html',context)
def post(request1):
request1.encoding='utf-8'
request=request1.POST
if ('division' in request1.POST):
intime=datetime.datetime.now().strftime("%m/%d/%Y %H:%M:%S")
vtype=request['division']
if (vtype=="线上面试"):
try:
date=request['Idate0']
time=request['Itime0']
except:
return render(request1,'Fail.html')
if date=='' or time =='':
return render(request1,'Fail.html')
S=datetime.datetime.strptime('3/22/2019 12:00:00','%m/%d/%Y %H:%M:%S')
a=datetime.datetime.now()
if a>S and date=='0':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/22/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='1':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/23/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='2':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/24/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='3':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/25/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='4':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/26/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='5':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/27/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='6':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/28/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='7':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/29/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='8':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/30/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='9':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/31/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='10':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/1/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='11':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/2/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='12':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/3/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='13':
return render(request1,'Fail_time.html')
elif (vtype=="线下成都面试"):
try:
date=request['Idate1']
time=request['Itime1']
except:
return render(request1,'Fail.html')
if date=='' or time =='':
return render(request1,'Fail.html')
S=datetime.datetime.strptime('3/22/2019 12:00:00','%m/%d/%Y %H:%M:%S')
a=datetime.datetime.now()
if a>S and date=='0':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/22/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='1':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/23/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='2':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/24/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='3':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/25/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='4':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/26/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='5':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/27/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='6':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/28/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='7':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/29/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='8':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/30/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='9':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/31/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='10':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/1/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='11':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/2/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='12':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/3/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='13':
return render(request1,'Fail_time.html')
elif (vtype=="线下天津面试"):
try:
date=request['Idate2']
time=request['Itime2']
except:
return render(request1,'Fail.html')
if date=='' or time =='':
return render(request1,'Fail.html')
S=datetime.datetime.strptime('3/22/2019 12:00:00','%m/%d/%Y %H:%M:%S')
a=datetime.datetime.now()
if a>S and date=='0':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/22/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='1':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/23/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='2':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/24/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='3':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/25/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='4':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/26/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='5':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/27/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='6':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/28/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='7':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/29/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='8':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/30/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='9':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/31/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='10':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/1/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='11':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/2/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='12':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/3/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='13':
return render(request1,'Fail_time.html')
elif (vtype=="线下北京面试"):
try:
date=request['Idate3']
time=request['Itime3']
except:
return render(request1,'Fail.html')
if date=='' or time =='':
return render(request1,'Fail.html')
S=datetime.datetime.strptime('3/22/2019 12:00:00','%m/%d/%Y %H:%M:%S')
a=datetime.datetime.now()
if a>S and date=='0':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/22/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='1':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/23/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='2':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/24/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='3':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/25/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='4':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/26/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='5':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/27/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='6':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/28/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='7':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/29/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='8':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/30/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='9':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('3/31/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='10':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/1/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='11':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/2/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='12':
return render(request1,'Fail_time.html')
S=datetime.datetime.strptime('4/3/2019 21:00:00','%m/%d/%Y %H:%M:%S')
if a>S and date=='13':
return render(request1,'Fail_time.html')
username=request['username']
tel=request['tel']
db = pymysql.connect(host='0.0.0.0', port=3306, user='0', passwd='0', db='0', charset='utf8')
cursor = db.cursor()
findSQL = "select * from teamtimes where date='"+date+"'and time='"+time+"'"
res = cursor.execute(findSQL)
if (res!=0):
data=cursor.fetchone()
number=data[2]
if (int(number)<8):
cursor.close()
cursor = db.cursor()
updateSQL ="update teaminterview set date ='"+str(date)+"',time='"+str(time)+"',admi = '1',intime='"+str(intime)+"',vtype='"+str(vtype)+"' where username='"+username+"'and tel='"+tel+"'"
try:
# 执行SQL语句
res=cursor.execute(updateSQL)
# 提交到数据库执行
db.commit()
except:
# 发生错误时回滚
db.rollback()
else:
return render('FailNumber.html')
else:
cursor.close()
cursor = db.cursor()
updateSQL = "update teaminterview set date ='"+str(date)+"',time='"+str(time)+"',admi = '1',intime='"+str(intime)+"',vtype='"+str(vtype)+"' where username='"+username+"'and tel='"+tel+"'"
try:
# 执行SQL语句
res=cursor.execute(updateSQL)
# 提交到数据库执行
db.commit()
except:
# 发生错误时回滚
db.rollback()
cursor.close()
db.close()
return render(request1,'OK.html')
return render(request1,'Fail.html')
def login(request1):
return render(request1,'firstlogin.html')
# 接收请求数据
def result(request1):
return render(request1,'404.html')