コード例 #1
0
ファイル: routes.py プロジェクト: FernFerret/servermanager
def view_server(server=None, viewtab=None):
    if viewtab not in ['info', 'settings', 'rcon', 'edit']:
        return redirect(url_for('view_server', server=server, viewtab='info'))
    if not g.user.admin and viewtab in ['rcon', 'edit']:
        return redirect(url_for('view_server', server=server, viewtab='info'))
    server_obj = Server.get(server)
    if request.method == 'POST':
        if viewtab == 'edit':
            server_obj.name = request.form.get('name', server_obj.name)
            server_obj.port = request.form.get('port', server_obj.port)
            server_obj.type = request.form.get('servertype', server_obj.type)
            server_obj.location = request.form.get('path', server_obj.location)
            server_obj.ip = request.form.get('address', server_obj.ip)
            # Only set rcon if they specified it.
            if request.form.get('rcon', None):
                server_obj.rcon = request.form.get('rcon', server_obj.rcon)
            db.session.commit()
            flash("Server edited successfully!", category='success')
            print "In edit!"
        if viewtab == 'settings':
            if request.form['action'] == 'sendmsg' and request.form['saytext']:
                server_obj._send_rcon("sm_csay '%s: %s'" % (session['user_nick'], request.form['saytext']))
                flash("Message sent!", category='success')
            elif request.form['action'] == 'alltalk':
                server_obj = Server.get(server)
                if 'enable' in request.form:
                    flash("Alltalk temporarily Enabled!", category='success')
                    server_obj._send_rcon("sv_alltalk 1")
                else:
                    flash("Alltalk temporarily Disabled!", category='success')
                    server_obj._send_rcon("sv_alltalk 0")
            elif request.form['action'] == 'changemode':
                print server_obj.location
                if 'arena' in request.form:
                    flash("Server set to arena mode, I'll restart it for ya!", category='success')
                    # server_obj._send_rcon("sv_alltalk 1")
                else:
                    flash("Server set to normal mode, I'll restart it for ya!", category='success')
                    # server_obj._send_rcon("sv_alltalk 0")
            elif request.form['action'] == 'changepass':
                if not request.form['srvpass']:
                    server_obj._send_rcon('sv_password ""')
                    flash("Password cleared!", category='success')
                else:
                    server_obj._send_rcon("sv_password "+request.form['srvpass'])
                    flash("Password set!", category='success')
            else:
                flash(request.form, category='success')
    return render_template('view_server.html', server=Server.get(server), servers=Server.get_all(), viewtab=viewtab, lock=app.config.get('LOCKSERVERS', True))
コード例 #2
0
ファイル: routes.py プロジェクト: FernFerret/servermanager
def servers():
    return render_template('servers.html', servers=Server.get_all(), lock=app.config.get('LOCKSERVERS', True))