diff --git a/README.rst b/README.rst index 80523e67b6..38754eaea3 100644 --- a/README.rst +++ b/README.rst @@ -40,7 +40,7 @@ Instead of using the usual ./manage.py use the alias mayan-edms.py: .. code-block:: bash - $ mayan-edms.py syncdb --migrate --noinput + $ mayan-edms.py initialsetup $ mayan-edms.py runserver Point your browser to 127.0.0.1:8000 and use the automatically created admin diff --git a/docs/intro/installation.rst b/docs/intro/installation.rst index 0d228893f8..559e261fac 100644 --- a/docs/intro/installation.rst +++ b/docs/intro/installation.rst @@ -28,7 +28,7 @@ is very easy to start using **Mayan EDMS**. Populate the database with the proje .. code-block:: bash - $ mayan-edms.py syncdb --migrate --noinput + $ mayan-edms.py initialsetup $ mayan-edms.py runserver Point your browser to http://127:0.0.1:8000, if everything was installed diff --git a/mayan/apps/main/management/__init__.py b/mayan/apps/main/management/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mayan/apps/main/management/commands/__init__.py b/mayan/apps/main/management/commands/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mayan/apps/main/management/commands/initialsetup.py b/mayan/apps/main/management/commands/initialsetup.py new file mode 100644 index 0000000000..7724cca55b --- /dev/null +++ b/mayan/apps/main/management/commands/initialsetup.py @@ -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) diff --git a/setup.py b/setup.py index d6ce5ee8ed..07826433a0 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,12 @@ #!/usr/bin/env python import os -import random -import string import sys try: from setuptools import setup except ImportError: from distutils.core import setup - from distutils.command.install import install as _install -else: - from setuptools.command.install import install as _install import mayan @@ -23,22 +18,6 @@ if sys.argv[-1] == 'publish': 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): """ 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 :: Communications :: File Sharing', ], - cmdclass={'install': install}, description='A Django based Document Management System.', include_package_data=True, install_requires=install_requires,