def add_event_news():

    redirect_url = request.args.get('redirect', '')
    event_id = request.args.get('event_id')
    if request.method == 'GET':
        sites = EventNewsService.get_sites()
        return render_template('admin/event/news_add.html',
                               sites=sites,
                               event_id=event_id,
                               url=redirect_url)

    eid = request.form.get('event_id', type=int)
    type = request.form.get('type')
    source = request.form.get('site')
    source_name = request.form.get('site_name')
    title = request.form.get('title')
    image = request.form.get('cover')
    play_url = request.form.get('play_url', '')
    subtitle = request.form.get('subtitle')
    content = request.form.get('content')

    EventNewsService.add(eid, type, source, source_name, title, image,
                         play_url, subtitle, content)

    return redirect(url_for('admin.list_event_news'))
def edit_event_news(news_id):

    redirect_url = request.args.get('redirect', '')

    if request.method == 'GET':
        sites = EventNewsService.get_sites()
        news = EventNewsService.get_one(news_id).to_dict()
        return render_template('admin/event/news_edit.html',
                               sites=sites,
                               news=news)

    eid = request.form.get('event_id', type=int)
    type = request.form.get('type')
    source = request.form.get('site')
    source_name = request.form.get('site_name')
    title = request.form.get('title')
    image = request.form.get('cover')
    play_url = request.form.get('play_url', '')
    subtitle = request.form.get('subtitle')
    content = request.form.get('content')

    EventNewsService.edit(news_id, eid, type, source, source_name, title,
                          image, play_url, subtitle, content)

    if redirect_url == '':
        return redirect(url_for('admin.list_event_news'))
    else:
        return redirect(redirect_url)
Exemple #3
0
def add_event_news():

    redirect_url = request.args.get('redirect', '')
    event_id = request.args.get('event_id')
    if request.method == 'GET':
        sites = EventNewsService.get_sites()
        return render_template(
            'admin/event/news_add.html', sites=sites, event_id=event_id, url=redirect_url)

    try:
        eid = int(request.form.get('event_id'))
        type = request.form.get('type')
        source = request.form.get('site')
        source_name = request.form.get('site_name')
        title = request.form.get('title')
        isvr = request.form.get('isvr', 0, int)
        image = request.form.get('cover')
        play_url = request.form.get('play_url', '')
        play_code = request.form.get('play_code', '')
        play_html = request.form.get('play_html', '')
        subtitle = request.form.get('subtitle')
        content = request.form.get('content')
    except:
        raise InvalidArgument()

    EventNewsService.add(
        eid, type, source, source_name, title, isvr,
        image, play_url, play_code, play_html, subtitle, content)

    return redirect(url_for('admin.list_event_news', event_id=event_id))