Example #1
0
File: views.py Project: a740122/pcp
def rm(request, dbtype):
    try:
        object_id = request.POST['object_id']
        u = request.session.get('switched_user', request.user)

        if dbtype == 'mysql':
            m = u.mysqldb_set.get(pk=object_id)
            mr = MySQLRequest(u, u.parms.mysql_machine)
        elif dbtype == 'pgsql':
            m = u.pgsql_set.get(pk=object_id)
            mr = PostgreSQLRequest(u, u.parms.pgsql_machine)
        else:
            raise Exception(ugettext('Unknown database type'))

        mr.remove_db(m.dbname)
        m.delete()

        return JsonResponse("OK", {1: ugettext("Database was successfuly deleted")})
    except Exception, e:
        return JsonResponse("KO", {1: ugettext("Error during delete database")})
Example #2
0
def rm(request, dbtype):
    try:
        object_id = request.POST['object_id']
        u = request.session.get('switched_user', request.user)

        if dbtype == 'mysql':
            m = u.mysqldb_set.get(pk=object_id)
            mr = MySQLRequest(u, u.parms.mysql_machine)
        elif dbtype == 'pgsql':
            m = u.pgsql_set.get(pk=object_id)
            mr = PostgreSQLRequest(u, u.parms.pgsql_machine)
        else:
            raise Exception(ugettext('Unknown database type'))

        mr.remove_db(m.dbname)
        m.delete()

        return JsonResponse("OK",
                            {1: ugettext("Database was successfuly deleted")})
    except Exception, e:
        return JsonResponse("KO",
                            {1: ugettext("Error during delete database")})