Esempio n. 1
0
def magazines_mid_posts_new(mid):
    json_data = request.get_json()

    user_id = current_user.id
    magazine_id = mid
    post_id = json_data.get('post_id')
    title = json_data.get('title')
    desc = json_data.get('desc')
    cover = json_data.get('cover')
    category = json_data.get('category')
    category_icon = json_data.get('category_icon')

    if not all((magazine_id, post_id, title, cover, category, category_icon)):
        return error('没有提供所有参数')

    magazine_post = MagazinePost.create_magazine_post(
        user_id=user_id,
        magazine_id=magazine_id,
        post_id=post_id,
        title=title,
        desc=desc,
        cover=cover,
        category=category,
        category_icon=category_icon)
    return ok(dump_magazine_post(magazine_post, mode='only_id'))
Esempio n. 2
0
def magazines_mid_posts_id_update(mid, id):
    try:
        magazine_post = MagazinePost.get(MagazinePost.id == id)
    except MagazinePost.DoesNotExist:
        return error('magazine_post does not exist', 404)

    json_data = request.get_json()

    user_id = current_user.id
    magazine_id = mid
    post_id = id

    title = json_data.get('title')
    desc = json_data.get('desc')
    cover = json_data.get('cover')
    category = json_data.get('category')
    category_icon = json_data.get('category_icon')

    if not all(
        (magazine_id, post_id, title, desc, cover, category, category_icon)):
        return error('没有提供所有参数')

    magazine_post.update_magazine_post(user_id=user_id,
                                       magazine_id=magazine_id,
                                       post_id=post_id,
                                       title=title,
                                       desc=desc,
                                       cover=cover,
                                       category=category,
                                       category_icon=category_icon)
    return ok()
Esempio n. 3
0
def magazines_mid_posts_new(mid):
    json_data = request.get_json()

    user_id = current_user.id
    magazine_id = mid
    post_id = json_data.get('post_id')
    title = json_data.get('title')
    desc = json_data.get('desc')
    cover = json_data.get('cover')
    category = json_data.get('category')
    category_icon = json_data.get('category_icon')

    if not all((magazine_id, post_id, title, cover,
               category, category_icon)):
        return error('没有提供所有参数')

    magazine_post = MagazinePost.create_magazine_post(
        user_id=user_id,
        magazine_id=magazine_id,
        post_id=post_id,
        title=title,
        desc=desc,
        cover=cover,
        category=category,
        category_icon=category_icon)
    return ok(dump_magazine_post(magazine_post, mode='only_id'))
Esempio n. 4
0
def magazines_mid_posts_id_update(mid, id):
    try:
        magazine_post = MagazinePost.get(MagazinePost.id == id)
    except MagazinePost.DoesNotExist:
        return error('magazine_post does not exist', 404)

    json_data = request.get_json()

    user_id = current_user.id
    magazine_id = mid
    post_id = id

    title = json_data.get('title')
    desc = json_data.get('desc')
    cover = json_data.get('cover')
    category = json_data.get('category')
    category_icon = json_data.get('category_icon')

    if not all((magazine_id, post_id, title, desc, cover,
               category, category_icon)):
        return error('没有提供所有参数')

    magazine_post.update_magazine_post(
        user_id=user_id,
        magazine_id=magazine_id,
        post_id=post_id,
        title=title,
        desc=desc,
        cover=cover,
        category=category,
        category_icon=category_icon)
    return ok()
Esempio n. 5
0
def magazines_mid_posts_id_delete(mid, id):
    try:
        magazine_post = MagazinePost.get(MagazinePost.id == id)
    except MagazinePost.DoesNotExist:
        return error('magazine_post does not exist', 404)

    magazine_post.delete_instance()
    return ok()
Esempio n. 6
0
def magazines_mid_posts_id_delete(mid, id):
    try:
        magazine_post = MagazinePost.get(MagazinePost.id == id)
    except MagazinePost.DoesNotExist:
        return error('magazine_post does not exist', 404)

    magazine_post.delete_instance()
    return ok()
Esempio n. 7
0
def magazines_mid_posts_id(mid, id):
    try:
        magazine_post = MagazinePost.get(MagazinePost.id == id)
    except MagazinePost.DoesNotExist:
        return error('magazine_post does not exist', 404)
    return ok(dump_magazine_post(magazine_post))
Esempio n. 8
0
def magazines_mid_posts_id(mid, id):
    try:
        magazine_post = MagazinePost.get(MagazinePost.id == id)
    except MagazinePost.DoesNotExist:
        return error('magazine_post does not exist', 404)
    return ok(dump_magazine_post(magazine_post))