Move intial setup code to a management command called initialsetup, update installation instructions

This commit is contained in:
Roberto Rosario
2014-07-17 00:17:14 -04:00
parent e48edd46c4
commit 7120ffe72d
6 changed files with 26 additions and 24 deletions
@@ -0,0 +1,24 @@
import os
import string
import random
from django.conf import settings
from django.core import management
class Command(management.BaseCommand):
help = 'Gets Mayan EDMS ready to be used (initializes database, creates a secret key, etc).'
def _generate_secret_key(self):
return ''.join([random.SystemRandom().choice((string.digits + string.letters + string.punctuation).replace("'",'')) for i in range(100)])
def handle(self, *args, **options):
with open(os.path.join(settings.BASE_DIR, 'mayan', 'settings', 'local.py'), 'w+') as file_object:
file_object.write('\n'.join([
'from __future__ import absolute_import',
'from .base import *',
'',
"SECRET_KEY = '{0}'".format(self._generate_secret_key()),
'',
]))
management.call_command('syncdb', migrate=True, interactive=False)