3.6. project_utils module

async project_utils.archive_objective_including_children(db_session: AsyncSession, objectives: list[Objective]) None[source]

Checks if objectives should be archived after changes to a project they belong to. Also checks their children objectives recursively and checks if they need to be archived

param objectives: list of Objective objects

project_utils.calculate_key_result_progress(key_result: KeyResult) float[source]

Calculate the progress for a key result.

param key_result: the key result to build the progress for return: the progress as float, between 0 and 1

async project_utils.calculate_objective_progress(db_session: AsyncSession, objective_id: UUID) float[source]

Calculate the progress for an objective by averaging the progress of its key results.

param objective_id: the ID of the objective to build the progress for return: the progress as float, between 0 and 1

async project_utils.change_project_deadline(db_session: AsyncSession, project_id: str, new_deadline: datetime) SuccessResponse[source]

Extends the project deadline

param project_id: the ID of the project param new_deadline: the new deadline of the project

project_utils.check_value_within_bounds(value, a, b)[source]
async project_utils.get_key_results_for_objective(db_session: AsyncSession, objective_id: UUID) list[KeyResult][source]

Get all key results for a given objective ID.

param objective_id: the ID of the objective for which to retrieve key results return: a list of key results related to the given objective

async project_utils.get_objectives_for_project(db_session: AsyncSession, project_id: str) list[Objective][source]

Fetch all objectives for a given project ID

param project_id: the ID of the project return: list of Objective objects linked to the project

async project_utils.get_projects_for_user(db_session: AsyncSession, user_id: UUID) list[Project][source]

Get all projects for the given user.

param user_id: the id of the user to filter for return: a list of all projects where the current user is participating

async project_utils.get_user_role_for_project(db_session: AsyncSession, project_id: str, user_id: str) UserRole | None[source]

Gets the role for a user in a project

param project_id: the ID of the project param user_id: the ID of the user return: the role of the user in the project

async project_utils.has_key_result_write_permissions(db_session: AsyncSession, user: User, key_result_id: str) bool[source]

Check whether a user has permissions for modifying this key result.

That’s true if the user participates in any project that is related to this key result.

async project_utils.has_objective_write_permissions(db_session: AsyncSession, user: User, objective_id: str) bool[source]

Check whether a user has permissions for modifying this objective.

That’s true if the user participates in any project that is related to this objective.

async project_utils.has_project_lead_permissions(db_session: AsyncSession, user: User, project_id: str) bool[source]

Return True if the current user may act as project leader for this project.

async project_utils.has_task_write_permissions(db_session: AsyncSession, user: User, task_id: str) bool[source]

Check whether a user has permissions for modifying this task.

That’s true if the user participates in any project that is related to this task.

async project_utils.has_weak_project_permissions(db_session: AsyncSession, user: User, project_id: str) bool[source]

Return True if the current user has permissions to do low-impact actions on the project.

E.g., such low-impact actions would be creating, updating, deleting objectives and key result … For permissions to modify projects, see has_project_lead_permissions instead.

async project_utils.key_result_exists(db_session: AsyncSession, key_result_id: str) bool[source]
async project_utils.objective_exists(db_session: AsyncSession, objective_id: str) bool[source]
async project_utils.project_exists(db_session: AsyncSession, project_id: str) bool[source]
async project_utils.unarchive_objective_including_children(db_session: AsyncSession, objectives: list[Objective]) None[source]

Unarchives all objectives, after changes to a project they belong to. Also unarchives all their children recursively.

param objectives: list of Objective objects