Exemplo n.º 1
0
def api_wrapper(*args, **kwargs):
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.post_interactor import PostInteractor
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    post_interactor = PostInteractor(json_presenter, storage)
    response = post_interactor.get_post_reactions_count()
    return response
Exemplo n.º 2
0
def api_wrapper(*args, **kwargs):
    post_id = kwargs['post_id']
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.post_interactor import PostInteractor
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    post_interactor = PostInteractor(json_presenter, storage)
    response = post_interactor.get_post_details(post_id)
    return response
Exemplo n.º 3
0
def api_wrapper(*args, **kwargs):
    post_id = kwargs['post_id']
    offset = kwargs['request_query_params']['offset']
    limit = kwargs['request_query_params']['limit']
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.post_interactor import PostInteractor
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    post_interactor = PostInteractor(json_presenter, storage)
    response = post_interactor.get_post_reactions(post_id, offset, limit)
    return response
Exemplo n.º 4
0
def api_wrapper(*args, **kwargs):
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.post_interactor import PostInteractor
    post_content = kwargs['request_data']['content']
    person = kwargs['user']
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    post_interactor = PostInteractor(json_presenter, storage)
    response = post_interactor.create_post(person.id, post_content)
    import json
    return json.dumps(response)
Exemplo n.º 5
0
def api_wrapper(*args, **kwargs):
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.reaction_interactor import ReactionInteractor
    post_id = kwargs['post_id']
    user = kwargs['user']
    reaction_type = kwargs['request_data']['reaction_type']
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    reaction_interactor = ReactionInteractor(json_presenter, storage)
    response = reaction_interactor.react_to_post(user.id, post_id,
                                                 reaction_type)
    return response
Exemplo n.º 6
0
def api_wrapper(*args, **kwargs):
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.comment_interactor import CommentInteractor

    comment_id = kwargs['comment_id']
    user = kwargs['user'].id
    comment_content = kwargs['request_data']['comment_content']
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    comment_interactor = CommentInteractor(json_presenter, storage)
    response = comment_interactor.add_reply_to_comment(comment_id, user, comment_content)
    return response
Exemplo n.º 7
0
def api_wrapper(*args, **kwargs):
    post_id = kwargs['post_id']

    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.post_interactor import PostInteractor
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    post_interactor = PostInteractor(json_presenter, storage)
    from django_swagger_utils.drf_server.exceptions import BadRequest
    try:
        post_interactor.delete_post(post_id)
        return
    except BadRequest:
        raise BadRequest('Invalid post id', 'INVALID_POST_ID')
Exemplo n.º 8
0
def api_wrapper(*args, **kwargs):
    from fb.presenters.json_presenter import JsonPresenter
    from fb.storages.storage import StorageImplementer
    from fb.interactors.comment_interactor import CommentInteractor
    comment_id = kwargs['comment_id']
    offset = kwargs['request_query_params']['offset']
    limit = kwargs['request_query_params']['limit']
    json_presenter = JsonPresenter()
    storage = StorageImplementer()
    comment_interactor = CommentInteractor(json_presenter, storage)
    try:
        response = comment_interactor.get_comment_replies(
            comment_id, offset, limit)
        return response
    except SuspiciousOperation:
        from django_swagger_utils.drf_server.exceptions import BadRequest
        raise BadRequest('Invalid comment id', 'INVALID_COMMENT_ID')