Пример #1
0
def delete_database(shortname="", host=""):
	DatabaseContainer.delete([shortname])
	BindContainer.delete([shortname])
	if len(DatabaseContainer.get_databases(host=host)) <= 0:
		DatabaseContainer.UNIQUE_HOSTS.remove(host)
		return True
	update()
	return False
Пример #2
0
def delete_server(host=""):
	databases = DatabaseContainer.get_databases(host=host)
	shortnames = [list(database.keys())[0] for database in databases]
	DatabaseContainer.delete(shortnames)
	BindContainer.delete(shortnames)
	DatabaseContainer.UNIQUE_HOSTS.remove(host)
	update()
	return True
Пример #3
0
def database_view_operations(host, shortname):
    error = False
    c = request.args.get("c")
    act_db_properties = DatabaseContainer.get(shortname)
    form = DatabaseEditForm(request.form)
    if c is not None:
        if COMMANDS[c](host=host, shortname=shortname):
            return redirect(
                url_for("blueprint.server_view_databases", host=host))
        else:
            return redirect('/')
    if request.method == 'POST':
        if form.validate():
            if check_connection(form.data):
                DatabaseContainer.add(form.data)
                DatabaseContainer.delete([shortname])
                BindContainer.delete([shortname])
                BindContainer.add(form.shortname.data)
                update()
                return redirect(
                    url_for("blueprint.database_view_operations",
                            host=host,
                            shortname=form.shortname.data))
            else:
                error = "Unable connect to database."
        else:
            if len(form.shortname.errors) > 0:
                error = "Shortname already exists. Please specify another one."
            if len(form.database.errors) > 0:
                error = "Specifed database already exists."
            else:
                error = "Please provide correct data."
    return make_response(
        render_template('database/operations.html',
                        host=host,
                        form=form,
                        error=error,
                        act_db_properties=act_db_properties), 200)