示例#1
0
文件: views.py 项目: Fy-/FyPress
def comments():
    count_published = SimpleComment.count_filter(SimpleComment.status == 'valid')
    count_spam = SimpleComment.count_filter(SimpleComment.status == 'spam')
    paginator = Paginator(
        query=SimpleComment.filter(SimpleComment.status == (request.args.get('filter') or 'valid')).order_by(SimpleComment.created),
        page=request.args.get('page')
    )
    akismet = Option.get(Option.name == 'akismet')

    if akismet:
        form = AkismetForm(api_key=akismet.value)
    else:
        form = AkismetForm()

    if form.validate_on_submit():
        Option.update('akismet', request.form['api_key'])
        fypress.options = Option.auto_load()
        return redirect(url_for('admin.comments'))

    return render_template('admin/comments.html',
                           count_published=count_published,
                           filter=request.args.get('filter'),
                           count_spam=count_spam,
                           pages=paginator.links,
                           akismet=akismet,
                           form=form,
                           comments=paginator.items,
                           title=gettext('Comments')
                           )
示例#2
0
文件: views.py 项目: vv3g/FyPress
def comments():
    count_published = SimpleComment.count_filter(
        SimpleComment.status == 'valid')
    count_spam = SimpleComment.count_filter(SimpleComment.status == 'spam')
    paginator = Paginator(query=SimpleComment.filter(SimpleComment.status == (
        request.args.get('filter') or 'valid')).order_by(
            SimpleComment.created),
                          page=request.args.get('page'))
    akismet = Option.get(Option.name == 'akismet')

    if akismet:
        form = AkismetForm(api_key=akismet.value)
    else:
        form = AkismetForm()

    if form.validate_on_submit():
        Option.update('akismet', request.form['api_key'])
        fypress.options = Option.auto_load()
        return redirect(url_for('admin.comments'))

    return render_template('admin/comments.html',
                           count_published=count_published,
                           filter=request.args.get('filter'),
                           count_spam=count_spam,
                           pages=paginator.links,
                           akismet=akismet,
                           form=form,
                           comments=paginator.items,
                           title=gettext('Comments'))
示例#3
0
文件: views.py 项目: Duncodes/Paipai
def settings_design():
    options = Option.get_settings('design')
    if request.form:
        for data in request.form:
            Option.update(data, request.form[data])
        from fypress.public.views import reset_options
        reset_options()

        return redirect(url_for('admin.settings_design'))

    return render_template('admin/settings_design.html', design=options, title=gettext('Design - Settings'))
示例#4
0
文件: views.py 项目: Duncodes/Paipai
def settings_social():
    form = SocialSettingsForm(obj=Option.get_settings('social'))

    if form.validate_on_submit():
        for data in form.data:
            Option.update(data, form.data[data])
        from fypress.public.views import reset_options
        reset_options()
        return redirect(url_for('admin.settings_social'))

    return render_template('admin/settings_social.html', form=form, title=gettext('Social - Settings'))
示例#5
0
文件: views.py 项目: Fy-/FyPress
def settings_design():
    options = Option.get_settings('design')

    if request.form:
        for data in request.form:
            Option.update(data, request.form[data])

        fypress.options = Option.auto_load()
        return redirect(url_for('admin.settings_design'))

    return render_template('admin/settings_design.html', design=options, title=gettext('Design - Settings'))
示例#6
0
文件: views.py 项目: Fy-/FyPress
def settings_general():
    form = GeneralSettingsForm(obj=Option.get_settings())

    if form.validate_on_submit():
        for data in form.data:
            Option.update(data, form.data[data])

        fypress.options = Option.auto_load()
        return redirect(url_for('admin.settings_general'))

    return render_template('admin/settings_general.html', form=form, title=gettext('General - Settings'))
示例#7
0
文件: views.py 项目: vv3g/FyPress
def settings_design():
    options = Option.get_settings('design')

    if request.form:
        for data in request.form:
            Option.update(data, request.form[data])

        fypress.options = Option.auto_load()
        return redirect(url_for('admin.settings_design'))

    return render_template('admin/settings_design.html',
                           design=options,
                           title=gettext('Design - Settings'))
示例#8
0
文件: views.py 项目: vv3g/FyPress
def settings_general():
    form = GeneralSettingsForm(obj=Option.get_settings())

    if form.validate_on_submit():
        for data in form.data:
            Option.update(data, form.data[data])

        fypress.options = Option.auto_load()
        return redirect(url_for('admin.settings_general'))

    return render_template('admin/settings_general.html',
                           form=form,
                           title=gettext('General - Settings'))
示例#9
0
文件: views.py 项目: Duncodes/Paipai
def before_request():
    from fypress.user import User
    g.user = None
    if 'user_id' in session:
        g.user = User.query.get(session['user_id'])

    from fypress.admin import Option
    g.options = Option.auto_load()
示例#10
0
文件: views.py 项目: vv3g/FyPress
def before_request():
    g.user = None
    if 'user_id' in session:
        g.user = User.get(User.id == session['user_id'])

    fypress.options = Option.auto_load()
示例#11
0
文件: views.py 项目: vv3g/FyPress
def theme_active():
    Option.update('theme', request.args.get('theme'))
    fypress.options = Option.auto_load()
    return redirect(url_for('admin.themes'))
示例#12
0
文件: views.py 项目: Fy-/FyPress
def before_request():
    g.user = None
    if 'user_id' in session:
        g.user = User.get(User.id == session['user_id'])

    fypress.options = Option.auto_load()
示例#13
0
文件: views.py 项目: Fy-/FyPress
def theme_active():
    Option.update('theme', request.args.get('theme'))
    fypress.options = Option.auto_load()
    return redirect(url_for('admin.themes'))