mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -17,12 +17,12 @@ from modoboa.core.commands import Command
|
||||
DBCONN_TPL = """
|
||||
'{{ conn_name }}': {
|
||||
'ENGINE': '{{ ENGINE }}',
|
||||
'NAME': '{{ NAME }}', # Or path to database file if using sqlite3.
|
||||
'USER': '{% if USER %}{{ USER }}{% endif %}', # Not used with sqlite3.
|
||||
'PASSWORD': '{% if PASSWORD %}{{ PASSWORD }}{% endif %}', # Not used with sqlite3.
|
||||
'HOST': '{% if HOST %}{{ HOST }}{% endif %}', # Set to empty string for localhost. Not used with sqlite3.
|
||||
'PORT': '{% if PORT %}{{ PORT }}{% endif %}', # Set to empty string for default. Not used with sqlite3.{% if ENGINE == 'django.db.backends.mysql' %}
|
||||
'OPTIONS' : {
|
||||
'NAME': '{{ NAME }}',
|
||||
'USER': '{% if USER %}{{ USER }}{% endif %}',
|
||||
'PASSWORD': '{% if PASSWORD %}{{ PASSWORD }}{% endif %}',
|
||||
'HOST': '{% if HOST %}{{ HOST }}{% endif %}',
|
||||
'PORT': '{% if PORT %}{{ PORT }}{% endif %}',
|
||||
{% if ENGINE == 'django.db.backends.mysql' %}'OPTIONS' : {
|
||||
"init_command" : 'SET foreign_key_checks = 0;',
|
||||
},{% endif %}
|
||||
},
|
||||
@@ -61,12 +61,20 @@ class DeployCommand(Command):
|
||||
'--amavis_dburl', type=str, nargs=1, default=None,
|
||||
help='The database-url for your amavis instance')
|
||||
self._parser.add_argument(
|
||||
'--domain', type=str, nargs=1, default=None,
|
||||
'--domain', type=str, default=None,
|
||||
help='The domain under which you want to deploy modoboa')
|
||||
self._parser.add_argument(
|
||||
'--extensions', type=str, nargs='*',
|
||||
help='Deploy with those extensions already enabled'
|
||||
)
|
||||
self._parser.add_argument(
|
||||
'--lang', type=str, default="en-us",
|
||||
help="Set the default language"
|
||||
)
|
||||
self._parser.add_argument(
|
||||
'--timezone', type=str, default="UTC",
|
||||
help="Set the local timezone"
|
||||
)
|
||||
self._parser.add_argument(
|
||||
'--devel', action='store_true', default=False,
|
||||
help='Create a development instance'
|
||||
@@ -137,15 +145,8 @@ class DeployCommand(Command):
|
||||
management.call_command(
|
||||
'startproject', parsed_args.name, verbosity=False
|
||||
)
|
||||
if os.path.exists("%(name)s/%(name)s" % {'name': parsed_args.name}):
|
||||
# Django 1.4+
|
||||
path = "%(name)s/%(name)s" % {'name': parsed_args.name}
|
||||
sys.path.append(parsed_args.name)
|
||||
django14 = True
|
||||
else:
|
||||
path = parsed_args.name
|
||||
sys.path.append(".")
|
||||
django14 = False
|
||||
path = "%(name)s/%(name)s" % {'name': parsed_args.name}
|
||||
sys.path.append(parsed_args.name)
|
||||
|
||||
t = Template(DBCONN_TPL)
|
||||
|
||||
@@ -183,11 +184,13 @@ class DeployCommand(Command):
|
||||
amavis_conn = None
|
||||
|
||||
if parsed_args.domain:
|
||||
allowed_host = parsed_args.domain[0]
|
||||
allowed_host = parsed_args.domain
|
||||
else:
|
||||
allowed_host = raw_input(
|
||||
'What will be the hostname used to access Modoboa? '
|
||||
)
|
||||
if not allowed_host:
|
||||
allowed_host = "localhost"
|
||||
|
||||
bower_components_dir = os.path.realpath(
|
||||
os.path.join(os.path.dirname(__file__), "../../bower_components")
|
||||
@@ -198,8 +201,10 @@ class DeployCommand(Command):
|
||||
"%s/settings.py.tpl" % self._templates_dir, {
|
||||
'default_conn': default_conn, 'amavis_conn': amavis_conn,
|
||||
'secret_key': mod.settings.SECRET_KEY,
|
||||
'name': parsed_args.name, 'django14': django14,
|
||||
'name': parsed_args.name,
|
||||
'allowed_host': allowed_host,
|
||||
'lang': parsed_args.lang,
|
||||
'timezone': parsed_args.timezone,
|
||||
'bower_components_dir': bower_components_dir,
|
||||
'devmode': parsed_args.devel
|
||||
}
|
||||
|
||||
@@ -1,163 +1,51 @@
|
||||
# Django settings for {{ name }} project.
|
||||
"""
|
||||
Django settings for {{ name }} project.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.6/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.6/ref/settings/
|
||||
"""
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
from logging.handlers import SysLogHandler
|
||||
|
||||
from django.conf import global_settings
|
||||
{% if devmode %}
|
||||
from modoboa.core.dev_settings import *
|
||||
{% endif %}
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '{{ secret_key }}'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = {{ devmode }}
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
MODOBOA_DIR = os.path.dirname(__file__)
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@example.com'),
|
||||
)
|
||||
TEMPLATE_DEBUG = {{ devmode }}
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
'{{ allowed_host }}',
|
||||
'{{ allowed_host }}'
|
||||
]
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASES = { {{ default_conn|safe }}
|
||||
# "pfxadmin" : {
|
||||
# "ENGINE" : "django.db.backends.",
|
||||
# "NAME" : "",
|
||||
# "USER" : "",
|
||||
# "PASSWORD" : ""
|
||||
# },{% if not amavis_conn %}
|
||||
# "amavis": {
|
||||
# "ENGINE" : "django.db.backends.",
|
||||
# "HOST" : "",
|
||||
# "NAME" : "",
|
||||
# "USER" : "",
|
||||
# "PASSWORD" : ""
|
||||
# }{% else %}
|
||||
{{ amavis_conn|safe }}{% endif %}
|
||||
}
|
||||
|
||||
DATABASE_ROUTERS = ["modoboa.extensions.amavis.dbrouter.AmavisRouter"]
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# In a Windows environment this must be set to your system time zone.
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
|
||||
# If you set this to False, Django will not format dates, numbers and
|
||||
# calendars according to the current locale.
|
||||
USE_L10N = False
|
||||
|
||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
||||
USE_TZ = True
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/home/media/media.lawrence.com/media/"
|
||||
MEDIA_ROOT = os.path.join(MODOBOA_DIR, 'media')
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Don't put anything in this directory yourself; store your static files
|
||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
||||
# Example: "/home/media/media.lawrence.com/static/"
|
||||
STATIC_ROOT = os.path.join(MODOBOA_DIR, 'sitestatic')
|
||||
|
||||
# URL prefix for static files.
|
||||
# Example: "http://media.lawrence.com/static/"
|
||||
STATIC_URL = '/sitestatic/'
|
||||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (
|
||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
"{{ bower_components_dir }}",
|
||||
)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
)
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = '{{ secret_key }}'
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
# 'django.template.loaders.eggs.Loader',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.static',
|
||||
'django.core.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
|
||||
'modoboa.core.context_processors.top_notifications',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.transaction.TransactionMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
# Uncomment the next line for simple clickjacking protection:
|
||||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
|
||||
'modoboa.lib.middleware.AjaxLoginRedirect',
|
||||
'modoboa.lib.middleware.CommonExceptionCatcher',
|
||||
'modoboa.lib.middleware.ExtControlMiddleware',
|
||||
'modoboa.lib.middleware.RequestCatcherMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = '{{ name }}.urls'
|
||||
|
||||
{% if django14 %}# Python dotted path to the WSGI application used by Django's runserver.
|
||||
WSGI_APPLICATION = '{{ name }}.wsgi.application'{% endif %}
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
)
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.staticfiles',
|
||||
# Uncomment the next line to enable the admin:
|
||||
# 'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
# 'south',
|
||||
'reversion',
|
||||
)
|
||||
@@ -188,42 +76,101 @@ INSTALLED_APPS += MODOBOA_APPS
|
||||
|
||||
AUTH_USER_MODEL = 'core.User'
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'modoboa.lib.middleware.AjaxLoginRedirect',
|
||||
'modoboa.lib.middleware.CommonExceptionCatcher',
|
||||
'modoboa.lib.middleware.ExtControlMiddleware',
|
||||
'modoboa.lib.middleware.RequestCatcherMiddleware',
|
||||
)
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'modoboa.lib.authbackends.SimpleBackend',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'modoboa.core.context_processors.top_notifications',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = '{{ name }}.urls'
|
||||
|
||||
WSGI_APPLICATION = '{{ name }}.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
|
||||
|
||||
DATABASES = { {{ default_conn|safe }}
|
||||
# "pfxadmin" : {
|
||||
# "ENGINE" : "django.db.backends.",
|
||||
# "NAME" : "",
|
||||
# "USER" : "",
|
||||
# "PASSWORD" : ""
|
||||
# },{% if not amavis_conn %}
|
||||
# "amavis": {
|
||||
# "ENGINE" : "django.db.backends.",
|
||||
# "HOST" : "",
|
||||
# "NAME" : "",
|
||||
# "USER" : "",
|
||||
# "PASSWORD" : ""
|
||||
# }{% else %}
|
||||
{{ amavis_conn|safe }}{% endif %}
|
||||
}
|
||||
|
||||
DATABASE_ROUTERS = ["modoboa.extensions.amavis.dbrouter.AmavisRouter"]
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.6/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = '{{ lang }}'
|
||||
|
||||
TIME_ZONE = '{{ timezone }}'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = False
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.6/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic')
|
||||
STATICFILES_DIRS = (
|
||||
'{{ bower_components_dir }}',
|
||||
)
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
# South settings
|
||||
SOUTH_TESTS_MIGRATE = False
|
||||
|
||||
# Modoboa settings
|
||||
#MODOBOA_CUSTOM_LOGO = os.path.join(MEDIA_URL, "custom_logo.png")
|
||||
|
||||
#DOVECOT_LOOKUP_PATH = ('/path/to/dovecot', )
|
||||
|
||||
MODOBOA_API_URL = 'http://api.modoboa.org/1/'
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'modoboa.lib.authbackends.SimpleBackend',
|
||||
)
|
||||
# Logging configuration
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
# performed by this configuration is to send an email to
|
||||
# the site admins on every HTTP 500 error when DEBUG=False.
|
||||
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
||||
# more details on how to customize your logging configuration.
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
{% if django14 %}'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
}
|
||||
},{% endif %}
|
||||
'formatters': {
|
||||
'syslog': {
|
||||
'format': '%(name)s: %(levelname)s %(message)s'
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',{% if django14 %}
|
||||
'filters': ['require_debug_false'],{% endif %}
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
},
|
||||
'syslog-auth': {
|
||||
'class': 'logging.handlers.SysLogHandler',
|
||||
'facility': SysLogHandler.LOG_AUTH,
|
||||
@@ -234,11 +181,6 @@ LOGGING = {
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['mail_admins'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
},
|
||||
'modoboa.auth': {
|
||||
'handlers': ['syslog-auth', 'modoboa'],
|
||||
'level': 'INFO',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.conf.urls import patterns, include, url
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'', include('modoboa.urls')),
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% for l in logs %}
|
||||
<tr>
|
||||
<td>{{ l.date_created }}</td>
|
||||
<td>{{ l.date_created|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
<td>{{ l.level|colorize_level|safe }}</td>
|
||||
<td>{{ l.logger }}</td>
|
||||
<td>{{ l.message|tohtml|safe }}</td>
|
||||
|
||||
Reference in New Issue
Block a user