示例#1
0
def admin_meta_blueprint():
    if only_admin() != None:
        return only_admin()

    bioform = BioForm(csrf_enabled=False)
    msg = ''

    if bioform.validate_on_submit():
        if get_option('bio') != None:
            get_option('bio').value = bioform.bio.data
        else:
            create_option('bio', bioform.bio.data)

        if get_option('bio_heading') != None:
            get_option('bio_heading').value = bioform.heading.data
        else:
            create_option('bio_heading', bioform.heading.data)

        sess.commit()
    else:
        if get_option('bio_heading') != None:
            bioform.heading.data = get_option('bio_heading').value

        if get_option('bio') != None:
            bioform.bio.data = get_option('bio').value

    return render_template('admin_meta.html', bioform=bioform, msg=msg)
示例#2
0
def admin_options_blueprint(page=0):
    if only_admin() != None:
        return only_admin()

    optionsform = OptionsForm(csrf_enabled=False)
    options = get_options(offset=int(page)*10, limit=10)

    delete = request.form.get('delete')

    msg = ''

    if delete != None:
        delete_option(request.form.get('selected_option'))

    if optionsform.validate_on_submit():
        if optionsform.key.data != None and optionsform.value.data != None and delete == None:
            create_option(key=optionsform.key.data, value=optionsform.value.data)
            msg = 'Option was created!'

    return render_template('admin_options.html', options=options, page=page, optionsform=optionsform, msg=msg)