mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
+10
-3
@@ -1,7 +1,10 @@
|
||||
# coding: utf-8
|
||||
from django.db import connection
|
||||
from django.conf import settings
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from modoboa.lib.exceptions import InternalError
|
||||
|
||||
|
||||
def db_table_exists(table, cursor=None):
|
||||
"""Check if table exists
|
||||
|
||||
@@ -20,14 +23,18 @@ def db_table_exists(table, cursor=None):
|
||||
else:
|
||||
return table in table_names
|
||||
|
||||
def db_type(connection="default"):
|
||||
|
||||
def db_type(cname="default"):
|
||||
"""Return the type of the *default* database
|
||||
|
||||
Supported values : 'postgres', 'mysql', 'sqlite'
|
||||
|
||||
:param str cname: connection name
|
||||
:return: a string or None
|
||||
"""
|
||||
if not cname in settings.DATABASES:
|
||||
raise InternalError(_("Connection to database %s not configured" % cname))
|
||||
for t in ['postgres', 'mysql', 'sqlite']:
|
||||
if settings.DATABASES[connection]['ENGINE'].find(t) != -1:
|
||||
if settings.DATABASES[cname]['ENGINE'].find(t) != -1:
|
||||
return t
|
||||
return None
|
||||
|
||||
@@ -8,7 +8,7 @@ import re
|
||||
import json
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render_to_response
|
||||
from django.shortcuts import render, render_to_response
|
||||
from django.template.loader import render_to_string
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
@@ -27,9 +27,8 @@ def _render_to_string(request, tpl, user_context):
|
||||
def _render_error(request, errortpl="error", user_context=None):
|
||||
if user_context is None:
|
||||
user_context = {}
|
||||
return render_to_response(
|
||||
"common/%s.html" % errortpl, user_context,
|
||||
context_instance=template.RequestContext(request)
|
||||
return render(
|
||||
request, "common/%s.html" % errortpl, user_context
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "nlayout.html" %}
|
||||
{% extends "layout_simple.html" %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<div class="alert alert-error"><strong>{% trans "Error:" %}</strong> {{ error }}</div>
|
||||
|
||||
Reference in New Issue
Block a user