Add COMMON_PROJECT_TITLE as a setting option to customize the title string.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import management
|
||||
from django.core.management.utils import get_random_secret_key
|
||||
|
||||
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.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
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(
|
||||
SETTING_FILE_TEMPLATE.format(get_random_secret_key())
|
||||
)
|
||||
@@ -6,9 +6,11 @@ import tempfile
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import mayan
|
||||
from smart_settings import Namespace
|
||||
|
||||
namespace = Namespace(name='common', label=_('Common'))
|
||||
|
||||
setting_auto_logging = namespace.add_setting(
|
||||
global_name='COMMON_AUTO_LOGGING',
|
||||
default=True,
|
||||
@@ -22,13 +24,6 @@ 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,
|
||||
@@ -45,7 +40,7 @@ setting_shared_storage_arguments = namespace.add_setting(
|
||||
global_name='COMMON_SHARED_STORAGE_ARGUMENTS',
|
||||
default='{{location: {}}}'.format(
|
||||
os.path.join(settings.MEDIA_ROOT, 'shared_files')
|
||||
)
|
||||
), quoted=True
|
||||
)
|
||||
setting_temporary_directory = namespace.add_setting(
|
||||
global_name='COMMON_TEMPORARY_DIRECTORY', default=tempfile.gettempdir(),
|
||||
@@ -70,3 +65,9 @@ setting_production_error_log_path = namespace.add_setting(
|
||||
),
|
||||
is_path=True
|
||||
)
|
||||
setting_project_title = namespace.add_setting(
|
||||
global_name='COMMON_PROJECT_TITLE',
|
||||
default=mayan.__title__, help_text=_(
|
||||
'Name to be displayed in the main menu.'
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from django.core import management
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from ..utils import fs_cleanup
|
||||
from ..management.commands.literals import SETTING_FILE_TEMPLATE
|
||||
|
||||
from .base import BaseTestCase
|
||||
|
||||
|
||||
class CommonCommandsTestCase(BaseTestCase):
|
||||
def test_createsettings_command(self):
|
||||
filename = force_text(uuid.uuid4())
|
||||
with self.settings(COMMON_LOCAL_SETTINGS_FILENAME=filename):
|
||||
management.call_command('createsettings', interactive=False)
|
||||
file_path = os.path.join(
|
||||
settings.BASE_DIR, 'settings', '{}.py'.format(filename)
|
||||
)
|
||||
|
||||
with open(file_path) as file_object:
|
||||
content = file_object.read()
|
||||
|
||||
fs_cleanup(filename=file_path)
|
||||
# Compare without the string substitution and the final linefeeds
|
||||
self.assertTrue(
|
||||
SETTING_FILE_TEMPLATE.replace("{0}'", '')[0:-2] in content
|
||||
)
|
||||
Reference in New Issue
Block a user