def update_teacher_info(request): """ 修改负责任的基本信息 :param request: :return: """ operation_object = None try: if request.method == 'POST': object_form = RegisterTeacherUpdateForm(request.POST) if object_form.is_valid(): update_id = object_form.cleaned_data.get('update_id', None) if update_id: main_object_terms = TeacherInfo.objects.filter( id=update_id) if len(main_object_terms) == 1: form_object_main_object = form_to_obj( object_form.cleaned_data, main_object_terms[0]) form_object_main_object.save() # 用户基础信息 form_object_user_info = form_to_obj( object_form.cleaned_data, form_object_main_object.user_info) form_object_user_info.save() operation_object = form_object_user_info # 注册信息修改(除了密码信息) form_object_register_user_info = form_to_obj( object_form.cleaned_data, form_object_user_info.register_user_info) form_object_register_user_info.save() result['status'] = True result['message'] = '修改成功!' result['data'] = json.dumps({}, ensure_ascii=False) return JsonResponse(result, safe=False) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 result['status'] = False result['message'] = '系统异常,请稍后尝试或联系管理员!' result['data'] = '' else: result['status'] = False result['message'] = '系统异常,请稍后尝试或联系管理员!' result['data'] = '' except Exception as e: result['status'] = False result['message'] = "系统异常:" + str(e) result['data'] = '' result["level"] = log_level_edit save_operation_log(request, inspect.stack()[0][3], operation_object.__str__(True), result) return JsonResponse(result, safe=False)
def register(request): """ 注册:分为管理员和普通用户 :param request: :return: """ if request.method == 'POST': object_form = RegisterForm(request.POST) if object_form.is_valid(): form_object = form_to_obj(object_form.cleaned_data, RegisterUserInfo()) # 密码加密处理 form_object.password = Password.encryption(form_object.password) form_object.role = RoleInfo.objects.filter(role_name='student') form_object.save() # user_role = UserRole() # role = RoleInfo.objects.get(role_name='student') # user = RegisterUserInfo.objects.get(username=form_object.username) # user_role.user = user # user_role.role_name = role # user_role.explain = "默认注册都是学生" # user_role.save() title_msg = sys_msg + '-登陆' return render(request, "login.html", {'title_msg': title_msg}) else: pass
def register(request): """ 注册:分为管理员和普通用户 :param request: :return: """ try: if request.method == 'POST': object_form = RegisterForm(request.POST) if object_form.is_valid(): form_object = form_to_obj(object_form.cleaned_data, RegisterUserInfo()) # 密码加密处理 form_object.password = Password.encryption( form_object.password) role_infos = RoleInfo.objects.filter(role_name='student') if len(role_infos) > 0: form_object.role = role_infos[0] form_object.save() result['message'] = "注册成功" result['level'] = log_level_register save_operation_log(request, inspect.stack()[0][3], form_object.__str__(True), result) title_msg = sys_msg + '-登陆' sign_in_msg = '注册成功,请您登陆' return render_result( request, "login.html", { 'title_msg': title_msg, 'sign_in_msg': sign_in_msg, 'username': form_object.username }) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 sign_in_msg = '-注册失败,请勿登陆,初始角色信息获取失败,请稍后重试,或者联系管理员查看和管理角色信息!' title_msg = sys_msg + '-注册失败!' return render_result(request, "login.html", { 'title_msg': title_msg, 'sign_in_msg': sign_in_msg }) # user_role = UserRole() # role = RoleInfo.objects.get(role_name='student') # user = RegisterUserInfo.objects.get(username=form_object.username) # user_role.user = user # user_role.role_name = role # user_role.explain = "默认注册都是学生" # user_role.save() else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 title_msg = sys_msg + '-注册失败' sign_in_msg = '注册失败,请勿登陆,请重试或联系管理员!报错内容:' + object_form.errors return render_result(request, "login.html", { 'title_msg': title_msg, 'sign_in_msg': sign_in_msg }) except Exception as e: print(str(e)) sign_in_msg = '-注册失败,请勿登陆,请重试或联系管理员!报错内容:' + str(e) title_msg = sys_msg + '-注册失败' return render_result(request, "login.html", { 'title_msg': title_msg, 'sign_in_msg': sign_in_msg })
def update_user_base_info(request): """ 修改用户的基本信息 :param request: :return: """ try: if request.method == 'POST': object_form = UserInfoUpdateForm(request.POST) if object_form.is_valid(): username = request.session.get('username', None) # 用户名 register_user_info = RegisterUserInfo.objects.get( username=username) user_info_id = object_form.cleaned_data.get('uid', None) print("user_info_id:::" + str(user_info_id)) user_infos = UserInfo.objects.filter(id=user_info_id) if len(user_infos) > 0: user_info = user_infos[len(user_infos) - 1] form_object_user_info = form_to_obj( object_form.cleaned_data, user_info) else: # 用户基础信息 form_object_user_info = form_to_obj( object_form.cleaned_data, UserInfo()) # 关联注册员信息 form_object_user_info.register_user_info = register_user_info # 关联注册员信息 # 关联操作员信息 form_object_user_info.user_operator = register_user_info # 关联注册员信息 # 关联教育程度 education_degree = object_form.cleaned_data.get( 'education_degree_form', None) if education_degree: education_degree_obj = EducationDegree.objects.get( id=education_degree) form_object_user_info.education_degree = education_degree_obj # 关联教育程度 # 关联民族信息 nation_info = object_form.cleaned_data.get( 'nation_info_form', None) if nation_info: nation_info_obj = NationInfo.objects.get(id=nation_info) form_object_user_info.nation_info = nation_info_obj # 关联民族信息 # 关联单位性质 unit_nature = object_form.cleaned_data.get( 'unit_nature_form', None) if unit_nature: unit_nature_obj = UnitNature.objects.get(id=unit_nature) form_object_user_info.unit_nature = unit_nature_obj # 关联单位性质 # 关联省 hukou_province = object_form.cleaned_data.get( 'hukou_province_form', None) if hukou_province: hukou_province_obj = ProvinceCityCountry.objects.get( id=hukou_province) form_object_user_info.hukou_province = hukou_province_obj # 关联省 # 关联市 hukou_city = object_form.cleaned_data.get( 'hukou_city_form', None) if hukou_city: hukou_city_obj = ProvinceCityCountry.objects.get( id=hukou_city) form_object_user_info.hukou_city = hukou_city_obj # 关联市 # 关联县 hukou_county = object_form.cleaned_data.get( 'hukou_county_form', None) if hukou_county: hukou_county_obj = ProvinceCityCountry.objects.get( id=hukou_county) form_object_user_info.hukou_county = hukou_county_obj # 关联县 # 关联二寸照片 two_inch_photo = object_form.cleaned_data.get( 'two_inch_photo_form', None) if two_inch_photo: two_inch_photo_obj = Picture.objects.get(id=two_inch_photo) form_object_user_info.two_inch_photo = two_inch_photo_obj # 关联二寸照片 id_number = form_object_user_info.id_number if len(id_number) > 17: birthday_string = str(id_number)[6:14] year = birthday_string[0:4] month = birthday_string[4:6] day = birthday_string[6:8] birthday = year + "-" + month + "-" + day form_object_user_info.birthday = birthday age = timezone.now().year - int(year) form_object_user_info.age = age start_working_date = form_object_user_info.start_working_date if start_working_date: year = start_working_date.year working_year = timezone.now().year - year form_object_user_info.working_year = working_year form_object_user_info.save() result['message'] = '个人信息修改成功' result["level"] = log_level_edit save_operation_log(request, inspect.stack()[0][3], form_object_user_info.__str__(True), result) # 用户基础信息 return HttpResponseRedirect('/report/user_setting/') else: title_msg = sys_msg + '-系统错误' message = '系统提示:参数获取异常' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-系统错误' message = '系统提示:请求方式异常' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) except Exception as e: print(str(e)) title_msg = sys_msg + '-系统错误' message = '系统提示:系统异常请稍后重试,或联系管理员,错误提示:' + str(e) return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message })
def add_user_info(request): """ 添加学生信息(化工类) :param request: :return: """ try: if request.method == 'POST': object_form = UserInfoForm(request.POST) if object_form.is_valid(): username = request.session.get('username', None) # 用户名 register_user_info = RegisterUserInfo.objects.get( username=username) user_infos = UserInfo.objects.filter( register_user_info=register_user_info) if len(user_infos) > 0: user_info = user_infos[len(user_infos) - 1] form_object_user_info = form_to_obj( object_form.cleaned_data, user_info) else: # 用户基础信息 form_object_user_info = form_to_obj( object_form.cleaned_data, UserInfo()) # 关联注册员信息 form_object_user_info.register_user_info = register_user_info # 关联注册员信息 # 关联操作员信息 form_object_user_info.user_operator = register_user_info # 关联注册员信息 # 关联教育程度 education_degree = object_form.cleaned_data.get( 'education_degree_form', None) if education_degree: education_degree_obj = EducationDegree.objects.get( id=education_degree) form_object_user_info.education_degree = education_degree_obj # 关联教育程度 # 关联民族信息 nation_info = object_form.cleaned_data.get( 'nation_info_form', None) if nation_info: nation_info_obj = NationInfo.objects.get(id=nation_info) form_object_user_info.nation_info = nation_info_obj # 关联民族信息 # 关联单位性质 unit_nature = object_form.cleaned_data.get( 'unit_nature_form', None) if unit_nature: unit_nature_obj = UnitNature.objects.get(id=unit_nature) form_object_user_info.unit_nature = unit_nature_obj # 关联单位性质 # 关联省 hukou_province = object_form.cleaned_data.get( 'hukou_province_form', None) if hukou_province: hukou_province_obj = ProvinceCityCountry.objects.get( id=hukou_province) form_object_user_info.hukou_province = hukou_province_obj # 关联省 # 关联市 hukou_city = object_form.cleaned_data.get( 'hukou_city_form', None) if hukou_city: hukou_city_obj = ProvinceCityCountry.objects.get( id=hukou_city) form_object_user_info.hukou_city = hukou_city_obj # 关联市 # 关联县 hukou_county = object_form.cleaned_data.get( 'hukou_county_form', None) if hukou_county: hukou_county_obj = ProvinceCityCountry.objects.get( id=hukou_county) form_object_user_info.hukou_county = hukou_county_obj # 关联县 # 关联二寸照片 two_inch_photo = object_form.cleaned_data.get( 'two_inch_photo_form', None) if two_inch_photo: two_inch_photo_obj = Picture.objects.get(id=two_inch_photo) form_object_user_info.two_inch_photo = two_inch_photo_obj # 关联二寸照片 # # 关联毕业证书照片 # certificate_photos = object_form.cleaned_data.get('certificate_photos_form', None) # if certificate_photos: # certificate_photos_obj = Picture.objects.get(id=certificate_photos) # form_object_user_info.certificate_photos = certificate_photos_obj # # 关联毕业证书照片 # # # 关联院校毕业证书照片 # diploma_certificate_photos = object_form.cleaned_data.get('diploma_certificate_photos_form', None) # if diploma_certificate_photos: # diploma_certificate_photos_obj = Picture.objects.get(id=diploma_certificate_photos) # form_object_user_info.diploma_certificate_photos = diploma_certificate_photos_obj # # 关联院校毕业证书照片 id_number = form_object_user_info.id_number if len(id_number) > 17: birthday_string = str(id_number)[6:14] year = birthday_string[0:4] month = birthday_string[4:6] day = birthday_string[6:8] birthday = year + "-" + month + "-" + day form_object_user_info.birthday = birthday age = timezone.now().year - int(year) print() form_object_user_info.age = age start_working_date = form_object_user_info.start_working_date if start_working_date: year = start_working_date.year # year = start_working_date[0:4] working_year = timezone.now().year - year form_object_user_info.working_year = working_year form_object_user_info.save() # 用户基础信息 # 关联现有的填报信息 student_id = object_form.cleaned_data.get("student_id", None) if student_id: student_infos = StudentInfo.objects.filter(id=student_id) if len(student_infos) > 0: student_info = student_infos[0] person_in_charge = object_form.cleaned_data.get( "person_in_charge", None) if person_in_charge: student_info.person_in_charge = person_in_charge student_info.save() student_info.user_info = form_object_user_info title_msg = sys_msg + '-填报详情' image_url = MEDIA_URL + str( student_info.user_info.two_inch_photo.picture_path) # 全部汇总在大填报表格里面 certificate_photos_url = '' if student_info.certificate_photos: certificate_photos_url = MEDIA_URL + str( student_info.certificate_photos.picture_path) return render_result( request, "page_main_controller/student/report_student_user_info_detail.html", { 'title_msg': title_msg, 'student_info': student_info, 'image_url': image_url, 'certificate_photos_url': certificate_photos_url, 'not_exist': False }) else: title_msg = sys_msg + '-填报详情' return render_result( request, "page_main_controller/student/report_student_user_info_detail.html", { 'title_msg': title_msg, 'not_exist': True }) else: title_msg = sys_msg + '-填报详情' return render_result( request, "page_main_controller/student/report_student_user_info_detail.html", { 'title_msg': title_msg, 'not_exist': True }) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 title_msg = sys_msg + '-继续填写信息' message = '添加失败:输入项不全,请返回重新确认并填写,或联系管理员' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) # return render(request, "account/form1.html", {"error": f.errors}) except Exception as e: print(str(e)) title_msg = sys_msg + '-系统错误' message = '系统提示:系统异常请稍后重试,或联系管理员' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message })
def update_user_info(request): """ 修改用户基础信息 :param request: :return: """ try: if request.method == 'POST': object_form = UserInfoUpdateForm(request.POST) student_id = request.POST.get('student_id', None) if object_form.is_valid(): username = request.session.get('username', None) # 用户名 register_user_info = RegisterUserInfo.objects.get( username=username) user_info_id = object_form.cleaned_data.get( 'user_info_id', None) user_infos = UserInfo.objects.filter(id=user_info_id) if len(user_infos) > 0: user_info = user_infos[len(user_infos) - 1] form_object_user_info = form_to_obj( object_form.cleaned_data, user_info) else: # 用户基础信息 form_object_user_info = form_to_obj( object_form.cleaned_data, UserInfo()) # 关联注册员信息 form_object_user_info.register_user_info = register_user_info # 关联注册员信息 # 关联操作员信息 form_object_user_info.user_operator = register_user_info # 关联注册员信息 # 关联教育程度 education_degree = object_form.cleaned_data.get( 'education_degree_form', None) if education_degree: education_degree_obj = EducationDegree.objects.get( id=education_degree) form_object_user_info.education_degree = education_degree_obj # 关联教育程度 # 关联民族信息 nation_info = object_form.cleaned_data.get( 'nation_info_form', None) if nation_info: nation_info_obj = NationInfo.objects.get(id=nation_info) form_object_user_info.nation_info = nation_info_obj # 关联民族信息 # 关联单位性质 unit_nature = object_form.cleaned_data.get( 'unit_nature_form', None) if unit_nature: unit_nature_obj = UnitNature.objects.get(id=unit_nature) form_object_user_info.unit_nature = unit_nature_obj # 关联单位性质 # 关联省 hukou_province = object_form.cleaned_data.get( 'hukou_province_form', None) if hukou_province: hukou_province_obj = ProvinceCityCountry.objects.get( id=hukou_province) form_object_user_info.hukou_province = hukou_province_obj # 关联省 # 关联市 hukou_city = object_form.cleaned_data.get( 'hukou_city_form', None) if hukou_city: hukou_city_obj = ProvinceCityCountry.objects.get( id=hukou_city) form_object_user_info.hukou_city = hukou_city_obj # 关联市 # 关联县 hukou_county = object_form.cleaned_data.get( 'hukou_county_form', None) if hukou_county: hukou_county_obj = ProvinceCityCountry.objects.get( id=hukou_county) form_object_user_info.hukou_county = hukou_county_obj # 关联县 # 关联二寸照片 two_inch_photo = object_form.cleaned_data.get( 'two_inch_photo_form', None) if two_inch_photo: two_inch_photo_obj = Picture.objects.get(id=two_inch_photo) form_object_user_info.two_inch_photo = two_inch_photo_obj # 关联二寸照片 id_card_heads_photo = object_form.cleaned_data.get( 'id_card_heads_photo', None) id_card_tails_photo = object_form.cleaned_data.get( 'id_card_tails_photo', None) print('id_card_heads_photo') print('id_card_tails_photo') print(id_card_heads_photo) print(id_card_tails_photo) # 关联身份证正面照片 if id_card_heads_photo: id_card_heads_photo_obj = IDCardPicture.objects.get( id=id_card_heads_photo) form_object_user_info.id_card_heads_photo = id_card_heads_photo_obj # 关联身份证反面照片 if id_card_tails_photo: id_card_tails_photo_obj = IDCardPicture.objects.get( id=id_card_tails_photo) form_object_user_info.id_card_tails_photo = id_card_tails_photo_obj id_number = form_object_user_info.id_number if len(id_number) > 17: birthday_string = str(id_number)[6:14] year = birthday_string[0:4] month = birthday_string[4:6] day = birthday_string[6:8] birthday = year + "-" + month + "-" + day form_object_user_info.birthday = birthday age = timezone.now().year - int(year) form_object_user_info.age = age start_working_date = form_object_user_info.start_working_date if start_working_date: year = start_working_date.year working_year = timezone.now().year - year form_object_user_info.working_year = working_year form_object_user_info.save() result['message'] = '个人信息添加成功' result["level"] = log_level_edit save_operation_log(request, inspect.stack()[0][3], form_object_user_info.__str__(True), result) # 用户基础信息 # 关联现有的填报信息 student_id = object_form.cleaned_data.get("student_id", None) teacher_info_form = object_form.cleaned_data.get( "teacher_info_form", None) if student_id: student_infos = StudentInfo.objects.filter(id=student_id) if len(student_infos) > 0: student_info = student_infos[0] if teacher_info_form: teacher_infos = TeacherInfo.objects.filter( id=teacher_info_form) if len(teacher_infos) > 0: student_info.teacher_info = teacher_infos[0] declaration_of_occupation = student_info.declaration_of_occupation identification_level = student_info.identification_level if '工业废水' in declaration_of_occupation: declaration_of_occupation_first = '工废' elif '工业固体' in declaration_of_occupation: declaration_of_occupation_first = '工固' elif '中式烹调师' in declaration_of_occupation: declaration_of_occupation_first = '烹' elif '中式面点师' in declaration_of_occupation: declaration_of_occupation_first = '面' else: declaration_of_occupation_first = str( declaration_of_occupation)[0:1] identification_level_dict = { '5': '(初)', '4': '(中)', '3': '(高)' } identification_level_str = identification_level_dict[ str(identification_level)] explain = declaration_of_occupation_first + identification_level_str student_info.explain = explain student_info.save() student_username = form_object_user_info.register_user_info.username term_worker_picture( student_info.school_term.school_term_name, student_info.declaration_of_occupation, student_username, "二寸证件照", form_object_user_info.two_inch_photo. picture_path) term_worker_picture( student_info.school_term.school_term_name, student_info.declaration_of_occupation, student_username, "SFZ证件ZFM照", form_object_user_info.id_card_heads_photo. picture_path) term_worker_picture( student_info.school_term.school_term_name, student_info.declaration_of_occupation, student_username, "SFZ证件ZFM照", form_object_user_info.id_card_tails_photo. picture_path) return HttpResponseRedirect( "/report/student_info_detail?studentId=" + str(student_id)) title_msg = sys_msg + '-填报详情' image_url = MEDIA_URL + str( student_info.user_info.two_inch_photo.picture_path) # 全部汇总在大填报表格里面 certificate_photos_url = '' if student_info.certificate_photos: certificate_photos_url = MEDIA_URL + str( student_info.certificate_photos.picture_path) diploma_certificate_photos_url = '' if student_info.diploma_certificate_photos: diploma_certificate_photos_url = MEDIA_URL + str( student_info.diploma_certificate_photos. picture_path) return render_result( request, "page_main_controller/student/report_student_user_info_detail.html", { 'title_msg': title_msg, 'student_info': student_info, 'image_url': image_url, 'certificate_photos_url': certificate_photos_url, 'diploma_certificate_photos_url': diploma_certificate_photos_url, 'not_exist': False }) else: title_msg = sys_msg + '-填报详情' return render_result( request, "page_main_controller/student/report_student_user_info_detail.html", { 'title_msg': title_msg, 'not_exist': True }) else: # 未携带学生信息,只修改基础信息 return HttpResponseRedirect('/report/user_setting/') # title_msg = sys_msg + '-填报详情' # return render_result(request, "page_main_controller/student/report_student_user_info_detail.html", # {'title_msg': title_msg, 'not_exist': True}) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 title_msg = sys_msg + '-继续填写信息' if student_id: return render_result( request, "page_main_controller/user/report_user_info.html", { 'title_msg': title_msg, 'student_id': student_id }) # return render_result(request, "account/form1.html", {"error": f.errors}) except Exception as e: print(str(e)) title_msg = sys_msg + '-系统错误' message = '系统提示:系统异常请稍后重试' + str(e) return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message })
def student_info_update(request): """ 修改学生的填报信息 :return: """ try: if request.method == 'POST': object_form = StudentUpdateForm(request.POST) # print(object_form.__str__()) if object_form.is_valid(): student_info_id = object_form.cleaned_data.get('obj_id', None) if student_info_id: student_infos = StudentInfo.objects.filter( id=student_info_id).order_by('-id') if len(student_infos) > 0: student_info = student_infos[0] student_id = student_info.id # 用户基础信息 form_object_student_info = form_to_obj( object_form.cleaned_data, student_info) # 关联申报的级别信息 identification_level = object_form.cleaned_data.get( 'update_identification_level', None) if identification_level: form_object_student_info.identification_level = identification_level # 关联职业资格证书照片 certificate_photos = object_form.cleaned_data.get( 'certificate_photos_form', None) if certificate_photos: certificate_photos_obj = Picture.objects.get( id=certificate_photos) form_object_student_info.certificate_photos = certificate_photos_obj # 关联职业资格证书照片 # 关联院校毕业证书照片 diploma_certificate_photos = object_form.cleaned_data.get( 'diploma_certificate_photos_form', None) if diploma_certificate_photos: diploma_certificate_photos_obj = Picture.objects.get( id=diploma_certificate_photos) form_object_student_info.diploma_certificate_photos = diploma_certificate_photos_obj # 关联院校毕业证书照片 # 关联登陆用户基础信息 username = request.session.get('username', None) # 用户名 register_user_info = RegisterUserInfo.objects.get( username=username) form_object_student_info.user_operator = register_user_info declaration_of_occupation = form_object_student_info.declaration_of_occupation identification_level = form_object_student_info.identification_level if '工业废水' in declaration_of_occupation: declaration_of_occupation_first = '工废' elif '工业固体' in declaration_of_occupation: declaration_of_occupation_first = '工固' elif '中式烹调师' in declaration_of_occupation: declaration_of_occupation_first = '烹' elif '中式面点师' in declaration_of_occupation: declaration_of_occupation_first = '面' elif '电梯安装维修工' in declaration_of_occupation: declaration_of_occupation_first = '电梯' else: declaration_of_occupation_first = str( declaration_of_occupation)[0:1] identification_level_dict = { '5': '(初)', '4': '(中)', '3': '(高)' } identification_level_str = identification_level_dict[ str(identification_level)] explain = declaration_of_occupation_first + identification_level_str form_object_student_info.explain = explain print("primary_level::" + form_object_student_info.primary_level) # if form_object_student_info.identification_level == "3": # # 如果申报等级是高级那么工作年限将不设置 # form_object_student_info.career_life = 0 # form_object_student_info.original_certificate_worker_year = 0 # form_object_student_info.apprentice_year = 0 # form_object_student_info.apprentice_month = 0 # else: # pass form_object_student_info.save() student_username = form_object_student_info.user_info.register_user_info.username if diploma_certificate_photos: # 备份到对应的 term_worker_picture( form_object_student_info.school_term. school_term_name, form_object_student_info. declaration_of_occupation, student_username, "毕业证件照", form_object_student_info. diploma_certificate_photos.picture_path) if certificate_photos: # 备份到对应的 term_worker_picture( form_object_student_info.school_term. school_term_name, form_object_student_info. declaration_of_occupation, student_username, "资格证件照", form_object_student_info. certificate_photos.picture_path) result['message'] = "学员信息添加成功!" result["level"] = log_level_add save_operation_log( request, inspect.stack()[0][3], form_object_student_info.__str__(True), result) # user_info = UserInfo.objects.get(register_user_info=register_user_info.id) # working_history_list = user_info.user_Info_working_history.all() # print("user_Info_working_history::" + str(working_history_list)) title_msg = sys_msg + '-用户信息' teacher_infos = TeacherInfo.objects.all() teacher_info_id = form_object_student_info.teacher_info if form_object_student_info.user_info: user_info = form_object_student_info.user_info if not user_info.real_name: user_info.real_name = "" if not user_info.id_number: user_info.id_number = "" if not user_info.id_card_address: user_info.id_card_address = "" if not user_info.address: user_info.address = "" if not user_info.work_unit: user_info.work_unit = "" if not user_info.fixed_telephone: user_info.fixed_telephone = "" if not user_info.contact_number: user_info.contact_number = "" if not user_info.postal_code: user_info.postal_code = "" if not user_info.main_occupation: user_info.main_occupation = "" if user_info.two_inch_photo: if user_info.two_inch_photo.picture_path: image_url = MEDIA_URL + str( user_info.two_inch_photo.picture_path) idcard_heads_image_url = MEDIA_URL + str( user_info.id_card_heads_photo. picture_path) idcard_tails_image_url = MEDIA_URL + str( user_info.id_card_tails_photo. picture_path) return render_result( request, "page_main_controller/user/report_user_info_update.html", { 'title_msg': title_msg, 'user_info': student_info.user_info, 'student_id': student_id, 'image_url': image_url, 'idcard_heads_image_url': idcard_heads_image_url, 'idcard_tails_image_url': idcard_tails_image_url, 'teacher_infos': teacher_infos, 'teacher_info_id': teacher_info_id }) else: return render_result( request, "page_main_controller/user/report_user_info_update.html", { 'title_msg': title_msg, 'user_info': user_info, 'student_id': student_id, 'image_url': '', 'teacher_infos': teacher_infos, 'teacher_info_id': teacher_info_id }) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 title_msg = sys_msg + '-错误信息展示页面' message = '更新失败:系统没有此信息记录,请重试或联系管理员!' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 title_msg = sys_msg + '-错误信息展示页面' message = '更新失败:输入项不全,请返回重新确认并填写' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:请求方式有误,请重新提交或者联系管理员' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) except Exception as e: print(str(e)) raise e
def add_student_info(request): """����ѧ������Ϣ. :param request: :return: """ try: if request.method == 'POST': object_form = StudentForm(request.POST) print(object_form) if object_form.is_valid(): print(object_form.cleaned_data) form_object_student_info = form_to_obj( object_form.cleaned_data, StudentInfo()) # # 关联教育程度 # education_degree = object_form.cleaned_data.get('education_degree_form', None) # if education_degree: # education_degree_obj = EducationDegree.objects.get(id=education_degree) # form_object_student_info.education_degree = education_degree_obj # # 关联教育程度 # 关联职业资格证书照片 certificate_photos = object_form.cleaned_data.get( 'certificate_photos_form', None) if certificate_photos: certificate_photos_obj = Picture.objects.get( id=certificate_photos) form_object_student_info.certificate_photos = certificate_photos_obj # 关联职业资格证书照片 # 关联院校毕业证书照片 diploma_certificate_photos = object_form.cleaned_data.get( 'diploma_certificate_photos_form', None) if diploma_certificate_photos: diploma_certificate_photos_obj = Picture.objects.get( id=diploma_certificate_photos) form_object_student_info.diploma_certificate_photos = diploma_certificate_photos_obj # 关联院校毕业证书照片 # 关联登陆用户基础信息 username = request.session.get('username', None) # 用户名 register_user_info = RegisterUserInfo.objects.get( username=username) user_infos = UserInfo.objects.filter( register_user_info=register_user_info) image_url = '' idcard_heads_image_url = '' idcard_tails_image_url = '' if len(user_infos) > 0: user_info_old = user_infos[len(user_infos) - 1] if user_info_old.two_inch_photo: if user_info_old.two_inch_photo.picture_path: image_url = MEDIA_URL + str( user_info_old.two_inch_photo.picture_path) idcard_heads_image_url = MEDIA_URL + str( user_info_old.id_card_heads_photo.picture_path) idcard_tails_image_url = MEDIA_URL + str( user_info_old.id_card_tails_photo.picture_path) else: image_url = '' # 学生附属信息 form_object_student_info.user_info = user_info_old else: # 用户基础信息 user_info_new = UserInfo() # 关联注册员信息 user_info_new.register_user_info = register_user_info user_info_new.save() form_object_student_info.user_info = user_info_new declaration_of_occupation = form_object_student_info.declaration_of_occupation if declaration_of_occupation in chemical_industry: form_object_student_info.chemical_worker = '1' else: form_object_student_info.chemical_worker = '2' school_term = SchoolTerm.objects.last() form_object_student_info.school_term = school_term declaration_of_occupation = form_object_student_info.declaration_of_occupation identification_level = form_object_student_info.identification_level if '工业废水' in declaration_of_occupation: declaration_of_occupation_first = '工废' elif '工业固体' in declaration_of_occupation: declaration_of_occupation_first = '工固' elif '中式烹调师' in declaration_of_occupation: declaration_of_occupation_first = '烹' elif '中式面点师' in declaration_of_occupation: declaration_of_occupation_first = '面' elif '电梯安装维修工' in declaration_of_occupation: declaration_of_occupation_first = '电梯' else: declaration_of_occupation_first = str( declaration_of_occupation)[0:1] identification_level_dict = { '5': '(初)', '4': '(中)', '3': '(高)' } identification_level_str = identification_level_dict[str( identification_level)] explain = declaration_of_occupation_first + identification_level_str form_object_student_info.explain = explain print("primary_level::" + form_object_student_info.primary_level) # if form_object_student_info.identification_level == "3": # # 如果申报等级是高级那么工作年限将不设置 # form_object_student_info.career_life = 0 # form_object_student_info.original_certificate_worker_year = 0 # form_object_student_info.apprentice_year = 0 # form_object_student_info.apprentice_month = 0 # else: # pass form_object_student_info.save() if diploma_certificate_photos: # 备份到对应的 term_worker_picture( school_term.school_term_name, form_object_student_info.declaration_of_occupation, username, "毕业证件照", form_object_student_info. diploma_certificate_photos.picture_path) if certificate_photos: # 备份到对应的 term_worker_picture( school_term.school_term_name, form_object_student_info.declaration_of_occupation, username, "资格证件照", form_object_student_info. certificate_photos.picture_path) result['message'] = "学员信息添加成功!" result["level"] = log_level_add save_operation_log(request, inspect.stack()[0][3], form_object_student_info.__str__(True), result) student_id = form_object_student_info.id # user_info = UserInfo.objects.get(register_user_info=register_user_info.id) # working_history_list = user_info.user_Info_working_history.all() # print("user_Info_working_history::" + str(working_history_list)) title_msg = sys_msg + '-学生信息' student_infos = StudentInfo.objects.filter(id=student_id) if len(student_infos) > 0: student_info = student_infos[0] user_info = student_info.user_info if not user_info.real_name: user_info.real_name = "" if not user_info.id_number: user_info.id_number = "" if not user_info.id_card_address: user_info.id_card_address = "" if not user_info.address: user_info.address = "" if not user_info.work_unit: user_info.work_unit = "" if not user_info.fixed_telephone: user_info.fixed_telephone = "" if not user_info.contact_number: user_info.contact_number = "" if not user_info.postal_code: user_info.postal_code = "" if not user_info.main_occupation: user_info.main_occupation = "" teacher_infos = TeacherInfo.objects.all() if teacher_infos.count() == 0: title_msg = sys_msg + '-错误信息展示页面' message = '负责人信息为空,请管理员添加负责人信息!' return render_result( request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: return render_result( request, "page_main_controller/user/report_user_info_update.html", { 'title_msg': title_msg, 'user_info': student_info.user_info, 'student_id': student_id, 'image_url': image_url, 'idcard_heads_image_url': idcard_heads_image_url, 'idcard_tails_image_url': idcard_tails_image_url, 'teacher_infos': teacher_infos }) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 title_msg = sys_msg + '-错误信息展示页面' message = '添加失败:输入项不全,请返回重新确认并填写,或联系管理员' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) # return render_result(request, "account/form1.html", {"error": f.errors}) else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:请求方式有误,请重新提交或者联系管理员' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) except Exception as e: raise e
def add_work_history(request): """ 添加工作经验历史 :param request: :return: """ title_msg = sys_msg + '-工作履历' try: if request.method == 'POST': object_form = WorkingHistoryForm(request.POST) # print(object_form) if object_form.is_valid(): user_info_id = object_form.cleaned_data['obj_id'] user_info = UserInfo.objects.get(id=user_info_id) form_object_working_history = form_to_obj( object_form.cleaned_data, WorkingHistory()) # 关联县 hukou_county = object_form.cleaned_data['hukou_county_form'] if hukou_county == -1: # 关联市 hukou_city = object_form.cleaned_data['hukou_city_form'] hukou_city_obj = ProvinceCityCountry.objects.get( id=hukou_city) form_object_working_history.city_or_county = hukou_city_obj else: hukou_county_obj = ProvinceCityCountry.objects.get( id=hukou_county) form_object_working_history.city_or_county = hukou_county_obj form_object_working_history.save() # 添加一条工作记录 user_info.user_Info_working_history.add( form_object_working_history) # 查找出所有的工作记录 working_history_list = user_info.user_Info_working_history.all( ) print("user_Info_working_history::" + str(working_history_list)) student_info = StudentInfo.objects.get(user_info=user_info) return render_result( request, "page_main_controller/report_worker_history.html", { 'title_msg': title_msg, 'student_info': student_info, 'working_history_list': working_history_list, 'is_report': True }) else: print(type(object_form.errors), object_form.errors) # errors类型是ErrorDict,里面是ul,li标签 message = '系统提示:信息填报内容未完善,请返回重新填报或完善填报信息再提交!' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: message = '系统提示:请求方式出现异常,请重试或联系管理员' return render_result(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) except Exception as e: raise e
def reply_system_message(request): """ 确认并回复消息保存 :param request: :return: """ teacher_infos = TeacherInfo.objects.all() school_terms = SchoolTerm.objects.filter().order_by('-id') not_confirm, message_already_sent, system_announcement = get_message_infos( request) try: not_confirm, message_already_sent, system_announcement = get_message_infos( request) if request.method == 'POST': object_form = SystemMessageForm(request.POST) print(object_form.__str__()) if object_form.is_valid(): form_object_system_message = form_to_obj( object_form.cleaned_data, SystemMessage()) feedback_message = object_form.cleaned_data.get( "feedback_message", None) form_object_system_message.sender = UserInfo.objects.get( register_user_info__username=request.session.get( 'username', None)) if feedback_message: # 是确认回复的消息 feedback_message_objects = SystemMessage.objects.filter( id=feedback_message).order_by('-id') if len(feedback_message_objects) > 0: feedback_message_object = feedback_message_objects[0] form_object_system_message.feedback_message = feedback_message_object form_object_system_message.receiver = feedback_message_objects[ 0].sender # form_object_system_message.feedback_status = "1" form_object_system_message.save() # 将原信息修改成已确认并恢复状态 feedback_status = feedback_message_object.feedback_status if feedback_status == '2': # 信息未确认 feedback_message_object.feedback_status = "1" reply_status = feedback_message_object.reply_status if reply_status == '2': # 信息未回复 feedback_message_object.reply_status = "1" # 保存修改之后的状态 feedback_message_object.save() return HttpResponseRedirect('/report/send/') # title_msg = "消息回复详情" # return render(request, # "page_main_controller/system_message/system_message_confirm_send_page.html", # {'title_msg': title_msg, 'receiver_message': feedback_message_objects[0], # 'replay_message': form_object_system_message, # 'replay_status': 'true', # 'teacher_infos': teacher_infos, # 'school_terms': school_terms, 'school_term': 0, 'teacher_info': 0, # 'message_not_confirm': not_confirm, # 'message_already_sent': message_already_sent, # 'system_announcement': system_announcement}) else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:未能获取到相关信息!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:未能获取到相关信息!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-错误信息展示页面' message = '操作失败:所要操作的记录不存在!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-错误信息展示页面' message = '操作失败:系统操作请求方式异常!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) except Exception as e: # raise e title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:未能获取到相关信息!错误信息提示:' + str(e) return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message })
def save_system_message(request): """ 保存并发送一个系统信息 :param request: :return: """ try: if request.method == 'POST': object_form = SystemMessageForm(request.POST) if object_form.is_valid(): form_object_system_message = form_to_obj( object_form.cleaned_data, SystemMessage()) form_object_system_message.sender = UserInfo.objects.get( register_user_info__username=request.session.get( 'username', None)) message_range = object_form.cleaned_data.get( 'message_range', None) # if message_range == message_range_system_announcement: # # 系统公告级别的 # print() # elif message_range == message_range_all_teacher: # # 所有负责人 # elif message_range == message_range_teacher_student: # # 负责人所辖所有的学员 if str(message_range) not in message_range_no_person: # 如果消息不是全体性的回复 receiver = object_form.cleaned_data.get('receiver', None) feedback_message = object_form.cleaned_data.get( 'feedback_message', None) if receiver: # 初始发送的消息 if type(receiver) == str: if "-" in receiver: ids = str(receiver).split("-") for id_str in ids: # 保存并发送到每个指定人 system_message = form_object_system_message system_message.receiver = UserInfo.objects.get( id=int(id_str)) system_message.save() else: if len(receiver) > 0: form_object_system_message.receiver = UserInfo.objects.get( id=int(receiver)) form_object_system_message.save() else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:收信人信息获取失败!' return render( request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: form_object_system_message.receiver = UserInfo.objects.get( id=receiver) form_object_system_message.save() elif feedback_message: # 是确认回复的消息 feedback_message_objects = SystemMessage.objects.filter( id=feedback_message).order_by('-id') if feedback_message_objects.count() > 0: form_object_system_message.feedback_message = feedback_message_objects[ 0] form_object_system_message.receiver = feedback_message_objects[ 0].sender form_object_system_message.save() else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:确认回复信件信息获取异常!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:收信人信息获取异常!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: if str(message_range) == '2': administrator_user_infos = UserInfo.objects.filter( register_user_info__role__role_name='administrator' ).order_by('-id') # form_object_system_message.receiver = administrator_user_infos[0] if administrator_user_infos.count() > 0: for administrator_user_info in administrator_user_infos: form_object_system_message_admin = form_object_system_message form_object_system_message_admin.receiver = administrator_user_info form_object_system_message_admin.save() else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:学校管理员信息获取失败,请完善学校管理员的用户基础信息!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) elif str(message_range) == '3': teachers = TeacherInfo.objects.all().order_by('-id') if teachers.count() > 0: for teacher in teachers: form_object_system_message_teacher = form_object_system_message form_object_system_message_teacher.receiver = teacher.user_info form_object_system_message_teacher.save() else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:您尚未添加负责人!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) elif str(message_range) == '6': username = request.session.get('username', None) register_user_info = RegisterUserInfo.objects.get( username=username) teacher_info = TeacherInfo.objects.get( user_info=UserInfo.objects.get( register_user_info=register_user_info)) student_infos = StudentInfo.objects.filter( teacher_info=teacher_info).order_by('-id') if student_infos.count() > 0: for student in student_infos: form_object_system_message_student = form_object_system_message form_object_system_message_student.receiver = student.user_info form_object_system_message_student.save() else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:您还没有负责人的学员!' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) elif str(message_range) == '8': username = request.session.get('username', None) register_user_info = RegisterUserInfo.objects.get( username=username) student_infos = StudentInfo.objects.filter( user_info=UserInfo.objects.get( register_user_info=register_user_info) ).order_by('-id') if student_infos.count() > 0: student_info = student_infos[0] if student_info.teacher_info: form_object_system_message.receiver = student_info.teacher_info.user_info form_object_system_message.save() else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:请正确选择负责人' return render( request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:您尚未填报任何职业信息,请返回首页填报鉴定职业' return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message }) else: form_object_system_message.save() return HttpResponseRedirect('/report/send/') except Exception as e: title_msg = sys_msg + '-错误信息展示页面' message = '系统提示:未能获取到相关信息!错误信息提示:' + str(e) return render(request, "page_main_controller/message.html", { 'title_msg': title_msg, 'message': message })