diff --git a/mayan/apps/common/management/commands/createsettings.py b/mayan/apps/common/management/commands/createsettings.py index b01269c86e..9c84254a6b 100644 --- a/mayan/apps/common/management/commands/createsettings.py +++ b/mayan/apps/common/management/commands/createsettings.py @@ -6,6 +6,10 @@ from django.conf import settings from django.core import management from django.utils.crypto import get_random_string +from ...settings import setting_local_settings_filename + +from .literals import SETTING_FILE_TEMPLATE + class Command(management.BaseCommand): help = 'Creates a local settings file with a random secret key.' @@ -16,16 +20,19 @@ class Command(management.BaseCommand): return get_random_string(50, chars) def handle(self, *args, **options): - path = os.path.join(settings.BASE_DIR, 'settings', 'local.py') + path = os.path.join(settings.BASE_DIR, 'settings', '{}.py'.format(setting_local_settings_filename.value)) if os.path.exists(path): self.stdout.write(self.style.NOTICE('Existing settings file at: {0}. Backup, remove this file, and try again.'.format(path))) else: with open(path, 'w+') as file_object: - file_object.write('\n'.join([ - 'from __future__ import absolute_import', - '', - 'from .base import *', - '', - "SECRET_KEY = '{0}'".format(Command._generate_secret_key()), - '', - ])) + #file_object.write('\n'.join([ + # 'from __future__ import absolute_import', + # '', + # 'from .base import *', + # '', + # "SECRET_KEY = '{0}'".format(Command._generate_secret_key()), + # '', + #])) + file_object.write( + SETTING_FILE_TEMPLATE.format(Command._generate_secret_key()) + ) diff --git a/mayan/apps/common/management/commands/literals.py b/mayan/apps/common/management/commands/literals.py new file mode 100644 index 0000000000..df4de0298b --- /dev/null +++ b/mayan/apps/common/management/commands/literals.py @@ -0,0 +1,10 @@ +from __future__ import unicode_literals + +SETTING_FILE_TEMPLATE = ''' + from __future__ import absolute_import + + from .base import * + + SECRET_KEY = '{0}' + +''' diff --git a/mayan/apps/common/settings.py b/mayan/apps/common/settings.py index 893f3219fe..99c4e121c6 100644 --- a/mayan/apps/common/settings.py +++ b/mayan/apps/common/settings.py @@ -22,6 +22,13 @@ settings_db_sync_task_delay = namespace.add_setting( 'propagate.' ) ) +setting_local_settings_filename = namespace.add_setting( + global_name='COMMON_LOCAL_SETTINGS_FILENAME', + default='local', help_text=_( + 'Filename of the local settings file (just the filename, extension ' + 'will be .py).' + ) +) setting_paginate_by = namespace.add_setting( global_name='COMMON_PAGINATE_BY', default=40,