Beispiel #1
0
def relate_collections_videos(collection_id, video_id):
    video = OGVideoService.get_one(video_id)
    if not video:
        return jsonify_with_error((10001, u"该视频不存在!"))

    item = CollectionVideoService.get_filter_one(collection_id, video_id)
    if item:
        return jsonify_with_error((10001, u"该视频已关联到该合集!"))

    CollectionVideoService.add(collection_id, video_id)
    return jsonify_with_data((200, 'OK'))
def edit_section_post(section_id, post_id):

    post = SectionPostService.get_one(post_id)
    if request.method == 'GET':
        sites = SiteService.get_all()
        return render_template('admin/section/edit_post.html',
                               sites=sites,
                               section_id=section_id,
                               post=post)

    title = request.form.get('title')
    site = request.form.get('site')
    origin = request.form.get('origin')
    content = request.form.get('content')
    image = request.form.get('true_image', '')

    try:
        publish_tm = request.form.get('publish_tm', '')
        string_to_datetime(publish_tm)
    except:
        return jsonify_with_error(APIError.BAD_FORMAT)

    SectionPostService.edit(post_id, title, site, origin, content, image,
                            publish_tm)

    return redirect(url_for('admin.list_section_posts', section_id=section_id))
Beispiel #3
0
def edit_program_post(program_id, post_id):

    post = ProgramPostService.get_one(post_id)
    if request.method == 'GET':
        sites = SiteService.get_all()
        return render_template('admin/program/edit_post.html',
                               sites=sites,
                               program_id=program_id,
                               post=post)
    title = request.form.get('title')
    isvr = request.form.get('isvr', 0, int)
    site = request.form.get('site', '')
    origin = request.form.get('origin', '')
    brief = request.form.get('brief', '')
    image = request.form.get('true_image', '')
    play_url = request.form.get('play_url')
    play_html = request.form.get('play_html')
    play_code = request.form.get('play_code')

    try:
        publish_tm = request.form.get('publish_tm', '')
        string_to_datetime(publish_tm)
    except:
        return jsonify_with_error(APIError.BAD_FORMAT)

    ProgramPostService.edit(post_id, title, isvr, site, origin, brief, image,
                            play_url, play_html, play_code, publish_tm)

    return redirect(url_for('admin.list_program_posts', program_id=program_id))
Beispiel #4
0
def delete_post(post_id):
    post = PostService.get_one(post_id)
    if not post:
        return jsonify_with_error(APIError.NOT_FOUND)

    PostService.delete_post(post_id)

    return jsonify_with_data(APIError.OK)
Beispiel #5
0
def delete_post(post_id):
    post = PostService.get_one(post_id)
    if not post:
        return jsonify_with_error(APIError.NOT_FOUND)

    PostService.delete_post(post_id)

    return jsonify_with_data(APIError.OK)
def all_error(e):
    current_app.logger.error("Error on %s", request.path, exc_info=True)
    return jsonify_with_error(APIError.SERVER_ERROR)
def not_found(e):
    return jsonify_with_error(APIError.NOT_FOUND)
def invalid_argument(e):
    return jsonify_with_error(APIError.BAD_REQUEST)
Beispiel #9
0
def get_post(post_id):
    post = PostService.get_one(post_id)
    if post is None:
        return jsonify_with_error(APIError.NOT_FOUNT)
    return jsonify_with_data(APIError.OK, post=post)
Beispiel #10
0
def get_post(post_id):
    post = PostService.get_one(post_id)
    if post is None:
        return jsonify_with_error(APIError.NOT_FOUNT)
    return jsonify_with_data(APIError.OK, post=post)