Esempio n. 1
0
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))
Esempio n. 2
0
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
        }))
Esempio n. 3
0
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
Esempio n. 4
0
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))
Esempio n. 5
0
def get_operators():
    operators = OperatorQuery(get_db_session()).get_operators()
    return jsonize.json_response(jsonize.dumps(operators))
Esempio n. 6
0
def get_available_signs():
    return jsonize.json_response(jsonize.dumps(all_available_sign))
Esempio n. 7
0
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))
Esempio n. 8
0
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))
Esempio n. 9
0
def get_launch_histories():
    histories = SchedulerQuery(get_db_session()).get_launch_histories()
    return jsonize.json_response(jsonize.dumps(histories))
Esempio n. 10
0
def get_current_runners():
    current_runners = SchedulerQuery(get_db_session()).get_current_runners()
    return jsonize.json_response(jsonize.dumps(current_runners))
Esempio n. 11
0
def get_uuid():
    uuid = UuidFactory.new_uuid()
    return jsonize.json_response(jsonize.dumps(uuid))
Esempio n. 12
0
def get_teams():
    teams = UserQuery(get_db_session()).get_teams_without_default()
    return jsonize.json_response(jsonize.dumps(teams))