예제 #1
0
 def __init__(self, request_json):
     self.zip_code = StringUtils.to_int(request_json.get('zip_code'))
     self.address = request_json.get('address')
     self.sido = request_json.get('sido')
     self.sigungu = request_json.get('sigungu')
     self.bname = request_json.get('bname')
     self.latitude = StringUtils.to_float(request_json.get('latitude'))
     self.longitude = StringUtils.to_float(request_json.get('longitude'))
예제 #2
0
 def __init__(self, purchase):
     self.kind = purchase.get('kind')
     self.purchase_time_millis = StringUtils.to_int(
         purchase.get('purchaseTimeMillis'))
     self.purchase_state = StringUtils.to_int(purchase.get('purchaseState'))
     self.consumptionState = StringUtils.to_int(
         purchase.get('consumptionState'))
     self.deveoper_payload = purchase.get('developerPayload')
예제 #3
0
 def __init__(self, request_json):
     self.order_id = request_json.get('order_id')
     self.package_name = request_json.get('package_name')
     self.product_id = request_json.get('product_id')
     self.purchase_time = StringUtils.to_int(
         request_json.get('purchase_time'))
     self.purchase_state = StringUtils.to_int(
         request_json.get('purchase_state'))
     self.purchase_token = request_json.get('purchase_token')
예제 #4
0
 def __init__(self, request_json):
     self.subjects = request_json.get('subjects')
     self.days_of_week = request_json.get('days_of_week')
     self.class_available_count = StringUtils.to_int(request_json.get('class_available_count'))
     self.class_time = StringUtils.to_int(request_json.get('class_time'))
     self.preferred_gender = request_json.get('preferred_gender')
     self.preferred_price = StringUtils.to_int(request_json.get('preferred_price'))
     # 경력
     self.career = StringUtils.to_int(request_json.get('career'))
     self.description = request_json.get('description')
예제 #5
0
 def __init__(self, **kwargs):
     self.universities = StringUtils.to_list(kwargs.get('universities'))
     self.major = kwargs.get('major')
     self.gender = kwargs.get('gender')
     self.subjects = StringUtils.to_list(kwargs.get('subjects'))
     self.more_than_price = StringUtils.to_int(
         kwargs.get('more_than_price'))
     self.less_than_price = StringUtils.to_int(
         kwargs.get('less_than_price'))
     self.max_zip_code = kwargs.get('max_zip_code')
     self.min_zip_code = kwargs.get('min_zip_code')
     self.next_token = StringUtils.to_int(kwargs.get('next_token'))
     self.per_page = kwargs.get('per_page')
예제 #6
0
 def __init__(self, request_json):
     self.type = request_json.get('type')
     self.name = request_json.get('name')
     self.gender = request_json.get('gender')
     self.phone_number = request_json.get('phone_number')
     self.birth_year = StringUtils.to_int(request_json.get('birth_year'))
     self.location = None
     if request_json.get('location') is not None:
         self.location = Location(request_json.get('location'))
     # 학교 상태 (유치원/초/중/고/재수/일반인)
     self.student_status = request_json.get('student_status')
     self.grade = StringUtils.to_int(request_json.get('grade'))
     # 계열 (문/이/예/실)
     self.department = request_json.get('department')
예제 #7
0
 def __init__(self, **kwargs):
     self.gender = kwargs.get('gender')
     self.subjects = StringUtils.to_list(kwargs.get('subjects'))
     self.more_than_price = StringUtils.to_int(
         kwargs.get('more_than_price'))
     self.less_than_price = StringUtils.to_int(
         kwargs.get('less_than_price'))
     self.student_status = kwargs.get('student_status')
     self.grade = StringUtils.to_int(kwargs.get('grade'))
     self.max_zip_code = kwargs.get('max_zip_code')
     self.min_zip_code = kwargs.get('min_zip_code')
     self.statuses = kwargs.get('statuses')
     self.next_token = StringUtils.to_int(kwargs.get('next_token'))
     self.per_page = kwargs.get('per_page')
예제 #8
0
 def __init__(self, request_json):
     self.type = request_json.get('type')
     self.name = request_json.get('name')
     self.gender = request_json.get('gender')
     self.phone_number = request_json.get('phone_number')
     self.birth_year = StringUtils.to_int(request_json.get('birth_year'))
     self.location = None
     if request_json.get('location') is not None:
         self.location = Location(request_json.get('location'))
     self.university = request_json.get('university')
     self.university_rank = request_json.get('university_rank')
     # 대학 상태(재학중/휴학중/졸업)
     self.university_status = request_json.get('university_status')
     self.major = request_json.get('major')
예제 #9
0
def get_user_profile(user_id):
    """
    :param user_id:
    :return:
    :parameter phone_number(Bool)
    :error
        NO_SUCH_ELEMENT
    """
    user_data = auth_service.check_permission()
    is_checked_phone_number = StringUtils.to_bool(
        request.args.get('phone_number'))
    if is_checked_phone_number and user_service.is_checked_phone_number(
            user_data.get('id'), user_id):
        is_checked_phone_number = True
    else:
        is_checked_phone_number = False
    user = user_service.get_user(user_id)
    is_favorited = False
    if user_service.get_favorite(user_data.get('id'), user.id) is not None:
        is_favorited = True
    return UserDTO(user,
                   is_checked_phone_number=is_checked_phone_number,
                   is_favorited=is_favorited), None
예제 #10
0
def add_lesson_bidding(lesson_id, user_id, bidding_request):
    lesson = Lesson.query.get(lesson_id)
    if lesson is None:
        raise NoSuchElementError(extra_message='Lesson is not existed.')
    if lesson.status != LessonStatus.BIDDING:
        raise BadRequestError(cause=ErrorCause.EXPIRED_LESSON_BIDDING,
                              message='Lesson is expired.')
    user = User.query.get(user_id)
    if user.type != UserType.TEACHER:
        raise InvalidArgumentError(
            extra_message='It can be available only by teacher.')
    bidding = LessonBidding.query \
        .filter(LessonBidding.lesson_id == lesson_id) \
        .filter(LessonBidding.user_id == user.id).first()
    if bidding is not None:
        raise ElementAlreadyExists(extra_message='Already bidding.')
    bidding = LessonBidding()
    bidding.lesson_id = lesson.id
    bidding.user_id = user.id
    if bidding_request is None:
        raise InvalidArgumentError(
            extra_message='Bidding price must not be null.')
    price = StringUtils.to_int(bidding_request.price)
    if price is None:
        raise InvalidArgumentError(extra_message='Price is wrong.')
    bidding.price = price
    bidding.created_at = current_millis()
    db.session.add(bidding)
    db.session.commit()

    # 선생님은 입찰할 때마다 coin을 차감시킨다.
    subtract_coins(user_id, CoinValueOfTransactionType.BIDDING,
                   TransactionType.BIDDING)
    add_notification(NotificationRequest().to(
        lesson.owner.id).on_bidding_lesson(user_id, lesson.id))
    return bidding
예제 #11
0
 def __init__(self, **kwargs):
     self.user_id = kwargs.get('user_id')
     self.next_token = StringUtils.to_int(kwargs.get('next_token'))
     self.per_page = kwargs.get('per_page')
예제 #12
0
 def __init__(self, request_json):
     self.price = StringUtils.to_int(request_json.get('price'))
예제 #13
0
 def __init__(self, request_json):
     self.hide_on_searching = StringUtils.to_bool(request_json.get('hide_on_searching'))
예제 #14
0
def charge_coins(user_id):
    coins = StringUtils.to_int(request.get_json().get('coins'))
    if coins is not None and coins > 0:
        coin_service.add_coins(user_id, coins, TransactionType.ADMIN)
    return True, None
예제 #15
0
 def __init__(self, **kwargs):
     self.email_pattern = kwargs.get('email_pattern')
     self.next_token = StringUtils.to_int(kwargs.get('next_token'))
     self.per_page = kwargs.get('per_page')