def edit_web_slide(slide_id):
    channel_id = int(request.args.get('channel_id', 0))
    channels = ChannelService.get_shown_all()
    slide = SlideService.get_one(slide_id)
    if request.method == 'GET':
        return render_template('admin/slide/edit_web.html',
                               slide=slide,
                               channel_id=channel_id,
                               channels=channels)

    slide_dict = request.form.to_dict()
    if not slide_dict['bgcolor']:
        slide_dict['bgcolor'] = "#000000"
    slide_dict['target_id'] = 0
    display_order = slide_dict['display_order'] or 0
    slide_dict['image'] = slide_dict['cover']
    if slide_dict.has_key("covermin"):
        slide_dict['thumbnail'] = slide_dict['covermin']
        del (slide_dict['covermin'])
    slide_dict['display_order'] = display_order
    del (slide_dict['cover'])

    SlideService.edit(slide_id, slide_dict)

    return redirect(
        url_for('admin.list_slides', platform='web', channel_id=channel_id))
def edit_slide(slide_id):
    channels = ChannelService.get_shown_all()
    slide = SlideService.get_one(slide_id)
    if request.method == 'GET':
        return render_template('admin/slide/edit.html',
                               slide=slide,
                               channels=channels)

    slide_dict = request.form.to_dict()
    if slide_dict['type'] == "ad":
        slide_dict['target_id'] = 0
    elif slide_dict['type'] == 'html':
        slide_dict['target_id'] = 0
    else:
        slide_dict['target_id'] = int(slide_dict['target_id'])
    slide_dict['image'] = slide_dict['cover']
    slide_dict['display_order'] = int(slide_dict['display_order'])
    del (slide_dict['cover'])

    SlideService.edit(slide_id, slide_dict)

    return redirect(url_for('admin.list_slides', platform='app'))