예제 #1
0
 def json(self):
     return {
         'id': self.id,
         'user_id': self.user_id,
         'date': DateTimeHelper.full_date(self.date),
         'url': self.url,
     }
예제 #2
0
def login():
    '''
    새로운 토큰을 발급해 줍니다.
    '''
    user_session = afr(UserSession(g.pr_result.get('user')))
    Session().commit()
    return {'token': user_session.token, 'expiry': DateTimeHelper.full_datetime(user_session.expiry)}, Status.HTTP_200_OK
예제 #3
0
 def json(self):
     return {
         'id': self.id,
         'google_purchase_token': self.google_purchase_token,
         'google_order_id': self.google_order_id,
         'type': self.type,
         'created_at': DateTimeHelper.full_datetime(self.created_at)
     }
예제 #4
0
 def json(self):
     return {
         'id': self.id,
         'from_user_id': self.from_user_id,
         'to_user_id': self.to_user_id,
         'memo': self.memo,
         'created_at': DateTimeHelper.full_datetime(self.created_at),
         'status': self.status,
     }
예제 #5
0
 def json(self, **kwargs):
     return {
         'id': self.id,
         'to_user_id': self.to_user_id,
         'body': self.body,
         'fire': self.fire,
         'read': self.read,
         'created_at': DateTimeHelper.full_datetime(self.created_at)
     }
예제 #6
0
def sign_up():
    '''
    auth_key, auth_value, phone, password 로 계정 하나를 생성합니다.
    '''
    user = afr(User(request.json.get('password'), phone=request.json.get('phone')))
    user_session = afr(UserSession(user))
    Session().commit()

    return {'user_id': user.id, 'token': user_session.token, 'expiry': DateTimeHelper.full_datetime(user_session.expiry)}, Status.HTTP_200_OK
예제 #7
0
 def json(self):
     return {
         'id': self.id,
         'result_rate': self.result_rate,
         'result_mbti': self.result_mbti,
         'rates_in_100': self.rates_in_100,
         'user_id': self.user_id,
         'animal_id': self.animal_id,
         'created_at': DateTimeHelper.full_datetime(self.created_at),
     }
예제 #8
0
 def json(self):
     result = {
         'id': self.id,
         'from_user_id': self.from_user_id,
         'from_user': self.from_user.json(),
         'to_user_id': self.to_user_id,
         'matched': self.matched,
         'heart_id': self.heart_id,
         'created_at': DateTimeHelper.full_datetime(self.created_at),
     }
     if self.heart:
         result['heart'] = self.heart.json()
     return result
예제 #9
0
    def json(self, **kwargs):
        result = {
            'id': self.id,
            'from_user_id': self.from_user_id,
            'to_user_id': self.to_user_id,
            'double': self.double,
            'accpeted': self.accpeted,
            'created_at': DateTimeHelper.full_datetime(self.created_at),
        }

        if kwargs.get('with_users'):
            result['from_user'] = self.from_user.json()
            result['to_user'] = self.to_user.json()

        return result
예제 #10
0
def login_kakao():
    oauth = Session().query(OauthKakao).filter(
        OauthKakao.party_id == g.info.get('id')).first()
    is_new = True if oauth is None else False

    if is_new:
        user = afr(User(email=g.info['kakao_account'].get('email')))
        oauth = afr(OauthKakao(user, g.info))
        afr(UserPoint(user_id=user.id))

    user_session = UserSession(oauth.user,
                               third_party_token=request.json.get('token'))
    Session(changed=True).add(user_session)

    return {
        'user_id': oauth.user.id,
        'token': user_session.token,
        'is_new': is_new,
        'expiry': DateTimeHelper.full_datetime(user_session.expiry)
    }, Status.HTTP_200_OK
예제 #11
0
def login_google():
    oauth = Session().query(OauthGoogle).filter(
        OauthGoogle.party_id == g.info.get('id')).first()
    is_new = True if oauth is None else False

    if is_new:
        user = afr(User(email=g.info.get('email')))
        oauth = afr(OauthGoogle(user, g.info))
        user.oauth_google_id = oauth.id

    user_session = UserSession(oauth.user,
                               third_party_token=request.json.get('token'))
    Session(changed=True).add(user_session)

    return {
        'okay': True,
        'user_id': oauth.user.id,
        'token': user_session.token,
        'is_new': is_new,
        'expiry': DateTimeHelper.full_datetime(user_session.expiry)
    }, Status.HTTP_200_OK
예제 #12
0
    def json(self, with_animal=True, **kwargs):
        result = {
            'id':
            self.id,
            'animal_id':
            self.animal_id,
            'email':
            self.email,
            'frozen_at':
            DateTimeHelper.full_datetime(self.frozen_at),
            'frozen_until':
            DateTimeHelper.full_datetime(self.frozen_until),
            'dormant_at':
            DateTimeHelper.full_datetime(self.dormant_at),

            # 신상 정보
            'name':
            self.name,
            'age':
            self.age,
            'sex':
            self.sex,
            'nick_name':
            self.nick_name,
            'education':
            self.education,
            'occupation':
            self.occupation,
            'occupation_confirmed':
            self.occupation_confirmed,
            'occupation_confirmed_at':
            DateTimeHelper.full_datetime(self.occupation_confirmed_at),
            'company':
            self.company,
            'pictures':
            self.pictures,
            'bio':
            self.bio,
            'phone':
            self.phone,
            'phone_registered':
            self.phone_registered,
            'location1':
            self.location1,
            'location2':
            self.location2,
            'height':
            self.height,
            'body_shape':
            self.body_shape,
            'religion':
            self.religion,
            'hobby':
            self.hobby,
            'speciality':
            self.speciality,
            'interest':
            self.interest,
            'drink':
            self.drink,
            'cigarette':
            self.cigarette,

            # 아는 사람
            'acquaintance':
            self.acquaintance,

            # 이상형 정보
            'ideal_age_start':
            self.ideal_age_start,
            'ideal_age_end':
            self.ideal_age_end,
            'ideal_body_shape':
            self.ideal_body_shape,
            'ideal_type_groups':
            self.ideal_type_groups,
            'ideal_height_start':
            self.ideal_height_start,
            'ideal_height_end':
            self.ideal_height_end,

            # 기타
            'registration_phase':
            self.registration_phase,
            'registration_confirmed':
            self.registration_confirmed,
            'registration_confirmed_at':
            DateTimeHelper.full_datetime(self.registration_confirmed_at),

            # 통계 정보
            'rate':
            float(self.rate),
            'rating_required':
            self.rating_required,
            'last_access':
            DateTimeHelper.full_datetime(self.last_access),
            'registered_at':
            DateTimeHelper.full_datetime(self.registered_at),
        }

        if self.phone:
            result['phone'] = self.phone

        if with_animal and self.animal_id:
            result['animal'] = self.animal.json()

        if kwargs.get('with_point'):
            result['hp'] = self.point.hp
            result['mp'] = self.point.mp

        return result