def get_mbti_indicator(synonym): try: indicator = Session().query(MbtiIndicator).filter( (MbtiIndicator.synonym == synonym)).one() except NoResultFound: raise ClientError(f'No Indicator Found synonym #{synonym}', status_code=Status.HTTP_404_NOT_FOUND) return {'indicator': indicator.json()}, Status.HTTP_200_OK
def get_mbti_result(user_id): try: mbti_result = Session().query(MbtiResult).filter((MbtiResult.user_id == user_id))\ .order_by(MbtiResult.id.desc()).first() except NoResultFound: raise ClientError(f'user #{user_id} mbti_result not found', Status.HTTP_404_NOT_FOUND) return {'result': mbti_result.json()}, Status.HTTP_200_OK
def get_animal(animal_id): try: animal = Session().query(Animal).filter((Animal.id == animal_id)).one() except NoResultFound: raise ClientError(f'No Animal Found id #{animal_id}', status_code=Status.HTTP_404_NOT_FOUND) return {'animal': animal.json()}, Status.HTTP_200_OK
def get_type_group(type_group_id): try: type_group = Session().query(TypeGroup).filter( (TypeGroup.id == type_group_id)).one() except NoResultFound: raise ClientError(f'No Type group Found id #{type_group_id}', status_code=Status.HTTP_404_NOT_FOUND) return {'type_group': type_group.json()}, Status.HTTP_200_OK
def get_picture_by_id(picture_id): try: picture = Session().query(Picture).filter_by(id=picture_id).one() except: raise ClientError(f'picture id #{picture_id} not found', Status.HTTP_404_NOT_FOUND) if picture.user_id != g.user_session.user.id: raise ClientError('not your picture') return picture.json(), Status.HTTP_200_OK
def get_match_by_id(match_id): ''' id 로 매치를 가져옵니다. ''' try: match = Session().query(Match).filter((Match.id == match_id)).one() except: raise ClientError(f'No Match Found ${match_id}', Status.HTTP_404_NOT_FOUND) if match.to_user_id != g.user_session.user.id: raise ClientError('Not Your Match', Status.HTTP_470_NOT_YOURS) return {'match': match.json()}, Status.HTTP_200_OK
def info(): admin = Session().query(Admin).filter( (Admin.user_id == g.user_session.user.id)).one() return {'admin': admin.json()}, Status.HTTP_200_OK