diff --git a/21412030537-吕宜芮-计科2105-学生选课系统.doc b/21412030537-吕宜芮-计科2105-学生选课系统.doc new file mode 100644 index 0000000..503f5cb Binary files /dev/null and b/21412030537-吕宜芮-计科2105-学生选课系统.doc differ diff --git a/app01/migrations/0001_initial.py b/app01/migrations/0001_initial.py index aed1992..8beb290 100644 --- a/app01/migrations/0001_initial.py +++ b/app01/migrations/0001_initial.py @@ -1,5 +1,3 @@ -# Generated by Django 3.2.13 on 2022-06-13 12:20 - from django.db import migrations, models import django.db.models.deletion diff --git a/app01/templates/course_manage.html b/app01/templates/course_manage.html index 00f0838..bb017f2 100644 --- a/app01/templates/course_manage.html +++ b/app01/templates/course_manage.html @@ -5,7 +5,7 @@
- +
diff --git a/app01/views.py b/app01/views.py index c1e4f85..c401b16 100644 --- a/app01/views.py +++ b/app01/views.py @@ -13,22 +13,19 @@ def login(request): return render(request, 'login.html', ) if request.method == 'POST': - # 获取form表单参数 role = request.POST.get('role') username = request.POST.get('username') pwd = request.POST.get('pwd') - # 验证身份,用户名,密码 - if role == '0': # 如果身份是学生 - # 从学生表中查询是否有匹配结果 + + if role == '0': # 如果身份是学生 result = models.StuInfo.objects.filter(username=username, password=pwd) - # 如果用户存在的话 + if result.exists(): - # 重定向到学生主页,把学生ID sid 传到前台页面 return redirect('student_index', sid=result.first().id) else: return HttpResponse('failed') - elif role == '1': - + + elif role == '1': # 如果身份是管理员 result = models.AdminInfo.objects.filter(username=username, password=pwd) if result.exists(): return redirect('/manage/homepage/') @@ -182,7 +179,7 @@ def student_index(request, sid): student_id = request.POST.get('sid') course_obj = models.CourseInfo.objects.get(pk=course_id) student_obj = models.StuInfo.objects.get(pk=student_id) - # 添加学生选课信息 + # 添加选课信息 student_obj.course.add(course_obj) return HttpResponse('success')