").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});
5 |
--------------------------------------------------------------------------------
/management/static/js/login.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function(){
2 |
3 | $('.dropdown').dropdown();
4 | $('.ui.checkbox').checkbox();
5 |
6 | $('.formexample .form')
7 | .form({
8 | on: 'blur',
9 | fields: {
10 | username: {
11 | identifier : 'username',
12 | rules: [
13 | {
14 | type : 'empty',
15 | prompt : '用户名不能为空'
16 | },
17 | {
18 | type:'number',
19 | prompt:'用户名只能是数字'
20 | },
21 | {
22 | type:'exactLength[10]',
23 | prompt:'用户名长度不正确'
24 | }
25 | ]
26 | },
27 |
28 | password: {
29 | identifier : 'password',
30 | rules: [
31 | {
32 | type: 'empty',
33 | prompt: '密码不能为空'
34 | },
35 | {
36 | type:'number',
37 | prompt:'密码只能是数字'
38 | },
39 | {
40 | type:'exactLength[6]',
41 | prompt:'密码长度不正确'
42 | }
43 | ]
44 | }
45 |
46 |
47 | }
48 | });
49 |
50 | })
51 |
52 |
53 | $('.menu .item')
54 | .tab()
55 | ;
56 |
57 |
--------------------------------------------------------------------------------
/management/tests.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from __future__ import unicode_literals
3 |
4 | from django.test import TestCase
5 |
6 | # Create your tests here.
7 |
--------------------------------------------------------------------------------
/management/views.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from __future__ import unicode_literals
3 | from models import Student, Teacher,Lesson,Score
4 | from django.shortcuts import render
5 | from django.http import HttpResponseRedirect
6 | # Create your views here.
7 | def index(request):
8 | return render(request, "login.html")
9 |
10 | def change(request):
11 |
12 | lid = int(request.GET['lid'])
13 | sid = int(request.GET['sid'])
14 | sscore = request.POST.get("score", None)
15 | Score.objects.filter(id=sid).update(score=sscore)
16 | score = Score.objects.filter(lNum=lid)
17 | teacher = Teacher.objects.get(t_lesson_id=lid)
18 | return render(request, "teacher.html", {"teacher": teacher, "score": score})
19 |
20 |
21 |
22 | def login(request):
23 | print request.POST.get("sid", None)
24 | if request.method == "POST":
25 | type = request.POST.get("fruit")
26 | name = request.POST.get("username", None)
27 | ps = request.POST.get("password", None)
28 |
29 | print (type)
30 | if type == "1":
31 |
32 | try:
33 | s = Student.objects.get(s_number=name)
34 | except Student.DoesNotExist:
35 | return HttpResponseRedirect("/")
36 | idnum = int(str(s.ID_number)[-6:])
37 | print idnum
38 | print "ps=", ps
39 | if idnum == int(ps):
40 | student = Student.objects.get(s_number=name)
41 | score = Score.objects.filter(sNum=name)
42 | print score[0].sName
43 | return render(request, "student.html", {"student": student, "score": score})
44 | else:
45 | return HttpResponseRedirect("/")
46 | elif type == "2":
47 |
48 | try:
49 | t = Teacher.objects.get(t_number=name)
50 | except Teacher.DoesNotExist:
51 | return HttpResponseRedirect("/")
52 | tps = t.t_pass
53 | if tps == int(ps):
54 | teacher = Teacher.objects.get(t_number=name)
55 | l_num = teacher.t_lesson_id
56 | score = Score.objects.filter(lNum=l_num)
57 | return render(request, "teacher.html", {"teacher": teacher, "score": score})
58 | else:
59 | return HttpResponseRedirect("/")
60 | else:
61 | return HttpResponseRedirect("/admin/")
62 |
--------------------------------------------------------------------------------
/templates/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
登录
8 |
9 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/templates/student.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
学生管理
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
学号 {{ student.s_number }}
26 |
姓名 {{ student.s_name }}
27 |
性别 {{ student.sex }}
28 |
专业 {{ student.subject }}
29 |
年级 {{ student.grade }}
30 |
身份证号 {{ student.ID_number }}
31 |
籍贯 {{ student.native_place }}
32 |
33 |
34 |
35 |
课程名
36 | 课程编号
37 | 学分
38 | 学时 成绩
39 | {% for s in score %}
40 | {% if s.lName == "嵌入式"%}
41 |
{{ s.lName }}
42 | {{ s.lNum }}
43 | {{ s.lCredit }}
44 | {{ s.lTime }}
45 | {% if s.score != 0 %}
46 | {{ s.score }}
47 | {% else %}
48 | 未出
49 | {% endif %}
50 |
51 | {% endif %}
52 | {% if s.lName != "嵌入式" %}
53 |
{{ s.lName }}
54 | {{ s.lNum }}
55 | {{ s.lCredit }}
56 | {{ s.lTime }}
57 | {% if s.score != 0 %}
58 | {{ s.score }}
59 | {% else %}
60 | 未出
61 | {% endif %}
62 |
63 | {% endif %}
64 | {% endfor %}
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/templates/teacher.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
教师管理
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
28 |
29 |
工号 {{ teacher.t_number }}
30 |
姓名 {{ teacher.t_name }}
31 |
所授课程 {{ teacher.t_lesson_name }}
32 |
所授课程编号 {{ teacher.t_lesson_id }}
33 |
34 |
35 |
36 |
37 |
38 |
39 | |
40 | |
41 | |
42 | |
43 |
44 |
45 |
46 | {% for s in score %}
47 |
48 | {% if s.score == 0 %}
49 | {{ s.sNum }} |
50 | {{ s.sName }} |
51 |
57 | {% endif %}
58 |
59 | {% endfor %}
60 |
61 |
62 |
63 |
64 |
65 |
学号
66 | 姓名
67 | 成绩 备注
68 |
69 | {% for s in score %}
70 | {% if s.score == 0 %}
71 |
{{ s.sNum }}
72 | {{ s.sName }}
73 | {{ s.score }} 未提交
74 |
75 | {% else %}
76 |
{{ s.sNum }}
77 | {{ s.sName }}
78 | {{ s.score }} 已提交
79 | {% endif %}
80 | {% endfor %}
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------