Move intial setup code to a management command called initialsetup, update installation instructions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
0
mayan/apps/main/management/__init__.py
Normal file
0
mayan/apps/main/management/__init__.py
Normal file
0
mayan/apps/main/management/commands/__init__.py
Normal file
0
mayan/apps/main/management/commands/__init__.py
Normal file
24
mayan/apps/main/management/commands/initialsetup.py
Normal file
24
mayan/apps/main/management/commands/initialsetup.py
Normal 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)
|
||||
22
setup.py
22
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,
|
||||
|
||||
Reference in New Issue
Block a user