def sign_out_act(): act_id = request.data enrolled = GK.get_act_detail(act_id.decode(), session['u_id']) if enrolled: GK.sign_out_act(act_id.decode(), session['u_id']) rs = GK.get_act_detail(act_id.decode(), session['u_id']) return json.dumps(rs, ensure_ascii=False, indent=4) return json.dumps({'error': True}, ensure_ascii=False, indent=4)
def reward(): rs = GK.get_reward(session['u_id']) reward_class = GK.get_rewards_statics(session['stu_info']['class']['_id']) reward_user = list(filter(lambda reward: reward['_id'] == session['u_id'], reward_class))[0] filter_list = ['tech', 'health', 'political', 'art', 'creative', 'volunteer', 'synthese'] reward_list = {i: int(v) for i, v in reward_user.items() if i in filter_list} reward_count = sum(reward_list.values()) return render_template('reward.html', reward_list=rs, reward_user=reward_user, reward_count=reward_count)
def sign_in_act(): if not session.get('logged', None): return redirect('/login') act_id = request.data enrolled = GK.get_act_detail(act_id.decode(), session['u_id']) if enrolled: GK.sign_activity(act_id.decode(), session['u_id']) rs = GK.get_act_detail(act_id.decode(), session['u_id']) return json.dumps(rs, ensure_ascii=False, indent=4) return json.dumps({'error': True}, ensure_ascii=False, indent=4)
def sign(): # if not session.get('logged', None): # return redirect('/login') result = GK.post('get_signin_by_student_opt', student=session['u_id']) photo_list = None if result: photo_list = GK.post('get_partication_by_schedule', schedule=result['schedule']['_id']) # result = None # photo_list = GK.post('get_partication_by_schedule', schedule='5c22f4b1dbd73973b64b45a7') return render_template('sign_in.html', result=result, photo_list=photo_list)
def cancel(): if session.get('logged', None): act_id = request.data cd = GK.cancel(act_id.decode(), session['u_id']) # cd = 'success' return Response(cd) return '''{"Error": "未登录"}''', 200, {'Content-Type': 'text/html;charset=UTF-8'}
def enroll_act(): # if not session.get('logged', None): # return redirect('/login') act_id = request.data print(act_id) rs = GK.create_active(act_id.decode(), session['u_id']) print(rs) return json.dumps(rs, ensure_ascii=False, indent=4)
def sign_in(): # if not session.get('logged', None): # return redirect('/login') file = request.files['file'] base_path = path.abspath(path.dirname(__file__)) file_path = path.join(base_path, 'file') filename = path.join(file_path, secure_filename(file.filename)) file.save(filename) sign_info = GK.post('get_signin_by_student_opt', student=session['u_id']) sign_result = GK.sign_in(session['stu_info'], sign_info['_id']) sign_upload_result = GK.sign_upload(filename, session['stu_info'], sign_info) result = { 'upload': sign_upload_result.strip('"'), 'signIn': sign_result } return Response(json.dumps(result, ensure_ascii=False))
def send(username): gk = GK(username) gk.get_info() gk.get_act() return gk
def get_enroll_list(): # if not session.get('logged', None): # return redirect('/login') rs = GK.get_enroll_list(session['u_id']) return json.dumps(rs, ensure_ascii=False, indent=4)
def act_detail_stu(act): # if not session.get('logged', None): # return redirect('/login') act_id = request.data rs = GK.get_act_detail(act, session['u_id']) return json.dumps(rs, ensure_ascii=False, indent=4)
def query_teacher(u_id): return json.dumps(GK.get_teacher(u_id), ensure_ascii=False)
def act_detail(act_id): act_list = GK.get_act_detail(act_id) act_info = GK.get_act_info(act_id) return render_template('act_detail.html', act_list=enumerate(act_list), act_info=act_info)