Generate a new secret key and save it to local.py settings after installation, use this local.py file by default
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mayan.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mayan.settings.local")
|
||||||
|
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
|
|
||||||
|
|||||||
3
mayan/settings/local.py
Normal file
3
mayan/settings/local.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from .base import *
|
||||||
22
setup.py
22
setup.py
@@ -1,12 +1,17 @@
|
|||||||
#!/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
|
||||||
|
|
||||||
@@ -18,6 +23,22 @@ if sys.argv[-1] == 'publish':
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def post_install(dir):
|
||||||
|
secret = ''.join([random.SystemRandom().choice(string.digits + string.letters + string.punctuation) 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
|
||||||
@@ -108,6 +129,7 @@ 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,
|
||||||
|
|||||||
Reference in New Issue
Block a user