Exemplo n.º 1
0
    def _get_project_model(self) -> ProjectModel:
        model = ProjectModel.get_or_none(ProjectModel.project_id == self._project_id)

        if model is None:
            raise ValueError(
                "ProjectModel with project_id {} was not found".format(self._project_id)
            )

        return model
Exemplo n.º 2
0
    def _get_project_model(self) -> ProjectModel:
        """
        :return: the project's model matching the given ids
        """
        model = ProjectModel.get_or_none(ProjectModel.model_id == self.model_id)

        if model is None:
            raise ValueError("could not find model_id of {}".format(self.model_id))

        return model
Exemplo n.º 3
0
def get_project_model_by_project_id(
    project_id: str, raise_not_found: bool = True
) -> ProjectModel:
    """
    Get a project model by its project_id

    :param project_id: project id of the project model
    :param raise_not_found: if no model is found raise an HTTPNotFoundError,
        otherwise return the result no matter what
    :return: Project model with the project id
    """
    query = ProjectModel.get_or_none(ProjectModel.project_id == project_id)

    if query is None and raise_not_found:
        _LOGGER.error("could not find model for project_id {}".format(project_id))
        raise HTTPNotFoundError(
            "could not find model for project_id {}".format(project_id)
        )

    return query