def get_monthly_setting(): team_id = request.args.get('team-id') schedule_of = to_date(request.args.get('schedule-of'), '%Y-%m') scheduler = SchedulerQuery( get_db_session()).get_scheduler_of_team_id(team_id) monthly_setting = scheduler.monthly_setting(schedule_of.month, schedule_of.year) return jsonize.json_response(jsonize.dumps(monthly_setting))
def get_schedules(): team_id = request.args.get('team-id') schedule_of = to_date(request.args.get('schedule-of'), '%Y-%m') day_settings, schedules = ScheduleFacade(get_db_session()).get_schedule( team_id, schedule_of.month, schedule_of.year) return jsonize.json_response( jsonize.dumps({ 'day_settings': day_settings, 'schedules': schedules }))
def append_vacation(): session = get_db_session() try: req = SchedulerCommandAdapter(session).append_vacation( jsonize.loads(request.data)) session.commit() session.refresh(req) response = jsonize.json_response(jsonize.dumps(req)) except Exception as e: session.rollback() print(e) response = jsonize.json_response(status_code=400) return response
def get_vacations(): team_id = request.args.get('team-id') scheduler = SchedulerQuery( get_db_session()).get_scheduler_of_team_id(team_id) schedule_of = to_date(request.args.get('schedule-of'), '%Y-%m') def is_in_period(on_from, on_to): return (on_from.year == schedule_of.year and on_from.month <= schedule_of.month or on_from.year < schedule_of.year)\ and (on_to.year == schedule_of.year and on_to.month >= schedule_of.month or schedule_of.year < on_to.year) vacations = list( filter(lambda x: is_in_period(x.on_from, x.on_to), scheduler.vacations)) return jsonize.json_response(jsonize.dumps(vacations))
def get_operators(): operators = OperatorQuery(get_db_session()).get_operators() return jsonize.json_response(jsonize.dumps(operators))
def get_available_signs(): return jsonize.json_response(jsonize.dumps(all_available_sign))
def get_work_categories(): team_id = request.args.get('team-id') scheduler = SchedulerQuery( get_db_session()).get_scheduler_of_team_id(team_id) work_categories = scheduler.work_categories return jsonize.json_response(jsonize.dumps(work_categories))
def get_scheduler(): team_id = request.args.get('team-id') scheduler = SchedulerQuery( get_db_session()).get_scheduler_of_team_id(team_id) return jsonize.json_response(jsonize.dumps(scheduler))
def get_launch_histories(): histories = SchedulerQuery(get_db_session()).get_launch_histories() return jsonize.json_response(jsonize.dumps(histories))
def get_current_runners(): current_runners = SchedulerQuery(get_db_session()).get_current_runners() return jsonize.json_response(jsonize.dumps(current_runners))
def get_uuid(): uuid = UuidFactory.new_uuid() return jsonize.json_response(jsonize.dumps(uuid))
def get_teams(): teams = UserQuery(get_db_session()).get_teams_without_default() return jsonize.json_response(jsonize.dumps(teams))