Esempio n. 1
0
def save_aliases():
    ''' save the current aliases. '''
    try:
        user = user_session.get_user()
    except user_session.NotLoggedIn:
        flash('Sorry, you need to be logged in!')
        return redirect(url_for('index'))
    if not user.is_admin:
        flash('Sorry. You are NOT an admin!')
        return redirect(url_for('index'))

    if request.method == 'POST':
        aliases = form_json('aliases', [])

        try:
            alias_configvar = ConfigVar.get(ConfigVar.id == 'screens.aliases')
        except ConfigVar.DoesNotExist:
            alias_configvar = ConfigVar()
            alias_configvar.id='screens.aliases'
            alias_configvar.save(force_insert=True)

        alias_configvar.value = aliases
        alias_configvar.save()
        return jsonify(aliases=json.loads(alias_configvar.value))

    return jsonify(aliases=config_var('screens.aliases', []))
Esempio n. 2
0
def save_aliases():
    ''' save the current aliases. '''

    if request.method == 'POST':
        aliases = form_json('aliases', [])

        try:
            alias_configvar = ConfigVar.get(ConfigVar.id == 'screens.aliases')
        except ConfigVar.DoesNotExist:
            alias_configvar = ConfigVar() # pylint: disable=no-value-for-parameter
            alias_configvar.id = 'screens.aliases'
            alias_configvar.save(force_insert=True)

        alias_configvar.value = aliases
        alias_configvar.save()
        return jsonify(aliases=json.loads(alias_configvar.value))

    return jsonify(aliases=config_var('screens.aliases', []))
Esempio n. 3
0
def save_aliases():
    ''' save the current aliases. '''

    if request.method == 'POST':
        aliases = form_json('aliases', [])

        try:
            alias_configvar = ConfigVar.get(ConfigVar.id == 'screens.aliases')
        except ConfigVar.DoesNotExist:
            alias_configvar = ConfigVar()  # pylint: disable=no-value-for-parameter
            alias_configvar.id = 'screens.aliases'
            alias_configvar.save(force_insert=True)

        alias_configvar.value = aliases
        alias_configvar.save()
        return jsonify(aliases=json.loads(alias_configvar.value))

    return jsonify(aliases=config_var('screens.aliases', []))