New initialization command. Creates media/system and populates the SECRET_KEY and VERSION files.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
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
|
||||
|
||||
import mayan
|
||||
from mayan.settings.literals import SECRET_KEY_FILENAME, SYSTEM_DIR
|
||||
|
||||
from ...signals import post_initial_setup, pre_initial_setup
|
||||
|
||||
@@ -8,8 +15,25 @@ from ...signals import post_initial_setup, pre_initial_setup
|
||||
class Command(management.BaseCommand):
|
||||
help = 'Initializes an install and gets it ready to be used.'
|
||||
|
||||
def initialize_system(self):
|
||||
system_path = os.path.join(settings.MEDIA_ROOT, SYSTEM_DIR)
|
||||
secret_key_file_path = os.path.join(system_path, SECRET_KEY_FILENAME)
|
||||
|
||||
if not os.path.exists(system_path):
|
||||
os.makedirs(system_path)
|
||||
|
||||
version_file_path = os.path.join(system_path, 'VERSION')
|
||||
with open(version_file_path, 'w+') as file_object:
|
||||
file_object.write(mayan.__version__)
|
||||
|
||||
with open(secret_key_file_path, 'w+') as file_object:
|
||||
secret_key = get_random_secret_key()
|
||||
file_object.write(secret_key)
|
||||
|
||||
settings.SECRET_KEY = secret_key
|
||||
|
||||
def handle(self, *args, **options):
|
||||
management.call_command('createsettings', interactive=False)
|
||||
self.initialize_system()
|
||||
pre_initial_setup.send(sender=self)
|
||||
management.call_command('installjavascript', interactive=False)
|
||||
management.call_command('createautoadmin', interactive=False)
|
||||
|
||||
Reference in New Issue
Block a user