mirror of
https://github.com/YunoHost-Apps/django_example_ynh.git
synced 2024-09-03 18:26:21 +02:00
Merge pull request #9 from YunoHost-Apps/updates
Add DEFAULT_FROM_EMAIL to config panel settings
This commit is contained in:
commit
e722526bd5
8 changed files with 28 additions and 4 deletions
|
@ -35,6 +35,8 @@ PATH_URL = PATH_URL.strip('/')
|
||||||
DEBUG_ENABLED = '__DEBUG_ENABLED__'
|
DEBUG_ENABLED = '__DEBUG_ENABLED__'
|
||||||
LOG_LEVEL = '__LOG_LEVEL__'
|
LOG_LEVEL = '__LOG_LEVEL__'
|
||||||
ADMIN_EMAIL = '__ADMIN_EMAIL__'
|
ADMIN_EMAIL = '__ADMIN_EMAIL__'
|
||||||
|
DEFAULT_FROM_EMAIL = '__DEFAULT_FROM_EMAIL__'
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Use/convert/validate config_panel.toml settings:
|
# Use/convert/validate config_panel.toml settings:
|
||||||
|
|
||||||
|
@ -46,7 +48,12 @@ assert LOG_LEVEL in (
|
||||||
'ERROR',
|
'ERROR',
|
||||||
'CRITICAL',
|
'CRITICAL',
|
||||||
), f'Invalid LOG_LEVEL: {LOG_LEVEL!r}'
|
), f'Invalid LOG_LEVEL: {LOG_LEVEL!r}'
|
||||||
__EmailValidator(message='ADMIN_EMAIL from config panel is not valid!')(ADMIN_EMAIL)
|
__EmailValidator(
|
||||||
|
message='ADMIN_EMAIL %(value)r from config panel is not valid!',
|
||||||
|
)(ADMIN_EMAIL)
|
||||||
|
__EmailValidator(
|
||||||
|
message='DEFAULT_FROM_EMAIL %(value)r from config panel is not valid!',
|
||||||
|
)(DEFAULT_FROM_EMAIL)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -91,7 +98,6 @@ SERVER_EMAIL = 'noreply@__DOMAIN__'
|
||||||
|
|
||||||
# Default email address to use for various automated correspondence from
|
# Default email address to use for various automated correspondence from
|
||||||
# the site managers. Used for registration emails.
|
# the site managers. Used for registration emails.
|
||||||
DEFAULT_FROM_EMAIL = ADMIN_EMAIL
|
|
||||||
|
|
||||||
# List of URLs your site is supposed to serve
|
# List of URLs your site is supposed to serve
|
||||||
ALLOWED_HOSTS = ['__DOMAIN__']
|
ALLOWED_HOSTS = ['__DOMAIN__']
|
||||||
|
|
|
@ -7,11 +7,16 @@ services = ["__APP__"]
|
||||||
[main.config]
|
[main.config]
|
||||||
name = "Configuration Options"
|
name = "Configuration Options"
|
||||||
|
|
||||||
|
[main.config.default_from_email]
|
||||||
|
ask = "from email"
|
||||||
|
type = "string"
|
||||||
|
help = "Default email address to use for various automated emails."
|
||||||
|
bind = "default_from_email:__FINALPATH__/settings.py"
|
||||||
|
|
||||||
[main.config.admin_email]
|
[main.config.admin_email]
|
||||||
ask = "ADMIN email"
|
ask = "ADMIN email"
|
||||||
type = "string"
|
type = "string"
|
||||||
help = "EMail address for error emails."
|
help = "EMail address for error emails."
|
||||||
default = "root@localhost"
|
|
||||||
bind = "admin_email:__FINALPATH__/settings.py"
|
bind = "admin_email:__FINALPATH__/settings.py"
|
||||||
|
|
||||||
[main.config.debug_enabled]
|
[main.config.debug_enabled]
|
||||||
|
|
|
@ -24,6 +24,9 @@ log_level="WARNING"
|
||||||
# 'admin_email' -> '__ADMIN_EMAIL__' add in settings.ADMINS
|
# 'admin_email' -> '__ADMIN_EMAIL__' add in settings.ADMINS
|
||||||
admin_email="${admin}@${domain}"
|
admin_email="${admin}@${domain}"
|
||||||
|
|
||||||
|
# 'default_from_email' -> '__DEFAULT_FROM_EMAIL__' -> settings.DEFAULT_FROM_EMAIL
|
||||||
|
default_from_email="${app}@${domain}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET CONSTANTS
|
# SET CONSTANTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -39,6 +39,7 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
|
||||||
debug_enabled=$(ynh_app_setting_get --app="$app" --key=debug_enabled)
|
debug_enabled=$(ynh_app_setting_get --app="$app" --key=debug_enabled)
|
||||||
log_level=$(ynh_app_setting_get --app="$app" --key=log_level)
|
log_level=$(ynh_app_setting_get --app="$app" --key=log_level)
|
||||||
admin_email=$(ynh_app_setting_get --app="$app" --key=admin_email)
|
admin_email=$(ynh_app_setting_get --app="$app" --key=admin_email)
|
||||||
|
default_from_email=$(ynh_app_setting_get --app="$app" --key=default_from_email)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
|
|
@ -65,6 +65,7 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled"
|
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled"
|
||||||
ynh_app_setting_set --app="$app" --key=log_level --value="$log_level"
|
ynh_app_setting_set --app="$app" --key=log_level --value="$log_level"
|
||||||
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
|
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
|
||||||
|
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
|
|
@ -45,10 +45,16 @@ fi
|
||||||
|
|
||||||
admin_email=$(ynh_app_setting_get --app="$app" --key=admin_email)
|
admin_email=$(ynh_app_setting_get --app="$app" --key=admin_email)
|
||||||
if [ -z "$admin_email" ]; then
|
if [ -z "$admin_email" ]; then
|
||||||
admin_email="root@localhost"
|
admin_email="${admin}@${domain}"
|
||||||
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
|
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
default_from_email=$(ynh_app_setting_get --app="$app" --key=default_from_email)
|
||||||
|
if [ -z "$default_from_email" ]; then
|
||||||
|
default_from_email="${app}@${domain}"
|
||||||
|
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -30,6 +30,7 @@ def pytest_configure():
|
||||||
'__DEBUG_ENABLED__': '0',
|
'__DEBUG_ENABLED__': '0',
|
||||||
'__LOG_LEVEL__': 'INFO',
|
'__LOG_LEVEL__': 'INFO',
|
||||||
'__ADMIN_EMAIL__': 'foo-bar@test.tld',
|
'__ADMIN_EMAIL__': 'foo-bar@test.tld',
|
||||||
|
'__DEFAULT_FROM_EMAIL__': 'django_app@test.tld',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
print('Local test files created here:')
|
print('Local test files created here:')
|
||||||
|
|
|
@ -32,6 +32,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
assert settings.DEBUG_ENABLED == '0' and settings.DEBUG is False
|
assert settings.DEBUG_ENABLED == '0' and settings.DEBUG is False
|
||||||
assert settings.LOG_LEVEL == 'INFO'
|
assert settings.LOG_LEVEL == 'INFO'
|
||||||
assert settings.ADMIN_EMAIL == 'foo-bar@test.tld'
|
assert settings.ADMIN_EMAIL == 'foo-bar@test.tld'
|
||||||
|
assert settings.DEFAULT_FROM_EMAIL == 'django_app@test.tld'
|
||||||
|
|
||||||
def test_urls(self):
|
def test_urls(self):
|
||||||
assert reverse('admin:index') == '/app_path/'
|
assert reverse('admin:index') == '/app_path/'
|
||||||
|
|
Loading…
Reference in a new issue