mdvtools.dbutils.dbservice#

Attributes#

Classes#

Module Contents#

mdvtools.dbutils.dbservice.logger[source]#
class mdvtools.dbutils.dbservice.ProjectService[source]#
failed_projects: list[tuple[int, str | Exception]] = [][source]#
static get_active_projects()[source]#
static get_next_project_id()[source]#
static add_new_project(path, name='unnamed_project')[source]#
static get_project_by_id(id)[source]#
static soft_delete_project(id)[source]#
static update_project_name(project_id, new_name)[source]#
static change_project_access(project_id, new_access_level)[source]#

Change the access level of a project.

static set_project_update_timestamp(project_id: str)[source]#
static set_project_accessed_timestamp(project_id: str)[source]#
class mdvtools.dbutils.dbservice.FileService[source]#
static add_or_update_file_in_project(file_name, file_path, project_id)[source]#

Adds a new file or updates an existing file in the database.

static get_file_by_path_and_project(file_path, project_id)[source]#

Fetch a file by its path and project ID.

static file_exists_in_project(file_path, project_id)[source]#

Utility function to check if a file exists in the files table.

static get_files_by_project(project_id)[source]#
static delete_files_by_project(project_id)[source]#
static update_file_timestamp(file_id)[source]#
class mdvtools.dbutils.dbservice.UserService[source]#
static add_or_update_user(email: str, auth_id: str | None = None, first_name: str | None = None, last_name: str | None = None, institution: str | None = None)[source]#

Adds a new user or updates an existing user based on the provided email.

Parameters:
  • email – User’s email address (mandatory).

  • auth_id – User’s Auth ID (optional).

  • first_name – User’s first name (optional).

  • last_name – User’s last name (optional).

  • institution – User’s institution or association (optional).

Returns:

The created or updated User object.

class mdvtools.dbutils.dbservice.UserProjectService[source]#
static add_or_update_user_project(user_id: int, project_id: int, is_owner: bool = False, can_write: bool = False)[source]#

Adds a new user-project relationship or updates an existing one. Permission logic: - If is_owner is True, can_read and can_write are set to True. - If can_write is True (and is_owner is False), can_read is set to True. - If neither is_owner nor can_write is True, can_read is set to True.

static get_user_project_permissions(user_id: int, project_id: int) dict[source]#

Returns the permission info (can_read, can_write, is_owner) for the given user and project.

static remove_user_from_project(user_id: int, project_id: int)[source]#

Remove a user from a project.