Beispiel #1
0
    def _authenticate(self):
        method = self.request.method
        token_instance = Token()
        if method == "POST":
            the_post = Post()
            the_header = Headers()
            user_id = the_post.get_user_id(self)
            user_id = user_id if user_id else the_header.get_user_id(self)
            token = the_post.get_token(self)
            token = token if token else the_header.get_token(self)

            token_from_db = token_instance.get(user_id)
            if token_from_db and token_from_db.token == token:
                result = func(self)
            else:
                return self.write(
                    OHHOOperation.dict2json(Result.result_not_login()))
        elif method == "GET":
            the_get = Get()
            the_header = Headers()
            user_id = the_get.get_user_id(self)
            user_id = user_id if user_id else the_header.get_user_id(self)
            token = the_get.get_token(self)
            token = token if token else the_header.get_token(self)

            token_from_db = token_instance.get(user_id)

            if token_from_db and token_from_db.token == token:
                result = func(self)
            else:
                return self.write(
                    OHHOOperation.dict2json(Result.result_not_login()))
        else:
            result = func(self)
        return result
Beispiel #2
0
    def get(self):
        the_get = Get()
        user_id = the_get.get_user_id(self)
        friend_id = the_get.get_friend_id(self)
        latitude = the_get.get_friend_id(self)
        longitude = the_get.get_friend_id(self)

        instance = LogicMapDistance()
        result = instance.map_distance(user_id, friend_id, latitude, longitude)
        return self.write(OHHOOperation.dict2json(result))
    def get(self):
        the_request = Get()
        self.set_format(the_request.get_format(self))
        user_id = the_request.get_user_id(self)
        base_url = the_request.get_base_url(self)

        user = User()
        data = user.get_basic_user_information(user_id, base_url)

        result = Result.result_success()
        result["data"] = data
        return self.response(result)
Beispiel #4
0
    def get(self):
        the_get = Get()
        user_id = the_get.get_user_id(self)
        instance = User()
        user = instance.get_by_id(user_id)
        country_code = instance.country_code.get_query()
        user_extension = instance.get_user_extension_by_user(user_id)
        if not user_extension:
            user_extension = instance.init_user_extension(user_id)

        return self.render(MANAGEMENT_USER_DELETE_HTML,
                           user=user,
                           user_extension=user_extension,
                           country_code_list=country_code)
Beispiel #5
0
    def get(self):
        the_get = Get()
        user_id = the_get.get_user_id(self)
        friend_user_id = the_get.get_friend_id(self)
        is_delete = the_get.get_delete(self)
        user = User()
        meet = Meet()
        the_user = user.get_by_id(user_id)
        the_friend = user.get_by_id(friend_user_id)
        if is_delete:
            met_instance = meet.get_met_by_users(user_id, friend_user_id)
            success = meet.met.delete(met_instance)
            if success:
                result = Result.result_success("delete successfully!")
            else:
                result = Result.result_failed("delete failed!")
        else:
            if the_user and the_friend:

                success = meet.add_apply(user_id, friend_user_id)
                if success:
                    apply = meet.get_apply_by_user_and_friend(
                        user_id, friend_user_id)
                    if apply:
                        data = dict()
                        data["apply_id"] = apply.id
                        data["user_id"] = user_id
                        data["another_user_id"] = friend_user_id
                        success = meet.add_met(data)
                        if success:
                            result = Result.result_success("add successfully!")
                        else:
                            result = Result.result_failed("add met failed!")
                    else:
                        result = Result.result_failed("get apply failed!")
                else:
                    result = Result.result_failed("add apply failed!")
            else:
                result = Result.result_failed("user does not exist!")

        self.write(OHHOOperation.dict2json(result))
Beispiel #6
0
    def get(self):
        # name = self.get_body_argument("user_name", None)
        the_get = Get()
        result = dict()
        base_url = the_get.get_base_url(self)
        user_id = the_get.get_user_id(self)
        friend_user_id = the_get.get_friend_id(self)
        user = User()
        friend_user_id2 = user_id if user_id else 4
        user_id = 4
        friend_user_id = friend_user_id if friend_user_id else 13

        log_string = "1234567890"
        OHHOLog.print_log(log_string)
        # message = user.get_user_basic_information(user_id, base_url)
        for i in range(100):
            OHHOLog.print_log(user.push(str(i), friend_user_id, user_id))
            OHHOLog.print_log(user.push(str(i), friend_user_id2, user_id))
        # return Result.result_success()

        self.write(OHHOOperation.dict2json(Result.result_success()))