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

View File

@@ -40,7 +40,7 @@ Instead of using the usual ./manage.py use the alias mayan-edms.py:
.. code-block:: bash .. code-block:: bash
$ mayan-edms.py syncdb --migrate --noinput $ mayan-edms.py initialsetup
$ mayan-edms.py runserver $ mayan-edms.py runserver
Point your browser to 127.0.0.1:8000 and use the automatically created admin Point your browser to 127.0.0.1:8000 and use the automatically created admin

View File

@@ -28,7 +28,7 @@ is very easy to start using **Mayan EDMS**. Populate the database with the proje
.. code-block:: bash .. code-block:: bash
$ mayan-edms.py syncdb --migrate --noinput $ mayan-edms.py initialsetup
$ mayan-edms.py runserver $ mayan-edms.py runserver
Point your browser to http://127:0.0.1:8000, if everything was installed Point your browser to http://127:0.0.1:8000, if everything was installed

View File

View File

@@ -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)

View File

@@ -1,17 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import random
import string
import sys import sys
try: try:
from setuptools import setup from setuptools import setup
except ImportError: except ImportError:
from distutils.core import setup from distutils.core import setup
from distutils.command.install import install as _install
else:
from setuptools.command.install import install as _install
import mayan import mayan
@@ -23,22 +18,6 @@ if sys.argv[-1] == 'publish':
sys.exit() sys.exit()
def post_install(dir):
secret = ''.join([random.SystemRandom().choice((string.digits + string.letters + string.punctuation).replace("'",'')) for i in range(100)])
with open(os.path.join(dir, 'mayan', 'settings', 'local.py'), 'w+') as file_object:
file_object.write('\n'.join([
'from __future__ import absolute_import',
'from .base import *',
"SECRET_KEY = '{}'".format(secret),
]))
class install(_install):
def run(self):
_install.run(self)
self.execute(post_install, (self.install_lib,), msg="Running post install task")
def fullsplit(path, result=None): def fullsplit(path, result=None):
""" """
Split a pathname into components (the opposite of os.path.join) in a Split a pathname into components (the opposite of os.path.join) in a
@@ -129,7 +108,6 @@ setup(
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application', 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
'Topic :: Communications :: File Sharing', 'Topic :: Communications :: File Sharing',
], ],
cmdclass={'install': install},
description='A Django based Document Management System.', description='A Django based Document Management System.',
include_package_data=True, include_package_data=True,
install_requires=install_requires, install_requires=install_requires,