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_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. 3
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. 4
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. 5
0
def get_launch_histories():
    histories = SchedulerQuery(get_db_session()).get_launch_histories()
    return jsonize.json_response(jsonize.dumps(histories))
Esempio n. 6
0
def get_current_runners():
    current_runners = SchedulerQuery(get_db_session()).get_current_runners()
    return jsonize.json_response(jsonize.dumps(current_runners))
Esempio n. 7
0
    def set_test(self):
        self.init()

        session = self.create_session()

        # add teams
        team_facade = UserFacade(session)
        team1 = team_facade.append_team(Team.new('チーム1', ''))
        team_facade.append_team(Team.new('チーム2', ''))
        team_facade.append_team(Team.new('チーム3', ''))

        session.flush()

        # add users
        append_user = UserFacade(session).append_user
        append_user(User.new('user1', 'ユーザ1', team1, role=UserRole.OPERATOR))
        user1 = append_user(User.new('user2', 'ユーザ2', team1, role=UserRole.OPERATOR))
        user2 = append_user(User.new('user3', 'ユーザ3', team1, role=UserRole.OPERATOR))
        user3 = append_user(User.new('user4', 'ユーザ4', team1, role=UserRole.OPERATOR))

        session.flush()

        # add skills
        from domains.models.operator import Skill

        skill1 = Skill.new('スキル1', 1, is_certified=True)
        session.add(skill1)
        skill2 = Skill.new('スキル2', 3, is_certified=True)
        session.add(skill2)
        session.add(Skill.new('スキル3', 2, is_certified=True))
        skill3 = Skill.new('スキル4', 5, is_certified=False)
        session.add(skill3)

        # add scheduler

        from datetime import time

        from backend.services import OperatorQuery
        from backend.services import SchedulerQuery
        from domains.models.scheduler import WorkCategory

        get_operator_of_user_id = OperatorQuery(session).get_operator_of_user_id
        work_daily = WorkCategory.new('勤務帯1', time(9, 30), time(18, 00), 7, 10, 3, 5, 0, 0,
                                      [get_operator_of_user_id(user1.id), get_operator_of_user_id(user2.id)],
                                      [], [], [], [])
        scheduler = SchedulerQuery(session).get_scheduler_of_team_id(team1.id)
        scheduler.work_categories.append(work_daily)
        scheduler.work_categories.append(
            WorkCategory.new('勤務帯2', time(17, 30), time(10, 00), 3, 5, 3, 5, 1, 5,
                             [], [], [skill3], [], [get_operator_of_user_id(user3.id)])
        )
        session.flush()

        # add scheduler calendar

        from utils.date import get_next_month
        from domains.models.scheduler import MonthlySetting

        next_month = get_next_month()
        monthly_setting = MonthlySetting.new(scheduler.work_categories,
                                             next_month.month, next_month.year)
        monthly_setting.is_published = True
        scheduler.monthly_settings.append(monthly_setting)

        session.flush()

        session.commit()
        session.close()