コード例 #1
0
def find_user_by(name=None, user_type=None):
    if name is None:
        raise exceptions.InvalidParameter("Name for User must be present")
    if user_type is None:
        raise exceptions.InvalidParameter(
            "You must indicate if you are a Client or an Owner")
    users_found = User.filter_by(name, user_type)
    if not users_found:
        raise exceptions.NotFound("There's no User matching the criteria")
    return users_found[0]
コード例 #2
0
ファイル: wall.py プロジェクト: wilson-boca/manotes-api
 def create_for_user(cls, id, user_id):
     db_instance = cls.repository.one_or_none(id=id)
     if db_instance is None:
         raise exceptions.NotFound(
             'Could not find a note with id {}'.format(id))
     if db_instance.user_id != user_id:
         raise exceptions.NotMine(
             'Could not create note because it dont belong to user id {}'.
             format(user_id))
     return cls(db_instance=db_instance)
コード例 #3
0
ファイル: database.py プロジェクト: strongbugman/flask_demo
 def fetch(self, sql: TextClause, **params) -> typing.List[RowProxy]:
     res = self.engine.execute(sql, **params).fetchall()
     if not res:
         raise excs.NotFound()
     return res
コード例 #4
0
ファイル: domain.py プロジェクト: wilson-boca/manotes-api
 def _create_with_keys(cls, **keys):
     db_instance = cls.repository.one_or_none(**keys)
     if db_instance is None:
         raise exceptions.NotFound('Could not find a user with keys: {}'.format(keys))
     return cls(db_instance=db_instance)
コード例 #5
0
ファイル: domain.py プロジェクト: wilson-boca/manotes-api
 def create_with_id(cls, id):
     db_instance = cls.repository.one_or_none(id=id)
     if db_instance is None:
         raise exceptions.NotFound('Could not find a entity with id {}'.format(id))
     return cls(db_instance=db_instance)
コード例 #6
0
def test_NotFound_detail():  # NOQA
    assert exceptions.NotFound().detail == 'Not Found'
コード例 #7
0
def test_NotFound_status_code():  # NOQA
    assert exceptions.NotFound().status_code == 404
コード例 #8
0
def get_client_by_external_id_and_source_id(external_client_id, system_id):
    searched_client = Client.query.filter_by(externalId=external_client_id,
                                             sourceId=system_id).first()
    if searched_client is None:
        raise exceptions.NotFound("There is no client with that ID")
    return searched_client
コード例 #9
0
def get_client(client_id):
    searched_client = Client.query.get(client_id)
    if searched_client is None:
        raise exceptions.NotFound("There is no client with that ID")
    return searched_client
コード例 #10
0
def get_queue(queue_id):
    searched_queue = ConceptQueue.query.get(queue_id)
    if searched_queue is None:
        raise exceptions.NotFound("There is no queue with that ID")
    return searched_queue
コード例 #11
0
def get_owner(owner_id):
    searched_owner = Owner.query.get(owner_id)
    if searched_owner is None:
        raise exceptions.NotFound("There is no owner with that ID")
    return searched_owner
コード例 #12
0
 def create_with_id(cls, something_id):
     db_instance = cls.repository.one_or_none(id=something_id)
     if db_instance is None:
         raise exceptions.NotFound(
             'Could not find a something with id = {}'.format(something_id))
     return cls(db_instance=db_instance)