上传文件至 'test/leave'
This commit is contained in:
parent
a9a8975287
commit
f880d9d278
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Leave(models.Model):
|
||||
classes = models.CharField(max_length=255, verbose_name="班级")
|
||||
s_id = models.CharField(max_length=255, verbose_name="学号")
|
||||
name = models.CharField(max_length=255, verbose_name="班级")
|
||||
dormitory = models.CharField(max_length=255, verbose_name="寝室号")
|
||||
phone = models.CharField(max_length=255, verbose_name="手机号码")
|
||||
reason = models.TextField(verbose_name="离校原因")
|
||||
l_time = models.CharField(max_length=255, verbose_name="离校时间")
|
||||
b_time = models.CharField(max_length=255, verbose_name="返校时间")
|
||||
place = models.CharField(max_length=255, verbose_name="前往地点")
|
||||
p_phone = models.CharField(max_length=255, verbose_name="父母联系方式")
|
||||
what = models.CharField(max_length=255,verbose_name="什么请假")
|
||||
status = models.CharField(max_length=225, verbose_name="状态")
|
||||
|
||||
class Meta:
|
||||
db_table = 'leaves'
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
a = [{"1":"1","2":"2"},{"1":"1","2":"2"}]
|
||||
c = {"1":"1","2":"2"}
|
||||
|
||||
for i in a:
|
||||
print(i)
|
||||
i["a"]=i.pop("1")
|
||||
i["b"]=i.pop("2")
|
||||
print(a)
|
||||
# e = 0
|
||||
# for i in b:
|
||||
# c[i]=c.pop(d[e])
|
||||
# e = e+1
|
||||
# print(c)
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,167 @@
|
|||
import json
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from django.http import JsonResponse
|
||||
from leave.models import Leave
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
# Create your views here.
|
||||
def sub_leave_school(request):
|
||||
if request.method == "POST":
|
||||
json_data = request.body
|
||||
leave_school_data = json.loads(json_data)
|
||||
classes = leave_school_data["classes"]
|
||||
s_id = leave_school_data["s_id"]
|
||||
name = leave_school_data["name"]
|
||||
dormitory = leave_school_data["dormitory"]
|
||||
phone = leave_school_data["phone"]
|
||||
reason = leave_school_data["reason"]
|
||||
l_time = leave_school_data["l_time"]
|
||||
b_time = leave_school_data["b_time"]
|
||||
place = leave_school_data["place"]
|
||||
p_phone = leave_school_data["p_phone"]
|
||||
what = leave_school_data["what"]
|
||||
status = leave_school_data["status"]
|
||||
le = Leave(classes=classes, s_id=s_id, name=name, dormitory=dormitory, phone=phone, reason=reason,
|
||||
l_time=l_time, b_time=b_time, place=place, p_phone=p_phone, what=what, status=status)
|
||||
le.save()
|
||||
result = {"code": "200", "meg": "申请成功"}
|
||||
return JsonResponse(result, safe=False)
|
||||
|
||||
|
||||
def get_leave_school(request):
|
||||
classes_list = []
|
||||
s_id_list = []
|
||||
name_list = []
|
||||
dormitory_list = []
|
||||
phone_list = []
|
||||
reason_list = []
|
||||
l_time_list = []
|
||||
b_time_list = []
|
||||
place_list = []
|
||||
p_phone_list = []
|
||||
what_list = []
|
||||
status_list = []
|
||||
if request.method == "POST":
|
||||
sid = request.headers["sid"]
|
||||
leave_school_list = Leave.objects.filter(s_id=sid)
|
||||
for i in leave_school_list:
|
||||
classes = i.classes
|
||||
classes_list.append(classes)
|
||||
s_id = i.s_id
|
||||
s_id_list.append(s_id)
|
||||
name = i.name
|
||||
name_list.append(name)
|
||||
dormitory = i.dormitory
|
||||
dormitory_list.append(dormitory)
|
||||
phone = i.phone
|
||||
phone_list.append(phone)
|
||||
reason = i.reason
|
||||
reason_list.append(reason)
|
||||
l_time = i.l_time
|
||||
l_time_list.append(l_time)
|
||||
b_time = i.b_time
|
||||
b_time_list.append(b_time)
|
||||
place = i.place
|
||||
place_list.append(place)
|
||||
p_phone = i.p_phone
|
||||
p_phone_list.append(p_phone)
|
||||
what = i.what
|
||||
what_list.append(what)
|
||||
status = i.status
|
||||
status_list.append(status)
|
||||
result = {"code": "200", "meg": "申请成功",
|
||||
"data": {"classes": classes_list, "s_id": s_id_list, "name": name_list, "dormitory": dormitory_list,
|
||||
"phone": phone_list, "reason": reason_list, "l_time": l_time_list, "b_time": b_time_list,
|
||||
"place": place_list,
|
||||
"p_phone": p_phone_list, "what": what_list, "status": status_list
|
||||
}}
|
||||
return JsonResponse(result, safe=False)
|
||||
|
||||
|
||||
def teacher_get_leave_school(request):
|
||||
id_list = []
|
||||
classes_list = []
|
||||
s_id_list = []
|
||||
name_list = []
|
||||
dormitory_list = []
|
||||
phone_list = []
|
||||
reason_list = []
|
||||
l_time_list = []
|
||||
b_time_list = []
|
||||
place_list = []
|
||||
p_phone_list = []
|
||||
what_list = []
|
||||
status_list = []
|
||||
if request.method == "POST":
|
||||
classes = request.headers["classes"]
|
||||
leave_school_list = Leave.objects.filter(classes=classes)
|
||||
for i in leave_school_list:
|
||||
id = i.id
|
||||
id_list.append(id)
|
||||
classes = i.classes
|
||||
classes_list.append(classes)
|
||||
s_id = i.s_id
|
||||
s_id_list.append(s_id)
|
||||
name = i.name
|
||||
name_list.append(name)
|
||||
dormitory = i.dormitory
|
||||
dormitory_list.append(dormitory)
|
||||
phone = i.phone
|
||||
phone_list.append(phone)
|
||||
reason = i.reason
|
||||
reason_list.append(reason)
|
||||
l_time = i.l_time
|
||||
l_time_list.append(l_time)
|
||||
b_time = i.b_time
|
||||
b_time_list.append(b_time)
|
||||
place = i.place
|
||||
place_list.append(place)
|
||||
p_phone = i.p_phone
|
||||
p_phone_list.append(p_phone)
|
||||
what = i.what
|
||||
what_list.append(what)
|
||||
status = i.status
|
||||
status_list.append(status)
|
||||
result = {"code": "200", "meg": "申请成功",
|
||||
"data": {"id": id_list, "classes": classes_list, "s_id": s_id_list, "name": name_list,
|
||||
"dormitory": dormitory_list,
|
||||
"phone": phone_list, "reason": reason_list, "l_time": l_time_list, "b_time": b_time_list,
|
||||
"place": place_list,
|
||||
"p_phone": p_phone_list, "what": what_list, "status": status_list
|
||||
}}
|
||||
return JsonResponse(result, safe=False)
|
||||
|
||||
|
||||
def get_leave_school_detailed(request):
|
||||
if request.method == "POST":
|
||||
json_data = request.body
|
||||
leave_school_id = json.loads(json_data)
|
||||
id = leave_school_id["id"]
|
||||
leave_school_data = Leave.objects.get(id=id)
|
||||
dic = {"classes": leave_school_data.classes, "s_id": leave_school_data.s_id, "name": leave_school_data.name,
|
||||
"dormitory": leave_school_data.dormitory, "phone": leave_school_data.phone,
|
||||
"reason": leave_school_data.reason,
|
||||
"l_time": leave_school_data.l_time, "b_time": leave_school_data.b_time, "place": leave_school_data.place,
|
||||
"p_phone": leave_school_data.p_phone, "what": leave_school_data.what, "status": leave_school_data.status
|
||||
}
|
||||
result = {"code": 200, "msg": "申请成功", "data": dic}
|
||||
return JsonResponse(result, safe=False)
|
||||
|
||||
|
||||
def success_leave(request):
|
||||
if request.method == "POST":
|
||||
json_data = request.body
|
||||
leave_school_id = json.loads(json_data)
|
||||
id = leave_school_id["id"]
|
||||
status = leave_school_id["status"]
|
||||
leave_school_data = Leave.objects.get(id=id)
|
||||
leave_school_data.status = status
|
||||
leave_school_data.save()
|
||||
result = {"code": 200, "msg": "申请成功"}
|
||||
return JsonResponse(result, safe=False)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue