def volunteer_info(request): ''' 后端需要在这里获取数据并返回 ''' if 'teacher_id' not in request.session.keys(): return redirect('/login/') id = request.GET.get('id') print request.GET account = vol.idToAccountVolunteer(str(id)) volunteer = vol.getVolunteerAll(account) vol_dic = vol.getVolunteerAllDictByAccount(account) dic = { 'id': vol_dic[Volunteer.ID], 'user_name': vol_dic[Volunteer.ACCOUNT], 'realName': vol_dic[Volunteer.REAL_NAME], 'idNumber': vol_dic[Volunteer.ID_NUMBER], 'sex': vol_dic[Volunteer.SEX], 'nation': vol_dic[Volunteer.NATION], 'birth_year': vol_dic[Volunteer.BIRTH].strftime("%Y"), 'birth_month': vol_dic[Volunteer.BIRTH].strftime("%m"), 'birth_date': vol_dic[Volunteer.BIRTH].strftime("%d"), 'department': vol_dic[Volunteer.MAJOR][0], 'class': vol_dic[Volunteer.CLASSROOM], 'phone': vol_dic[Volunteer.PHONE], 'email': vol_dic[Volunteer.EMAIL], 'province': vol_dic[Volunteer.PROVINCE], 'distribute': '1 | 2 | 3', 'qqn': vol_dic[Volunteer.QQ], 'weichat': vol_dic[Volunteer.WECHAT], 'teacher': '白老师 | 李老师', 'comment': vol_dic[Volunteer.COMMENT], } group_list = vol.getVolunteerGroupIDListString(volunteer).split(' ') if '' in group_list: group_list.remove('') for i in range(0, 5): if i < len(group_list) and group_list[i].strip() != '': dic['group' + str(i + 1)] = int(group_list[i]) else: dic['group' + str(i + 1)] = 0 dic['grouplist'] = [' '] all_group = back.getGroupbyDict({}) for item in all_group: dic['grouplist'].append(back.getGroupAllDictByObject(item)['id']) dic['forbid'] = int(vol_dic[Volunteer.QUANXIAN]) dic['forbidlist'] = PERMISSION_LIST id_ = request.session.get('teacher_id', -1) return render(request, 'teacher/volunteer_info.html', { 'dict': dic, 'id': id_ })
def back_to_profile(request, id): account = stu.idToAccountStudent(id) stu_dic = stu.getStudentAllDictByAccount(account) student = stu.getStudentAll(account) (rank, tmp) = stu.getStudentEstimateRank(student) dic = { 'name': stu_dic[Student.REAL_NAME], 'identification': stu_dic[Student.ID_NUMBER], 'sex': stu_dic[Student.SEX], 'nation': stu_dic[Student.NATION], 'birth': stu_dic[Student.BIRTH].strftime("%m/%d/%Y"), 'province': stu_dic[Student.PROVINCE], 'phone': stu_dic[Student.PHONE], 'email': stu_dic[Student.EMAIL], 'wenli': stu_dic[Student.TYPE], 'address': stu_dic[Student.ADDRESS], 'dadName': stu_dic[Student.DAD_NAME], 'dadPhone': stu_dic[Student.DAD_PHONE], 'momName': stu_dic[Student.MOM_NAME], 'momPhone': stu_dic[Student.MOM_PHONE], 'school': stu_dic[Student.SCHOOL], 'stu_class': stu_dic[Student.CLASSROOM], 'tutorName': stu_dic[Student.TUTOR_NAME], 'tutorPhone': stu_dic[Student.TUTOR_PHONE], Student.MAJOR: stu_dic[Student.MAJOR], Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST], Student.RANK_LIST: stu_dic[Student.RANK_LIST], Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST], 'realScore': stu_dic[Student.REAL_SCORE], 'relTeacher': stu_dic[Student.DUIYING_TEACHER], 'comment': stu_dic[Student.COMMENT], 'estimateScore': getStudentEstimateScore(stu.getStudentAll(account)), 'estimateRank': str(rank) + '/' + str(tmp) } group_list = stu.getStudentGroupIDListString(student).split(' ') for i in range(1, 6): if i < len(group_list): dic['group' + str(i)] = group_list[i] else: dic['group' + str(i)] = '0' dic['grouplist'] = [' '] all_group = back.getGroupbyDict({}) for item in all_group: dic['grouplist'].append(back.getGroupAllDictByObject(item)['id']) print '----------------*****--------' return redirect('/student/profile/?auth=0')
def distribute_student(request): ''' GET newteam 新建组 ''' if 'newteam' in request.GET: back.createGroupbyDict({Group.NAME: 'new name'}) num = len(back.getGroupbyDict({})) return JsonResponse({'teamnum': num}) ''' GET id teamid 删除 ''' if ('id' in request.GET) and ('teamid' in request.GET) and ('class' in request.GET): print 'cao ', request.GET group_id = int(request.GET['teamid']) isDelStudent = int(request.GET['class']) if isDelStudent == 1: stu_id = str(request.GET['id']) group = back.getGroupbyDict({Group.ID: group_id})[0] group_dic = back.getGroupAllDictByObject(group) # print 'group_dic', group_dic stu_id_list = group_dic[Group.STU_LIST].split('_') if stu_id in stu_id_list: stu_id_list.remove(stu_id) str_list = '_'.join(stu_id_list) print 'haha', str_list back.setGroup(group, Group.STU_LIST, str_list) else: vol_id = str(request.GET['id']) group = back.getGroupbyDict({Group.ID: group_id})[0] group_dic = back.getGroupAllDictByObject(group) vol_id_list = group_dic[Group.VOL_LIST].split('_') if vol_id in vol_id_list: vol_id_list.remove(vol_id) str_list = '_'.join(vol_id_list) back.setGroup(group, Group.VOL_LIST, str_list) return JsonResponse({'success': 1}) else: team_list = [] group_list = back.getGroupbyDict({}) for group in group_list: group_dic = back.getGroupAllDictByObject(group) team = {} team['teamleader'] = str(group_dic[Group.ID]) team['teamname'] = str(group_dic[Group.NAME]) team['volunteer'] = {} team['student'] = {} print 'adf', group_dic if len(group_dic[Group.VOL_LIST].strip()) > 0: vol_id_list = group_dic[Group.VOL_LIST].split('_') for i in range(0, len(vol_id_list)): if vol_id_list[i].strip() == '': continue vol_account = vol.idToAccountVolunteer(str(vol_id_list[i])) vol_dic = vol.getVolunteerAllDictByAccount(vol_account) dic = { 'user_name': vol_dic[Volunteer.ACCOUNT], 'name': vol_dic[Volunteer.REAL_NAME], 'id': vol_dic[Volunteer.ID], } team['volunteer'][('volunteer' + str(i))] = dic if len(group_dic[Group.STU_LIST].strip()) > 0: stu_id_list = group_dic[Group.STU_LIST].split('_') for i in range(0, len(stu_id_list)): if stu_id_list[i].strip() == '': continue stu_account = stu.idToAccountStudent(str(stu_id_list[i])) stu_dic = stu.getStudentAllDictByAccount(stu_account) dic = { 'user_name': stu_dic[Student.ACCOUNT], 'name': stu_dic[Student.REAL_NAME], 'id': stu_dic[Student.ID], } team['student'][('student' + str(i))] = dic team_list.append(team) team_list.reverse() id_ = request.session.get('teacher_id', -1) return render(request, 'teacher/distribute_student.html', { 'dict': team_list, 'id': id_ })
def volunteer_info_edit(request): if request.method == 'POST': ''' 后端需要在这里改代码,保存传进来的数据到数据库,并返回正确的dict ''' id = request.GET.get('id') account = vol.idToAccountVolunteer(str(id)) volunteer = vol.getVolunteerAll(account) # 志愿者页面上目前可以修改的,之后会在有所改动 phone = request.POST.get('phone', '110') email = request.POST.get('email', '110@qq') weichat = request.POST.get('weichat', '110@qq') comment = request.POST.get('comment', '110') qqn = request.POST.get('qqn', '110') vol.setVolunteer(account, Volunteer.QUANXIAN, int(request.POST.get('forbid', '1'))) vol.setVolunteer(account, Volunteer.PHONE, phone) vol.setVolunteer(account, Volunteer.EMAIL, email) vol.setVolunteer(account, Volunteer.WECHAT, weichat) vol.setVolunteer(account, Volunteer.COMMENT, comment) vol.setVolunteer(account, Volunteer.QQ, qqn) # vol.setVolunteerGroupbyList(volunteer, [10,9,8]) return JsonResponse(request.POST) else: ''' 后端需要在这里改代码,从数据库读取正确的dict,并返回 ''' if 'teacher_id' not in request.session.keys(): return redirect('/login/') print request.GET id = request.GET.get('id') account = vol.idToAccountVolunteer(str(id)) volunteer = vol.getVolunteerAll(account) vol_dic = vol.getVolunteerAllDictByAccount(account) dic = { 'id': vol_dic[Volunteer.ID], 'user_name': vol_dic[Volunteer.ACCOUNT], 'realName': vol_dic[Volunteer.REAL_NAME], 'idNumber': vol_dic[Volunteer.ID_NUMBER], 'sex': vol_dic[Volunteer.SEX], 'nation': vol_dic[Volunteer.NATION], 'birth_year': vol_dic[Volunteer.BIRTH].strftime("%Y"), 'birth_month': vol_dic[Volunteer.BIRTH].strftime("%m"), 'birth_date': vol_dic[Volunteer.BIRTH].strftime("%d"), 'department': vol_dic[Volunteer.MAJOR][0], 'class': vol_dic[Volunteer.CLASSROOM], 'phone': vol_dic[Volunteer.PHONE], 'email': vol_dic[Volunteer.EMAIL], 'province': vol_dic[Volunteer.PROVINCE], 'distribute': '1 | 2 | 3', 'qqn': vol_dic[Volunteer.QQ], 'weichat': vol_dic[Volunteer.WECHAT], 'teacher': '白老师 | 李老师', 'comment': vol_dic[Volunteer.COMMENT], } group_list = vol.getVolunteerGroupIDListString(volunteer).split(' ') if '' in group_list: group_list.remove('') for i in range(0, 5): if i < len(group_list) and group_list[i].strip() != '': dic['group' + str(i + 1)] = int(group_list[i]) else: dic['group' + str(i + 1)] = 0 dic['grouplist'] = [' '] all_group = back.getGroupbyDict({}) for item in all_group: dic['grouplist'].append(back.getGroupAllDictByObject(item)['id']) print dic['group1'], dic['group2'], dic['group3'], dic['group4'], dic[ 'group5'] print dic['grouplist'] dic['forbid'] = int(vol_dic[Volunteer.QUANXIAN]) dic['forbidlist'] = PERMISSION_LIST print 'wo ca lei', dic['forbid'], dic['forbidlist'] id_ = request.session.get('teacher_id', -1) return render(request, 'teacher/volunteer_info_edit.html', { 'dict': dic, 'id': id_ })
def student_info_show(request): t = get_template('teacher/student_info.html') id = request.GET.get('id', -1) if id == -1: return HttpResponse('Access denied') account = stu.idToAccountStudent(str(id)) student = stu.getStudentAll(account) stu_dic = stu.getStudentAllDictByAccount(account) dic = { Student.ID: stu_dic[Student.ID], Student.ACCOUNT: stu_dic[Student.ACCOUNT], Student.REAL_NAME: stu_dic[Student.REAL_NAME], Student.BIRTH: stu_dic[Student.BIRTH].strftime("%Y-%m-%d"), Student.ID_NUMBER: stu_dic[Student.ID_NUMBER], Student.TYPE: stu_dic[Student.TYPE], Student.SEX: stu_dic[Student.SEX], Student.NATION: stu_dic[Student.NATION], Student.SCHOOL: stu_dic[Student.SCHOOL], Student.CLASSROOM: stu_dic[Student.CLASSROOM], Student.ADDRESS: stu_dic[Student.ADDRESS], Student.PHONE: stu_dic[Student.PHONE], Student.EMAIL: stu_dic[Student.EMAIL], Student.DAD_PHONE: stu_dic[Student.DAD_PHONE], Student.MOM_PHONE: stu_dic[Student.MOM_PHONE], Student.TUTOR_NAME: stu_dic[Student.TUTOR_NAME], Student.TUTOR_PHONE: stu_dic[Student.TUTOR_PHONE], Student.PROVINCE: stu_dic[Student.PROVINCE], Student.MAJOR: stu_dic[Student.MAJOR], Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST], Student.RANK_LIST: stu_dic[Student.RANK_LIST], Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST], Student.ESTIMATE_SCORE: getStudentEstimateScore(stu.getStudentAll(account)), Student.REAL_SCORE: stu_dic[Student.REAL_SCORE], Student.REGISTER_CODE: stu_dic[Student.REGISTER_CODE], Student.ADMISSION_STATUS: stu_dic[Student.ADMISSION_STATUS], Student.TEACHER_LIST: stu_dic[Student.TEACHER_LIST], Student.VOLUNTEER_ACCOUNT_LIST: stu_dic[Student.VOLUNTEER_ACCOUNT_LIST], Student.COMMENT: stu_dic[Student.COMMENT], Student.MOM_NAME: stu_dic[Student.MOM_NAME], Student.DAD_NAME: stu_dic[Student.DAD_NAME], Student.DUIYING_TEACHER: stu_dic[Student.DUIYING_TEACHER], } group_list = stu.getStudentGroupIDListString(student).split(' ') if '' in group_list: group_list.remove('') for i in range(0, 5): if i < len(group_list) and group_list[i] != '': dic['group' + str(i + 1)] = int(group_list[i]) else: dic['group' + str(i + 1)] = 0 dic['grouplist'] = [' '] all_group = back.getGroupbyDict({}) for item in all_group: dic['grouplist'].append(back.getGroupAllDictByObject(item)['id']) print dic['grouplist'] dic['forbid'] = int(stu_dic[Student.QUANXIAN]) dic['forbidlist'] = PERMISSION_LIST print 'byr pinwei ', dic['forbid'], dic['forbidlist'] id_ = request.session.get('teacher_id', -1) return HttpResponse(t.render({'student': dic, 'id': id_}))
def student_info_edit(request): if request.method == 'POST': ''' 后端需要在这里改代码,保存传进来的数据到数据库,并返回正确的dict ''' id = request.GET.get('id') account = stu.idToAccountStudent(str(id)) info_dict = request.POST.copy() for i in range(1, 7): if info_dict['majorSelect' + str(i)].strip() == '': info_dict['majorSelect' + str(i)] = '0' for i in range(1, 4): if info_dict['testScore' + str(i)].strip() == '': info_dict['testScore' + str(i)] = '0' for i in range(1, 4): if info_dict['rank' + str(i)].strip() == '': info_dict['rank' + str(i)] = '0' for i in range(1, 4): if info_dict['rank' + str(i)].strip() == '': info_dict['rank' + str(i)] = '0' for i in range(1, 4): if info_dict['rank' + str(i) + str(i)].strip() == '': info_dict['rank' + str(i) + str(i)] = '0' if info_dict['estimateScore'].strip() == '': info_dict['estimateScore'] = '0' if info_dict['realScore'].strip() == '': info_dict['realScore'] = '0' if info_dict['admissionStatus'].strip() == '': info_dict['admissionStatus'] = '0' print info_dict dic = { 'type': int(info_dict.get('type', '110')), 'province': int(info_dict.get('province', '110')), 'phone': info_dict.get('phone', '110'), 'email': info_dict.get('email', '110'), 'address': info_dict.get('address', '110'), 'dadName': info_dict.get('dadName', '110'), 'dadPhone': info_dict.get('dadPhone', '110'), 'momName': info_dict.get('momName', '110'), 'momPhone': info_dict.get('momPhone', '110'), 'school': info_dict.get('school', '110'), 'stu_class': info_dict.get('stu_class', '110'), 'tutorName': info_dict.get('tutorName', '110'), 'tutorPhone': info_dict.get('tutorPhone', '110'), 'majorSelect1': int(info_dict.get('majorSelect1', '110')), 'majorSelect2': int(info_dict.get('majorSelect2', '110')), 'majorSelect3': int(info_dict.get('majorSelect3', '110')), 'majorSelect4': int(info_dict.get('majorSelect4', '110')), 'majorSelect5': int(info_dict.get('majorSelect5', '110')), 'majorSelect6': int(info_dict.get('majorSelect6', '110')), 'testScore1': int(info_dict.get('testScore1', '110')), 'testScore2': int(info_dict.get('testScore2', '110')), 'testScore3': int(info_dict.get('testScore3', '110')), 'rank1': int(info_dict.get('rank1', '110')), 'rank11': int(info_dict.get('rank11', '110')), 'rank2': int(info_dict.get('rank2', '110')), 'rank22': int(info_dict.get('rank22', '110')), 'rank3': int(info_dict.get('rank3', '110')), 'rank33': int(info_dict.get('rank33', '110')), 'estimateScore': getStudentEstimateScore(stu.getStudentAll(account)), 'realScore': int(info_dict.get('realScore', '110')), 'admissionStatus': info_dict.get('admissionStatus', '110'), 'relTeacher': info_dict.get('relTeacher', '110'), 'relVolunteer': info_dict.get('relVolunteer', '110'), 'comment': info_dict.get('comment', '110') + info_dict.get('newcomment', '110') + '\n', 'team1': info_dict.get('team1', '1'), 'team2': info_dict.get('team2', '1'), 'team3': info_dict.get('team3', '1'), 'team4': info_dict.get('team4', '1'), 'team5': info_dict.get('team5', '1'), 'forbid': int(info_dict.get('forbid', '1')), 'name': info_dict.get('realName'), 'id_card': info_dict.get('idNumber'), 'sex': int(info_dict.get('sex')), 'nation': int(info_dict.get('nation')), 'birth': info_dict.get('birth'), } if info_dict.get('newcomment', '110').strip() == '': dic['comment'] = info_dict.get('comment', '110') stu.setStudent(account, Student.REAL_NAME, dic['name']) stu.setStudent(account, Student.ID_NUMBER, dic['id_card']) stu.setStudent(account, Student.SEX, dic['sex']) stu.setStudent(account, Student.NATION, dic['nation']) try: tmp = dic['birth'].split('-') stu.setStudent( account, Student.BIRTH, datetime.date(int(tmp[0]), int(tmp[1]), int(tmp[2]))) except: pass print 'asdfasdfasdf-----' stu.setStudent(account, Student.TYPE, dic['type']) stu.setStudent(account, Student.PROVINCE, dic['province']) stu.setStudent(account, Student.PHONE, dic['phone']) stu.setStudent(account, Student.EMAIL, dic['email']) stu.setStudent(account, Student.ADDRESS, dic['address']) stu.setStudent(account, Student.TYPE, dic['type']) stu.setStudent(account, Student.DAD_PHONE, dic['dadPhone']) stu.setStudent(account, Student.MOM_PHONE, dic['momPhone']) stu.setStudent(account, Student.SCHOOL, dic['school']) stu.setStudent(account, Student.CLASSROOM, dic['stu_class']) stu.setStudent(account, Student.TUTOR_NAME, dic['tutorName']) stu.setStudent(account, Student.TUTOR_PHONE, dic['tutorPhone']) stu.setStudent(account, Student.MAJOR, [ dic['majorSelect1'], dic['majorSelect2'], dic['majorSelect3'], dic['majorSelect4'], dic['majorSelect5'], dic['majorSelect6'] ]) stu.setStudent( account, Student.TEST_SCORE_LIST, [dic['testScore1'], dic['testScore2'], dic['testScore3']]) stu.setStudent(account, Student.RANK_LIST, [dic['rank1'], dic['rank2'], dic['rank3']]) stu.setStudent(account, Student.SUM_NUMBER_LIST, [dic['rank11'], dic['rank22'], dic['rank33']]) stu.setStudent(account, Student.REAL_SCORE, dic['realScore']) stu.setStudent(account, Student.ADMISSION_STATUS, dic['admissionStatus']) # stu.setStudent(account, Student.TYPE, dic['relTeacher']) # stu.setStudent(account, Student.TYPE, dic['relVolunteer']) stu.setStudent(account, Student.COMMENT, dic['comment']) stu.setStudent(account, Student.DAD_NAME, dic['dadName']) stu.setStudent(account, Student.MOM_NAME, dic['momName']) stu.setStudentGroupbyList(stu.getStudentAll(account), [ dic['team1'], dic['team2'], dic['team3'], dic['team4'], dic['team5'] ]) stu.setStudent(account, Student.DUIYING_TEACHER, dic['relTeacher']) stu.setStudent(account, Student.QUANXIAN, dic['forbid']) ret_dic = {} for key in request.POST.copy().keys(): ret_dic[key] = request.POST.copy().get(key) ret_dic['comment'] = dic['comment'] return JsonResponse(ret_dic) else: ''' 后端需要在这里改代码,从数据库读取正确的dict,并返回 ''' if 'teacher_id' not in request.session.keys(): return redirect('/login/') print request.GET id = request.GET.get('id') account = stu.idToAccountStudent(str(id)) student = stu.getStudentAll(account) stu_dic = stu.getStudentAllDictByAccount(account) dic = { Student.ID: stu_dic[Student.ID], Student.ACCOUNT: stu_dic[Student.ACCOUNT], Student.REAL_NAME: stu_dic[Student.REAL_NAME], Student.BIRTH: stu_dic[Student.BIRTH].strftime("%Y-%m-%d"), Student.ID_NUMBER: stu_dic[Student.ID_NUMBER], Student.TYPE: stu_dic[Student.TYPE], Student.SEX: stu_dic[Student.SEX], Student.NATION: stu_dic[Student.NATION], Student.SCHOOL: stu_dic[Student.SCHOOL], Student.CLASSROOM: stu_dic[Student.CLASSROOM], Student.ADDRESS: stu_dic[Student.ADDRESS], Student.PHONE: stu_dic[Student.PHONE], Student.EMAIL: stu_dic[Student.EMAIL], Student.DAD_PHONE: stu_dic[Student.DAD_PHONE], Student.MOM_PHONE: stu_dic[Student.MOM_PHONE], Student.TUTOR_NAME: stu_dic[Student.TUTOR_NAME], Student.TUTOR_PHONE: stu_dic[Student.TUTOR_PHONE], Student.PROVINCE: stu_dic[Student.PROVINCE], Student.MAJOR: stu_dic[Student.MAJOR], Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST], Student.RANK_LIST: stu_dic[Student.RANK_LIST], Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST], Student.ESTIMATE_SCORE: getStudentEstimateScore(stu.getStudentAll(account)), Student.REAL_SCORE: stu_dic[Student.REAL_SCORE], Student.REGISTER_CODE: stu_dic[Student.REGISTER_CODE], Student.ADMISSION_STATUS: stu_dic[Student.ADMISSION_STATUS], Student.TEACHER_LIST: stu_dic[Student.TEACHER_LIST], Student.VOLUNTEER_ACCOUNT_LIST: stu_dic[Student.VOLUNTEER_ACCOUNT_LIST], Student.COMMENT: stu_dic[Student.COMMENT], Student.MOM_NAME: stu_dic[Student.MOM_NAME], Student.DAD_NAME: stu_dic[Student.DAD_NAME], Student.DUIYING_TEACHER: stu_dic[Student.DUIYING_TEACHER], } group_list = stu.getStudentGroupIDListString(student).split(' ') if '' in group_list: group_list.remove('') for i in range(0, 5): if i < len(group_list) and group_list[i] != '': dic['group' + str(i + 1)] = int(group_list[i]) else: dic['group' + str(i + 1)] = 0 dic['grouplist'] = [' '] all_group = back.getGroupbyDict({}) for item in all_group: dic['grouplist'].append(back.getGroupAllDictByObject(item)['id']) id_ = request.session.get('teacher_id', -1) # print 'byr ', dic['group1'], dic['group2'], dic['group3'], dic['group4'], dic['group5'] dic['forbid'] = int(stu_dic[Student.QUANXIAN]) dic['forbidlist'] = PERMISSION_LIST print 'wo ca lei', dic['forbid'], dic['forbidlist'] return render(request, 'teacher/student_info_edit.html', { 'student': dic, 'id': id_ })
def profile(request): weichatopenid(request) id = request.session.get('student_id', -1) if id == -1: return HttpResponse('Access denied') account = stu.idToAccountStudent(str(id)) student = stu.getStudentAll(account) if request.method == 'POST': ''' 保存信息并返回json ''' print "wp",request.POST info_dict = request.POST.copy() print info_dict for i in range(1, 7): if info_dict['majorSelect' + str(i)].strip() == '': info_dict['majorSelect' + str(i)] = '0' for i in range(1, 4): if info_dict['testScore' + str(i)].strip() == '': info_dict['testScore' + str(i)] = '0' for i in range(1, 4): if info_dict['rank' + str(i)].strip() == '': info_dict['rank' + str(i)] = '0' for i in range(1, 4): if info_dict['rank' + str(i)].strip() == '': info_dict['rank' + str(i)] = '0' for i in range(1, 4): if info_dict['rank' + str(i) + str(i)].strip() == '': info_dict['rank' + str(i) + str(i)] = '0' if info_dict['realScore'].strip() == '': info_dict['realScore'] = '0' dic = { 'name': info_dict.get('name'), 'identification': info_dict.get('identification'), 'sex': info_dict.get('sex'), 'nation': info_dict.get('nation'), 'birth': info_dict.get('birth'), 'type': int(info_dict.get('wenli')), 'province': int(info_dict.get('province')), 'phone': info_dict.get('phone'), 'email': info_dict.get('email'), 'address': info_dict.get('address'), 'dadName': info_dict.get('dadName'), 'dadPhone': info_dict.get('dadPhone'), 'momName': info_dict.get('momName'), 'momPhone': info_dict.get('momPhone'), 'school': info_dict.get('school'), 'stu_class': info_dict.get('stu_class'), 'tutorName': info_dict.get('tutorName'), 'tutorPhone': info_dict.get('tutorPhone'), 'majorSelect1': int(info_dict.get('majorSelect1')), 'majorSelect2': int(info_dict.get('majorSelect2')), 'majorSelect3': int(info_dict.get('majorSelect3')), 'majorSelect4': int(info_dict.get('majorSelect4')), 'majorSelect5': int(info_dict.get('majorSelect5')), 'majorSelect6': int(info_dict.get('majorSelect6')), 'testScore1': int(info_dict.get('testScore1')), 'testScore2': int(info_dict.get('testScore2')), 'testScore3': int(info_dict.get('testScore3')), 'rank1': int(info_dict.get('rank1')), 'rank11': int(info_dict.get('rank11')), 'rank2': int(info_dict.get('rank2')), 'rank22': int(info_dict.get('rank22')), 'rank3': int(info_dict.get('rank3')), 'rank33': int(info_dict.get('rank33')), 'realScore': int(info_dict.get('realScore')), # 'relTeacher': info_dict.get('relTeacher'), 'comment': info_dict.get('comment'), 'password': info_dict.get('comment'), } # print 'wocao ni mei', dic try: birth_list = info_dict['birth'].split('/') dic['birth'] = datetime.date(int(birth_list[2]), int(birth_list[0]), int(birth_list[1])) except: dic['success'] = 'N' dic['message'] = u'日期设置不正确,请重新输入' return JsonResponse(dic) stu.setStudent(account, Student.REAL_NAME, dic['name']) stu.setStudent(account, Student.ID_NUMBER, dic['identification']) stu.setStudent(account, Student.SEX, dic['sex']) stu.setStudent(account, Student.NATION, dic['nation']) stu.setStudent(account, Student.BIRTH, dic['birth']) stu.setStudent(account, Student.TYPE, dic['type']) stu.setStudent(account, Student.PROVINCE, dic['province']) stu.setStudent(account, Student.PHONE, dic['phone']) stu.setStudent(account, Student.EMAIL, dic['email']) stu.setStudent(account, Student.ADDRESS, dic['address']) stu.setStudent(account, Student.MOM_NAME, dic['momName']) stu.setStudent(account, Student.DAD_NAME, dic['dadName']) stu.setStudent(account, Student.DAD_PHONE, dic['dadPhone']) stu.setStudent(account, Student.MOM_PHONE, dic['momPhone']) stu.setStudent(account, Student.SCHOOL, dic['school']) stu.setStudent(account, Student.CLASSROOM, dic['stu_class']) stu.setStudent(account, Student.TUTOR_NAME, dic['tutorName']) stu.setStudent(account, Student.TUTOR_PHONE, dic['tutorPhone']) stu.setStudent(account, Student.MAJOR, [dic['majorSelect1'], dic['majorSelect2'], dic['majorSelect3'], dic['majorSelect4'], dic['majorSelect5'], dic['majorSelect6']]) stu.setStudent( account, Student.TEST_SCORE_LIST, [ dic['testScore1'], dic['testScore2'], dic['testScore3']]) stu.setStudent( account, Student.RANK_LIST, [ dic['rank1'], dic['rank2'], dic['rank3']]) stu.setStudent( account, Student.SUM_NUMBER_LIST, [ dic['rank11'], dic['rank22'], dic['rank33']]) stu.setStudent(account, Student.REAL_SCORE, dic['realScore']) stu.setStudent(account, Student.COMMENT, dic['comment']) return JsonResponse(dic) else: ''' 获取信息并返回 ''' stu_dic = stu.getStudentAllDictByAccount(account) (rank, tmp) = stu.getStudentEstimateRank(student) dic = { 'name': stu_dic[Student.REAL_NAME], 'identification': stu_dic[Student.ID_NUMBER], 'sex': stu_dic[Student.SEX], 'nation': stu_dic[Student.NATION], 'birth': stu_dic[Student.BIRTH].strftime("%m/%d/%Y"), 'province': stu_dic[Student.PROVINCE], 'phone': stu_dic[Student.PHONE], 'email': stu_dic[Student.EMAIL], 'wenli': stu_dic[Student.TYPE], 'address': stu_dic[Student.ADDRESS], 'dadName': stu_dic[Student.DAD_NAME], 'dadPhone': stu_dic[Student.DAD_PHONE], 'momName': stu_dic[Student.MOM_NAME], 'momPhone': stu_dic[Student.MOM_PHONE], 'school': stu_dic[Student.SCHOOL], 'stu_class': stu_dic[Student.CLASSROOM], 'tutorName': stu_dic[Student.TUTOR_NAME], 'tutorPhone': stu_dic[Student.TUTOR_PHONE], Student.MAJOR: stu_dic[Student.MAJOR], Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST], Student.RANK_LIST: stu_dic[Student.RANK_LIST], Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST], 'realScore': stu_dic[Student.REAL_SCORE], 'relTeacher': stu_dic[Student.DUIYING_TEACHER], 'comment': stu_dic[Student.COMMENT], 'estimateScore': getStudentEstimateScore(stu.getStudentAll(account)), 'estimateRank': str(rank)+'/'+str(tmp) } group_list = stu.getStudentGroupIDListString(student).split(' ') for i in range(1, 6): if i < len(group_list): dic['group' + str(i)] = group_list[i] else: dic['group' + str(i)] = '0' dic['grouplist'] = [' '] all_group = back.getGroupbyDict({}) for item in all_group: dic['grouplist'].append(back.getGroupAllDictByObject(item)['id']) print 'jiao baba', dic if 'auth' in request.GET: dic['auth'] = '0' return render(request, 'student/userinfo.html', {'dict': dic, 'id':id})