update code

scl-branch
bettleChen 1 year ago
parent 05228943b4
commit ee2fc5dfd9

@ -21,11 +21,8 @@ def login(request):
if student:
request.session["username"] = student.username
request.session["type"] = "student"
<<<<<<< Updated upstream
result = ResponseUtil.ok(student.to_dict(), "login success!")
=======
result = {"code": 0, "message": "login success!"}
>>>>>>> Stashed changes
else:
result = {"code": -1, "message": "username or password error!"}
elif _type == "teacher":
@ -34,20 +31,14 @@ def login(request):
if teacher:
request.session["username"] = teacher.username
request.session["type"] = "teacher"
<<<<<<< Updated upstream
result = ResponseUtil.ok(teacher.to_dict(), "login success!")
=======
result = {"code": 0, "message": "login success!"}
>>>>>>> Stashed changes
else:
result = ResponseUtil.error("username or password error!")
else:
result = ResponseUtil.error("type error!")
return JsonResponse(result)
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
@csrf_exempt
def get_user_info(request):
_type = request.GET.get("type")

@ -22,9 +22,6 @@ from django.http.multipartparser import MultiPartParser
@csrf_exempt
def studnets(request):
if request.method == "POST":
<<<<<<< Updated upstream
=======
<<<<<<< HEAD
try:
request_data = json.loads(request.body)
print(request_data)
@ -41,40 +38,6 @@ def studnets(request):
return JsonResponse(response)
except Exception as E:
return JsonResponse(ResponseUtil.error(E))
=======
>>>>>>> Stashed changes
student = Student()
student.s_username = request.POST.get("s_username")
student.s_password = request.POST.get("s_password")
student.s_name = request.POST.get("s_name")
student.s_sex = request.POST.get("s_sex")
student.s_grade = request.POST.get("s_grade")
student.s_class_name = request.POST.get("s_class_name")
student.s_major = request.POST.get("s_major")
print(student.sid)
print(student.to_dict())
student.s_name = request.POST.get("s_name") or ''
student.s_sex = request.POST.get("s_sex") or ''
student.s_grade = request.POST.get("s_grade") or ''
student.s_class_name = request.POST.get("s_class_name") or ''
student.s_major = request.POST.get("s_major") or ''
student.username = request.POST.get("username")
student.password = request.POST.get("password")
student.name = request.POST.get("name")
student.sex = request.POST.get("sex")
student.grade = request.POST.get("grade")
student.class_name = request.POST.get("class_name")
student.major = request.POST.get("major")
student.sid = request.POST.get("sid")
student.save()
response = {"code": 200, "message": "添加成功!", "data": student.to_dict()}
return JsonResponse(response)
<<<<<<< Updated upstream
=======
>>>>>>> 1e084d20f30e0b66d5e309a483f87ce5cfe06c39
>>>>>>> Stashed changes
elif request.method == "GET":
sid = request.GET.get('sid')
s_name = request.GET.get('s_name')
@ -155,13 +118,6 @@ def studnets(request):
xx = str(value).split('-')[0]
print(xx.split('\r\n'))
return JsonResponse({'code': 200, 'msg': 'success'}, safe=False)
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
>>>>>>> Stashed changes
def get_select_course_by_id(request):
pass

@ -4,41 +4,19 @@ from django.db import models
# Create your models here.
class Teacher(models.Model):
tid = models.AutoField(primary_key=True, verbose_name="教师编号", name="tid")
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
username = models.CharField(max_length=128, verbose_name="用户名", name="username", blank=True, unique=True)
password = models.CharField(max_length=128, verbose_name="密码", name="password", blank=True)
=======
>>>>>>> Stashed changes
>>>>>>> Stashed changes
name = models.CharField(max_length=255, verbose_name="教师名称", name="name", blank=True)
sex = models.CharField(max_length=128, verbose_name="教师性别", name="sex", blank=True)
title = models.CharField(max_length=128, verbose_name="教师职称", name="title", blank=True)
education = models.CharField(max_length=128, verbose_name="教师学历", name="education", blank=True)
dept = models.CharField(max_length=128, verbose_name="教师所属院系", name="dept", blank=True)
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
=======
def to_dict(self):
return {"tid": self.tid, "name": self.name, "sex": self.sex,
"title": self.title, "education": self.education, "dept": self.dept}
>>>>>>> Stashed changes
<<<<<<< HEAD
def to_dict(self):
return {"tid": self.tid, "name": self.name, "sex": self.sex,
"title": self.title, "education": self.education,
"dept": self.dept, "username": self.username, "password": self.password}
=======
>>>>>>> 1e084d20f30e0b66d5e309a483f87ce5cfe06c39
>>>>>>> Stashed changes
def to_dict(self):
return {"tid": self.tid, "name": self.name, "sex": self.sex, "title": self.title,
"education": self.education, "dept": self.dept}
class Meta:
db_table = "teacher"
verbose_name = "教师"

Loading…
Cancel
Save