Example #1
0
    def add_node(user: User,
                 node_type=ActionsEnum.A_FILL_TYPE_TIME,
                 time=Constants.base_time):
        current_task = user.get_current_task()

        chosen_date = user.get_chosen_date()

        TS = user.get_TS()

        if node_type == ActionsEnum.A_FILL_TYPE_TIME:
            current_task[Constants.presence] = True

            current_task[Constants.role_id] = user.get_role()
            current_task[Constants.chours] = time

            try:
                user.get_TS().change_time_in_task(
                    current_task[Constants.cdate],
                    current_task[Constants.task_id],
                    current_task[Constants.chours])

                current_task[Constants.update] = True
                user.add_task_to_list(current_task)
                user.set_current_task({})
            except TimeError as e:
                raise e
            except ValueError as e:
                raise e
        else:
            user.get_TS().write_absence(chosen_date, node_type)
Example #2
0
    def update_user(user: User):

        node = {
            Constants.chosen_date: user.get_chosen_date(),
            Constants.role_id: user.get_role(),
            Constants.task_list: user.get_task_list(),
            Constants.current_task: user.get_current_task(),
            Constants.reset_request: user.get_reset_request(),
            Constants.TS: user.get_TS()
        }

        ActiveUsers.users.update({user.get_id(): node})

        pass