Fixed deployment when amavis is enabled

This commit is contained in:
Antoine Nguyen
2025-09-10 17:22:53 +02:00
parent d0317c021f
commit 8365058b0e
5 changed files with 18 additions and 19 deletions
+2 -6
View File
@@ -61,9 +61,9 @@ copyright = "2025, Antoine Nguyen" # NOQA:A001
# built documents.
#
# The short X.Y version.
version = "2.4.0"
version = "2.5.0"
# The full version, including alpha/beta/rc tags.
release = "2.4.0"
release = "2.5.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -224,7 +224,3 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "modoboa", "Modoboa Documentation", ["Antoine Nguyen"], 1)]
intersphinx_mapping = {
"amavis": ("http://modoboa-amavis.readthedocs.org/en/latest/", None)
}
+3
View File
@@ -218,6 +218,7 @@ class DeployCommand(Command):
allowed_host = "localhost"
extra_settings = []
extensions = parsed_args.extensions
amavis_enabled = False
if extensions:
if "all" in extensions:
extensions = self._get_extension_list()
@@ -233,6 +234,7 @@ class DeployCommand(Command):
exec_cmd(cmd, capture_output=False)
extra_settings = self.find_extra_settings(extensions)
extensions = [extension[1] for extension in extensions]
amavis_enabled = "modoboa.amavis" in extensions
mod = __import__(parsed_args.name, globals(), locals(), [smart_str("settings")])
tpl = self._render_template(
@@ -247,6 +249,7 @@ class DeployCommand(Command):
"devmode": parsed_args.devel,
"extensions": extensions,
"extra_settings": extra_settings,
"amavis_enabled": amavis_enabled,
},
)
with open(f"{path}/settings.py", "w") as fp:
+12 -11
View File
@@ -2,10 +2,10 @@
Django settings for {{ name }} project.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
https://docs.djangoproject.com/en/dev/ref/settings/
"""
from logging.handlers import SysLogHandler
@@ -17,9 +17,6 @@ env = environ.Env()
BASE_DIR = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ secret_key }}'
@@ -157,14 +154,14 @@ WSGI_APPLICATION = '{{ name }}.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
{% for conn in db_connections.values %}{{ conn|safe }}{% endfor %}
}
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
# https://docs.djangoproject.com/en/dev/topics/i18n/
LANGUAGE_CODE = '{{ lang }}'
@@ -177,12 +174,12 @@ USE_L10N = True
USE_TZ = True
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/dev/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
# https://docs.djangoproject.com/en/dev/howto/static-files/
STATIC_URL = '/sitestatic/'
STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic')
@@ -295,7 +292,7 @@ CACHES = {
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -384,7 +381,11 @@ SILENCED_SYSTEM_CHECKS = [
]
PHONENUMBER_DB_FORMAT = 'INTERNATIONAL'
{% if amavis_enabled %}
# Amavis settings
DATABASE_ROUTERS = ["modoboa.amavis.dbrouter.AmavisRouter"]
AMAVIS_DEFAULT_DATABASE_ENCODING = "LATIN1" # or any value matching your database config
{% endif %}
# Load settings from extensions
{% for extension in extra_settings %}
try:
+1 -1
View File
@@ -104,7 +104,7 @@ MODOBOA_APPS = (
"modoboa.contacts",
"modoboa.calendars",
"modoboa.webmail",
"modoboa.amavis",
# "modoboa.amavis",
)
try:
-1
View File
@@ -31,7 +31,6 @@ class DeployTest(unittest.TestCase):
f"--dburl {dburl} --domain localhost --admin-username admin {self.projname}"
)
code, output = exec_cmd(cmd, cwd=self.workdir)
print(output)
self.assertEqual(code, 0)