Example #1
0
def settings():
    values = {}
    if request.method == 'POST':
        # These 4 cannot be changed in settings
        values['STEAM_API_KEY'] = str(app.config['STEAM_API_KEY'])
        values['SECRET_KEY'] = str(app.config['SECRET_KEY'])
        values['ADDRESS'] = str(app.config['ADDRESS'])
        values['SQLALCHEMY_DATABASE_URI'] = str(app.config['SQLALCHEMY_DATABASE_URI'])
        # The rest of these can
        values['TITLE'] = str(request.form['title'])
        values['DEMO_STORAGE_DIR'] = str(request.form.get('storage', None))
        values['DEBUG'] = request.form.get('debug', None) is not None
        values['TEST'] = request.form.get('test', None) is not None
        values['DEMO_DOWNLOAD_DIR'] = str(request.form.get('download', None))
        values['DEMO_PUBLIC'] = request.form.get('public', None) is not None
        try:
            values['DEMO_PER_PAGE'] = int(request.form.get('perpage', 12))
        except ValueError:
            flash("Warning: Defaulting demos per page to 12 because you didn't put a number in that textbox, idiot.",
                  category='warn')
        #if request.form.get('cleardb', None) is not None and values['DEBUG'] is True:
        #    db.drop_all()
        #    db.create_all()
        write_pyfile(app.config['CFG_FILE'], values)
        # Now set our config values properly
        for key, value in values.iteritems():
            app.config[key] = value
        flash('Success! Your settings were updated.', category='success')
    return render_template('settings.html')
Example #2
0
def settings():
    values = {}
    if request.method == 'POST':
        values['STEAM_API_KEY'] = str(app.config['STEAM_API_KEY'])
        values['SECRET_KEY'] = str(app.config['SECRET_KEY'])
        values['ADDRESS'] = str(app.config['ADDRESS'])
        values['SQLALCHEMY_DATABASE_URI'] = str(app.config['SQLALCHEMY_DATABASE_URI'])
        values['TITLE'] = str(request.form['title'])
        values['LOCKSERVERS'] = request.form.get('lockservers', None) is not None
        values['DEBUG'] = request.form.get('debug', None) is not None
        values['TEST'] = request.form.get('test', None) is not None
        values['ALLOW_LOCAL'] = request.form.get('allowlocal', None) is not None
        write_pyfile(app.config['CFG_FILE'], values)
        # Now set our config values properly
        for key, value in values.iteritems():
            app.config[key] = value
        flash('Success! Your settings were updated.', category='success')
    return render_template('settings.html')