def get_abnormal(s, access_token, data): now = datetime.datetime.now() days_from_now = (now - datetime.timedelta(days=400)) # abnormal in 400 days result = work_api.get_abnormal_list(s, access_token, days_from_now, now) return Response(common.utf_to_res_text(result), content_type="application/json;charset=UTF-8")
def ot_hours(s, access_token, data): now = datetime.datetime.now() first_month_day = datetime.datetime(int(now.strftime('%Y')), int(now.strftime('%m')), 1) result = OT_api.get_ot_hours(s, access_token, first_month_day, now) return Response(common.utf_to_res_text(result), content_type="application/json;charset=UTF-8")
def get_work(s, access_token, data): access_token = general.get_access_token(s) now = datetime.datetime.now() last_monday = now - datetime.timedelta(days=(int(now.strftime('%w')) + 6)) result = work_api.get_work_list(s, access_token, last_monday, now) return Response(common.utf_to_res_text(result), content_type="application/json;charset=UTF-8")
def get_preOT(s, access_token, data): now = datetime.datetime.now() last_monday = now - datetime.timedelta(days=(int(now.strftime('%w')) + 13)) next_monday = last_monday + datetime.timedelta(days=21) result = preOT_api.get_preOT_list(s, access_token, last_monday, next_monday) return Response(common.utf_to_res_text(result), content_type="application/json;charset=UTF-8")
def get_user(s, access_token, data): now = datetime.datetime.now() days_from_now = (now - datetime.timedelta(days=1)) result = general.get_user_info(s, access_token, days_from_now, now) return Response(common.utf_to_res_text(result), content_type="application/json;charset=UTF-8")
def test2(s, access_token, data): result = OT_api.get_OT_schedule(data['username']) return Response(common.utf_to_res_text({'result': result}), content_type="application/json;charset=UTF-8")
def test1(s, access_token, data): test_day = datetime.datetime.strptime( data['day'], '%Y-%m-%d') if data.get('day') else None result = OT_api.schedule_OT(data, [test_day]) return Response(common.utf_to_res_text({'result': result}), content_type="application/json;charset=UTF-8")