예제 #1
0
def login(username, password):
    user = __user_service.login(username, password)
    if user is None:
        return RestResponse(data={},
                            status=httplib.UNAUTHORIZED,
                            messages="Username or Password is incorrect!!",
                            success=False).to_json()
    return RestResponse(user).to_json()
예제 #2
0
def get_user_interest(user_id):
    interest = __user_service.find_user_interests(user_id)
    if interest is not None:
        return RestResponse(interest).to_json()
    else:
        return RestResponse(data={},
                            status=httplib.NOT_FOUND,
                            messages="user is not found!!",
                            success=False).to_json()
예제 #3
0
def remove_user_interest(user_id, interest_id):
    user = __user_service.remove_user_interest(user_id, interest_id)
    if user is not None:
        return RestResponse(user).to_json()
    else:
        return RestResponse(data={},
                            status=httplib.NOT_FOUND,
                            messages="user or interest is not found!!",
                            success=False).to_json()
예제 #4
0
def get_interest(interest_id):
    interest = __interest_service.find_interest(interest_id)
    if interest is not None:
        interest["_id"] = str(interest["_id"])
        return RestResponse(interest).to_json()
    else:
        return RestResponse(data={},
                            status=httplib.NOT_FOUND,
                            messages="user is not found",
                            success=False).to_json()
예제 #5
0
def set_user_interest(user_id, ur_interest):
    ur_interest = ur_interest.split(',')
    user = __user_service.add_user_interest(user_id, ur_interest)
    if user is not None:
        return RestResponse(user).to_json()
    else:
        return RestResponse(data={},
                            status=httplib.NOT_FOUND,
                            messages="user is not found!!",
                            success=False).to_json()
예제 #6
0
def remove_user(user_id):
    status = __user_service.remove_user(user_id)
    if status:
        return RestResponse(data={},
                            status=httplib.OK,
                            messages="user is removed successfully",
                            success=True).to_json()
    else:
        return RestResponse(data={},
                            status=httplib.NOT_FOUND,
                            messages="user is not found",
                            success=False).to_json()
예제 #7
0
def update_user(user):
    try:
        updated_user = __user_service.update_user(user)
        if updated_user is None:
            return RestResponse(data={},
                                status=httplib.NOT_FOUND,
                                messages="user is not exists!!",
                                success=False).to_json()
        return RestResponse(updated_user).to_json()
    except Exception as e:
        logging.error(e)
        return RestResponse(data={},
                            status=httplib.BAD_REQUEST,
                            messages="Enter Invalid Inputs ",
                            success=False).to_json()
예제 #8
0
def register_user(user):
    try:
        user = User.VALIDATOR.validate(user)
        saved_user = __user_service.register(user)
        if saved_user is None:
            return RestResponse(data={},
                                status=httplib.CONFLICT,
                                messages="Username already exists!!",
                                success=False).to_json()
        return RestResponse(saved_user).to_json()
    except Exception as e:
        logging.error(e)
        return RestResponse(data={},
                            status=httplib.BAD_REQUEST,
                            messages="Enter Invalid Inputs ",
                            success=False).to_json()
예제 #9
0
def edit_interest():
    try:
        interest = request.json
        interest = Interest.VALIDATOR.validate(interest)
        updated_interest = __interest_service.update_interest(interest)
        if updated_interest is None:
            return RestResponse(
                data={},
                status=httplib.CONFLICT,
                messages=
                "interest already exists or relative category not exists !!",
                success=False).to_json()
        return RestResponse(updated_interest).to_json()
    except Exception as e:
        logging.error(e)
        return RestResponse(data={},
                            status=httplib.BAD_REQUEST,
                            messages="Enter Invalid Inputs ",
                            success=False).to_json()
예제 #10
0
def category_wise_interest(category_id):
    interests = __interest_service.find_interests_by_category(category_id)
    return RestResponse(interests).to_json()
예제 #11
0
def get_tweets():
    top_tweets = __tweet_service.get_tweets()
    return RestResponse(top_tweets).to_json()
예제 #12
0
def location_trending():
    trending_hashtags = __twitter_service.get_location_trending()
    return RestResponse(trending_hashtags).to_json()
예제 #13
0
def get_trending_group(group_id):
    group_stories = __story_service.get_group_stories(group_id)
    return RestResponse(group_stories).to_json()
예제 #14
0
def get_all_interests():
    all_interest = __interest_service.find_all_interests()
    return RestResponse(all_interest).to_json()
예제 #15
0
def get_article_by_interest_wise(interest_id):
    interest_id = interest_id.split(',')
    articles = __story_service.get_stories(interest_id)
    return RestResponse(articles).to_json()
예제 #16
0
def get_all_users():
    users = __user_service.find_all_users()
    return RestResponse(users).to_json()
예제 #17
0
def get_trending_group():
    all_group = __story_service.pull_group()
    return RestResponse(all_group).to_json()
예제 #18
0
def get_all_categories():
    all_categories = __category_service.find_all_categories()
    return RestResponse(all_categories).to_json()