Пример #1
0
def update():
    request_data = get_json(request)

    code, response = User.update(request_data['user'], request_data['name'], request_data['about'])
    return json.dumps({
        'code': code,
        'response': response
    })
Пример #2
0
def unfollow():
    request_data = get_json(request)

    code, response = User.unfollow(request_data['follower'], request_data['followee'])
    return json.dumps({
        'code': code,
        'response': response
    })
Пример #3
0
def unsubscribe():
    request_data = get_json(request)

    code, response = Thread.unsubscribe(request_data['thread'], request_data['user'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #4
0
def list_threads():
    request_data = get_json(request)

    if "related" not in request_data:
        request_data["related"] = None

    code, response = Thread.list_by_forum(request_data["forum"], request_data, request_data["related"])
    return json.dumps({"code": code, "response": response})
Пример #5
0
def create():
    request_data = get_json(request)

    columns = ', '.join(request_data.keys())
    values = get_values(request_data)

    code, response = User.insert(columns, values, request_data['email'])
    return json.dumps({'code': code, 'response': response})
Пример #6
0
def open_thread():
    request_data = get_json(request)

    code, response = Thread.open(request_data['thread'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #7
0
def remove():
    request_data = get_json(request)

    code, response = Post.remove(request_data['post'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #8
0
def list_following():
    request_data = get_json(request)

    code, response = User.list_following(request_data['user'])
    return json.dumps({
        'code': code,
        'response': response
    })
Пример #9
0
def update():
    request_data = get_json(request)

    code, response = Thread.update(request_data['thread'], request_data['message'], request_data['slug'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #10
0
def list_users():
    request_data = get_json(request)

    code, response = User.list_by_forum(request_data['forum'], request_data)
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #11
0
def details():
    request_data = get_json(request)

    if "related" not in request_data:
        request_data["related"] = None

    code, response = Forum.details(request_data["forum"], request_data["related"])
    return json.dumps({"code": code, "response": response})
Пример #12
0
def list_posts():
    request_data = get_json(request)

    code, response = Post.list_by_user(request_data['user'], request_data)
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #13
0
def update():
    request_data = get_json(request)

    code, response = Post.update(request_data['post'], request_data['message'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #14
0
def vote():
    request_data = get_json(request)

    code, response = Post.vote(request_data['post'], request_data['vote'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #15
0
def remove():
    request_data = get_json(request)

    code, response = Thread.remove(request_data['thread'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #16
0
def details():
    request_data = get_json(request)

    code, response = User.details(request_data['user'])
    return json.dumps({
        'code': code,
        'response': response
    })
Пример #17
0
def create():
    request_data = get_json(request)

    request_data["name"] = request_data["name"].encode("utf-8")

    columns = ", ".join(request_data.keys())
    values = get_values(request_data)

    code, response = Forum.insert(columns, values, request_data["short_name"])
    return json.dumps({"code": code, "response": response})
Пример #18
0
def details():
    request_data = get_json(request)

    if 'related' not in request_data:
        request_data['related'] = None

    code, response = Thread.details(request_data['thread'], request_data['related'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #19
0
def list_threads():
    request_data = get_json(request)

    if 'related' not in request_data:
        request_data['related'] = None

    code, response = Thread.list_by_forum(request_data['forum'], request_data, request_data['related'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #20
0
def create():
    request_data = get_json(request)

    columns = ', '.join(request_data.keys())
    values = get_values(request_data)

    code, response = Post.create(columns, values)
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #21
0
def details():
    request_data = get_json(request)

    if 'related' in request_data:
        code, response = Forum.details(request_data['forum'], request_data['related'])
    else:
        code, response = Forum.details(request_data['forum'])

    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #22
0
def create():
    request_data = get_json(request)

    request_data['title'] = request_data['title'].encode('utf-8')

    columns = ', '.join(request_data.keys())
    values = get_values(request_data)

    code, response = Thread.create(columns, values)
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #23
0
def create():
    request_data = get_json(request)

    request_data['name'] = request_data['name'].encode('utf-8')

    columns = ', '.join(request_data.keys())
    values = get_values(request_data)

    code, response = Forum.create(columns, values, request_data['short_name'])
    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #24
0
def list_posts():
    request_data = get_json(request)

    if 'thread' in request_data:
        code, response = Post.list_by_thread(request_data['thread'], request_data)
    elif 'forum' in request_data:
        code, response = Post.list_by_forum(request_data['forum'], request_data)
    else:
        code, response = Codes.NOT_CORRECT, 'Please enter thread or forum'

    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #25
0
def list_threads():
    request_data = get_json(request)

    if 'user' in request_data:
        code, response = Thread.list_by_user(request_data['user'], request_data)
    elif 'forum' in request_data:
        code, response = Thread.list_by_forum(request_data['forum'], request_data)
    else:
        code, response = Codes.NOT_CORRECT, 'Please enter user or forum'

    return json.dumps(
        {'code': code,
         'response': response}
    )
Пример #26
0
def list_users():
    request_data = get_json(request)

    code, response = User.list_by_forum(request_data["forum"], request_data)
    return json.dumps({"code": code, "response": response})
Пример #27
0
def list_followees():
    request_data = get_json(request)

    code, response = User.list_followees(request_data)
    return json.dumps({'code': code, 'response': response})