def post(self, request, eduproject_id):
     if session_judge_teacher(request):
         return HttpResponseRedirect('/')
     else:
         eduresult_name = request.POST.get('mingcheng' '')
         eduresult_type = request.POST.get('leixing', '7')
         eduresult_date = request.POST.get(
             'riqi',
             datetime.datetime.now().strftime("%Y-%m-%d"))
         if eduresult_date != '':
             eduresult_date = datetime.datetime.strptime(
                 eduresult_date, '%Y-%m-%d').date()
         eduresult_master = request.POST.get('suoyouren', '')
         eduresult_file = request.FILES.get('file')
         edufile_detail = file_upload(eduresult_file, 'EduResult')
         teacher = Teacher.objects.get(
             teacher_id=request.session['user_id'])
         edu_project = EduProject.objects.get(eduproject_id=eduproject_id)
         eduresult = EduResult()
         eduresult.eduresult_name = eduresult_name
         eduresult.eduresult_type = eduresult_type
         eduresult.eduresult_date = eduresult_date
         eduresult.eduresult_master = eduresult_master
         eduresult.eduresult_file_name = edufile_detail[0]
         eduresult.eduresult_file_url = edufile_detail[1]
         eduresult.eduproject_belong = edu_project
         eduresult.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}',
                             content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         student = Student.objects.get(student_id = request.session['user_id'])
         member_num = int(request.POST.get('member_num', '0'))
         stuname_list = []
         stunumber_list = []
         member_list = ''
         if member_num != 0:
             for i in range(1, member_num+1):
                 if i > 1:
                     if i < member_num:
                         member_list = member_list + request.POST.get('stuname_%d' %(i), '') + '、'
                     else:
                         member_list += request.POST.get('stuname_%d' %(i), '')
                 stuname_list.append(request.POST.get('stuname_%d' %(i), ''))
                 stunumber_list.append(request.POST.get('number_%d' %(i), ''))
         applicant_phone = request.POST.get('phone', '')
         applicant_email = request.POST.get('email', '')
         if student.student_name != stuname_list[0] and student.student_id != int(stunumber_list[0]) and student.student_phone != applicant_phone and student.student_email != applicant_email:
             return HttpResponse('{"status": "fail", "msg": "申请人信息填写错误"}', content_type='application/json')
         else:
             srtp_project = Project()
             srtp_project.project_appli_student = student
             srtp_project.project_name = request.POST.get('proname', '')
             srtp_project.project_plan = request.POST.get('jihua', '')
             srtp_project.project_type = request.POST.get('cx', 'cx')
             srtp_project.project_rank = request.POST.get('rank', '1')
             srtp_project.project_subject = request.POST.get('xueke','')
             srtp_project.project_depart = request.POST.get('depart', 'jt')
             srtp_project.project_fund_appli = int(request.POST.get('fund', '3000'))
             srtp_project.project_period = request.POST.get('zhouqi', '1年')
             srtp_project.project_form = request.POST.get('results', '实体')
             begin_date = request.POST.get('begin', datetime.datetime.now().strftime("%Y-%m-%d"))
             if begin_date != '':
                 begin_date = datetime.datetime.strptime(begin_date, "%Y-%m-%d").date()
             one_year = datetime.datetime.now() + datetime.timedelta(days=365)
             print(one_year)
             end_date = request.POST.get('end', one_year.strftime("%Y-%m-%d"))
             if end_date != '':
                 end_date = datetime.datetime.strptime(end_date, "%Y-%m-%d").date()
             srtp_project.project_date_begin = begin_date
             srtp_project.project_date_end = end_date
             teacher_name = request.POST.get('teacher', '')
             teacher = Teacher.objects.get(teacher_name = teacher_name)
             srtp_project.project_teacher = teacher
             srtp_project.project_member = member_list
             appli_file = request.FILES.get('apply_file', '')
             file_detail = file_upload(appli_file, 'SrtpAppli')
             srtp_project.project_appli_name = file_detail[0]
             srtp_project.project_appli_url = file_detail[1]
             srtp_project.project_apply_status = True
             srtp_project.save()
             return HttpResponse('{"status": "success", "msg": "success"}', content_type='application/json')
 def post(self, request):
     if session_judge_teacher(request):
         return HttpResponse('{"status": "fail", "msg": "/"}',
                             content_type='application/json')
     else:
         member_num = int(request.POST.get('member_num', '0'))
         peopleName_list = []
         peopleDuty_list = []
         member_list = ''
         if member_num != 0:
             for i in range(1, member_num + 1):
                 if i > 1:
                     if i < member_num:
                         member_list = member_list + request.POST.get(
                             'peopleName_%d' % (i), '') + '、'
                     else:
                         member_list += request.POST.get(
                             'peopleName_%d' % (i), '')
                 peopleName_list.append(
                     request.POST.get('peopleName_%d' % (i), ''))
                 peopleDuty_list.append(
                     request.POST.get('peopleDuty_%d' % (i), ''))
         edu_project = EduProject()
         edu_project.eduproject_name = request.POST.get('pro_name', '')
         edu_project.eduproject_belong_unit = request.POST.get(
             'work_unit', '')
         edu_project.eduproject_fund_appli = request.POST.get('fund', '')
         edu_project.eduproject_type = request.POST.get('type', 'zd')
         edu_project.eduproject_date_begin = request.POST.get(
             'begin_date', '')
         edu_project.eduproject_date_end = request.POST.get('end_date', '')
         person_in_charge_name = request.POST.get('peopleName_1', '')
         teacher = Teacher.objects.get(teacher_name=person_in_charge_name)
         edu_project.eduproject_person_in_charge = teacher
         teacher.teacher_gender = request.POST.get('gender', '')
         teacher.teacher_birth_date = request.POST.get('birth_date', '')
         teacher.teacher_major = request.POST.get('major', '')
         teacher.teacher_title = request.POST.get('title', '')
         teacher.teacher_duty = request.POST.get('peopleDuty_1', '')
         teacher.teacher_phone = request.POST.get('phone', '')
         teacher.teacher_email = request.POST.get('email', '')
         appli_file = request.FILES.get('apply_file', '')
         file_detail = file_upload(appli_file, 'EduReformApply')
         edu_project.eduproject_appli_name = file_detail[0]
         edu_project.eduproject_appli_url = file_detail[1]
         edu_project.eduproject_member = member_list
         teacher.save()
         edu_project.save()
         return HttpResponse('{"status": "success", "msg": "success"}',
                             content_type='application/json')
 def post(self, request):
     if session_judge_teacher(request):
         return HttpResponseRedirect('/')
     else:
         user_id = request.session['user_id']
         teacher = Teacher.objects.get(teacher_id=user_id)
         midtermreport = MidtermReport()
         midterm_file = request.FILES.get('mid_file', '')
         file_detail = file_upload(midterm_file, 'GradMidtermCollection')
         midtermreport.file_name = file_detail[0]
         midtermreport.file_url = file_detail[1]
         midtermreport.teacher_to = teacher
         midtermreport.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}',
                             content_type='application/json')
 def post(self, request):
     if session_judge_teacher(request):
         return HttpResponseRedirect('/')
     else:
         user_id = request.session['user_id']
         teacher = Teacher.objects.get(teacher_id=user_id)
         openingreport = OpeningReport()
         proposal_file = request.FILES.get('kaiti_file', '')
         file_detail = file_upload(proposal_file, 'GradOpeningCollection')
         openingreport.file_name = file_detail[0]
         openingreport.file_url = file_detail[1]
         openingreport.teacher_to = teacher
         openingreport.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}',
                             content_type='application/json')
 def post(self, request, eduproject_id):
     if session_judge_teacher(request):
         return HttpResponseRedirect('/')
     else:
         edu_project = EduProject.objects.get(eduproject_id=eduproject_id)
         edumidterm_file = request.FILES.get('file', '')
         file_detail = file_upload(edumidterm_file, 'EduMidTerm')
         edumidterm = EduMidTerm.objects.get(
             eduproject_belong_id=eduproject_id)
         edumidterm.edumidterm_file_name = file_detail[0]
         edumidterm.edumidterm_file_url = file_detail[1]
         edumidterm.edumidterm_check_status = '1'
         edumidterm.eduproject_belong = edu_project
         edumidterm.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}',
                             content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         student = Student.objects.get(student_id = request.session['user_id'])
         dissertation = Dissertation()
         teacher_name = request.POST.get('tea_name', '')
         teacher = Teacher.objects.get(teacher_name = teacher_name)
         dessertation_file = request.FILES.get('biye_file', '')
         file_detail = file_upload(dessertation_file, 'GradDissertation')
         dissertation.file_name = file_detail[0]
         dissertation.file_url = file_detail[1]
         dissertation.student_belong = student
         dissertation.teacher_to = teacher
         try:
             dissertation.save()
         except:
             return HttpResponse('{"status": "fail", "msg": "你已经提交毕业设计论文"}', content_type='application/json')
         return HttpResponse('{"status": "success", "msg": "添加成功"}', content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         student = Student.objects.get(student_id = request.session['user_id'])
         midtermreport = MidtermReport()
         teacher_name = request.POST.get('tea_name', '')
         teacher = Teacher.objects.get(teacher_name = teacher_name)
         midterm_file = request.FILES.get('mid_file', '')
         file_detail = file_upload(midterm_file, 'GradMidterm')
         midtermreport.file_name = file_detail[0]
         midtermreport.file_url = file_detail[1]
         midtermreport.student_belong = student
         midtermreport.teacher_to = teacher
         try:
             midtermreport.save()
         except:
             return HttpResponse('{"status": "fail", "msg": "你已经提交中期报告"}', content_type='application/json')
         return HttpResponse('{"status": "success", "msg": "添加成功"}', content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         student = Student.objects.get(student_id = request.session['user_id'])
         openingreport = OpeningReport()
         teacher_name = request.POST.get('tea_name', '')
         teacher = Teacher.objects.get(teacher_name = teacher_name)
         proposal_file = request.FILES.get('kaiti_file', '')
         file_detail = file_upload(proposal_file, 'GradOpening')
         openingreport.file_name = file_detail[0]
         openingreport.file_url = file_detail[1]
         openingreport.student_belong = student
         openingreport.teacher_to = teacher
         try:
             openingreport.save()
         except:
             return HttpResponse('{"status": "fail", "msg": "你已经提交开题报告"}', content_type='application/json')
         return HttpResponse('{"status": "success", "msg": "添加成功"}', content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         student = Student.objects.get(student_id=request.session['user_id'])
         srtp_project = Project.objects.get(project_appli_student_id=student.id)
         conclusion_file = request.FILES.get('file', '')
         file_detail = file_upload(conclusion_file, 'SrtpConclusion')
         try:
             conclusion = Conclusion.objects.get(project_belong_id=srtp_project.project_id)
         except Conclusion.DoesNotExist:
             conclusion = Conclusion()
         conclusion.conclusion_file_name = file_detail[0]
         conclusion.conclusion_file_url = file_detail[1]
         conclusion.conclusion_check_status = '1'
         conclusion.conclusion_check_point = '1'
         conclusion.project_belong = srtp_project
         conclusion.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}', content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         student = Student.objects.get(student_id=request.session['user_id'])
         srtp_project = Project.objects.get(project_appli_student_id=student.id)
         midterm_file = request.FILES.get('file', '')
         file_detail = file_upload(midterm_file, 'SrtpMidTerm')
         try:
             midterm = MidTerm.objects.get(project_belong_id = srtp_project.project_id)
         except MidTerm.DoesNotExist:
             midterm = MidTerm()
         midterm.midterm_file_name = file_detail[0]
         midterm.midterm_file_url = file_detail[1]
         midterm.midterm_check_status = '1'
         midterm.midterm_check_point = '1'
         midterm.project_belong = srtp_project
         midterm.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}', content_type='application/json')
 def post(self, request):
     if session_judge(request):
         return HttpResponseRedirect('/')
     else:
         result_name = request.POST.get('mingcheng' '')
         result_type = request.POST.get('leixing', '7')
         result_date = request.POST.get('riqi', datetime.datetime.now().strftime("%Y-%m-%d"))
         if result_date != '':
             result_date = datetime.datetime.strptime(result_date, '%Y-%m-%d').date()
         result_master = request.POST.get('suoyouren', '')
         result_file = request.FILES.get('file')
         file_detail = file_upload(result_file, 'SrtpResult')
         student = Student.objects.get(student_id=request.session['user_id'])
         srtp_project = Project.objects.get(project_appli_student_id=student.id)
         result = Result()
         result.result_name = result_name
         result.result_type = result_type
         result.result_date = result_date
         result.result_master = result_master
         result.result_file_name = file_detail[0]
         result.result_file_url = file_detail[1]
         result.project_belong = srtp_project
         result.save()
         return HttpResponse('{"status": "success", "msg": "添加成功"}', content_type='application/json')
Ejemplo n.º 13
0
def segment_cxr():

    parsed_files = request.files

    # get file for upload
    filename = file_upload(parsed_files, UPLOAD_PATH)
    if filename == None:
        output = {"Error": "A file has not been sent to the server!"}
        return jsonify(output)

    image = Image.open(os.path.join(UPLOAD_PATH, filename))

    # convert to grayscale and reshape the array to the network input
    image = image.resize((IMG_COLS, IMG_ROWS))
    image = image.convert('L')
    image = np.asarray(image, dtype=np.float32)
    image /= 255
    image = np.reshape(image, (1, IMG_COLS, IMG_ROWS, 1))

    segmentation = model.predict(image).argmax(axis=3)
    segmentation = np.squeeze(segmentation)

    image_encoded = convert_to_base64(segmentation)
    return image_encoded