예제 #1
0
def magazines_id(id):
    try:
        magazine = Magazine.get(Magazine.id == id)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    return ok(dump_magazine(magazine))
예제 #2
0
def magazines_public(mid):
    try:
        magazine = Magazine.get(Magazine.id == mid)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    return render_template('magazine.html', magazine=dump_magazine(magazine))
예제 #3
0
def magazines_id(id):
    try:
        magazine = Magazine.get(Magazine.id == id)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    return ok(dump_magazine(magazine))
예제 #4
0
def magazines_public(mid):
    try:
        magazine = Magazine.get(Magazine.id == mid)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    return render_template('magazine.html', magazine=dump_magazine(magazine))
예제 #5
0
def magazines_new():
    json_data = request.get_json()

    title = json_data.get('title')

    if not all((title, )):
        return error('没有提供所有参数')

    magazine = Magazine.create_magazine(title=title)
    return ok(dump_magazine(magazine, mode='only_id'))
예제 #6
0
def magazines_id_delete(id):
    try:
        magazine = Magazine.get(Magazine.id == id)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    if magazine.posts.count():
        return error('杂志中有文章,确定删除请先删除杂志中的内容')

    magazine.delete_instance()
    return ok()
예제 #7
0
def magazines_id_delete(id):
    try:
        magazine = Magazine.get(Magazine.id == id)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    if magazine.posts.count():
        return error('杂志中有文章,确定删除请先删除杂志中的内容')

    magazine.delete_instance()
    return ok()
예제 #8
0
def magazines_new():
    json_data = request.get_json()

    title = json_data.get('title')

    if not all((title,)):
        return error('没有提供所有参数')

    magazine = Magazine.create_magazine(
        title=title)
    return ok(dump_magazine(magazine, mode='only_id'))
예제 #9
0
def magazines_id_update(id):
    try:
        magazine = Magazine.get(Magazine.id == id)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    json_data = request.get_json()

    title = json_data.get('title')

    if not all((title, )):
        return error('没有提供所有参数')

    magazine.update_magazine(title=title)
    return ok()
예제 #10
0
def magazines_id_update(id):
    try:
        magazine = Magazine.get(Magazine.id == id)
    except Magazine.DoesNotExist:
        return error('magazine does not exist', 404)

    json_data = request.get_json()

    title = json_data.get('title')

    if not all((title,)):
        return error('没有提供所有参数')

    magazine.update_magazine(title=title)
    return ok()
예제 #11
0
def dump_magazine_all():
    magazines_data = []
    magazines = Magazine.all()
    for magazine in magazines:
        magazines_data.append(dump_magazine(magazine))
    return magazines_data