示例#1
0
def add_web_slide():
    channel_id = int(request.args.get('channel_id', 0))
    channels = ChannelService.get_shown_all()
    if request.method == 'GET':
        return render_template('admin/slide/add_web.html',
                               channel_id=channel_id,
                               channels=channels)

    platform = request.args.get('platform', 'web')
    slide_dict = request.form.to_dict()

    slide_dict['target_id'] = 0
    if not slide_dict['display_order']:
        slide_dict['display_order'] = 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['platform'] = platform
    del (slide_dict['cover'])

    SlideService.add(slide_dict)

    return redirect(
        url_for('admin.list_slides', platform=platform, channel_id=channel_id))
示例#2
0
def add_slide():
    channels = ChannelService.get_shown_all()
    if request.method == 'GET':
        return render_template('admin/slide/add.html', channels=channels)

    platform = request.args.get('platform', 'app')
    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'])
    if not slide_dict['display_order']:
        slide_dict['display_order'] = 0
    slide_dict['image'] = slide_dict['cover']
    slide_dict['platform'] = platform
    del (slide_dict['cover'])

    SlideService.add(slide_dict)

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