From 0e7664e059d475a5f5b99002ad199bc002c2c7ea Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Thu, 21 Jan 2021 17:56:28 +0100 Subject: [PATCH] README instructions improved --- README.md | 94 +++++++++++++++++++++++++++++++++++++++- config_example/config.py | 19 ++++++-- main/settings.py | 9 ++-- 3 files changed, 111 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ebd8d7f..529c5c2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,93 @@ -# pygal +# PyGal -Python Galery \ No newline at end of file +Python Galery + +---- +## Installation +---- +### Get the repository +####Go to the subfolder, where you want to create your new PaTT-Application (here ~/tmp) + cd ~/tmp +#### Clone the repository + git clone https://git.mount-mockery.de/application/pygal.git +#### Change to your repository and initialise it completely + cd pygal + git submodule init + git submodule update + + +### Create your virtual environment +#### Create python3 environment + virtualenv -p /usr/bin/python3 venv +#### Activate the environment + source activate +#### Upgrade all outdated packages + pip list -o --format freeze|cut -d '=' -f 1 | xargs pip install $1 --upgrade +#### Install PaTT Requirements + pip install -r requirements.txt + +---- +## Configuration and Initialisation of PyGal +---- +### Create your config File +#### Copy the config example + cp config_example/config.py . + chmod 700 config.py + +#### Set a secret key +Edit config.py and add a SECRET_KEY. Generate the secret e.g by executing the following command: + + python manage.py + +At the End of the error message you'll see a random secret: + +KeyError: "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> **'HERE IS THE RANDOM SECRET ;-)'** <--)." + + +### Create your initial database and first user for PyGal + python manage.py migrate + python manage.py createsuperuser + +### Finalise Configuration +Now there are two ways to finalise your configuration. The first way is for a test or development system. The other is for a production System. + +1. **Test or development System:** Edit + config.py +and set the Variable + DEBUG +to + True. + +2. **Production System:** Edit + config.py +and set the Variable ALLOWED_HOSTS. Execute + "python manage.py collectstatic" to create a folder including all static files. Then add PaTT to your server configuration. See also [Django Documnetation](https://docs.djangoproject.com/en/3.1/howto/deployment/) for further information. + +---- +## Start the Test or development System +---- +### Go to the folder, where your PyGal-Application is locates (here ~/tmp/pygal) + cd ~/tmp/pygal + +###Activate your Virtual Environment + source activate + +###Start the Server + python manage.py runserver + + +[comment]: <> (----) +[comment]: <> (## Backup)) +[comment]: <> (----) +[comment]: <> (### Create Backup files) + + +[comment]: <> (### Restore Backup) + +[comment]: <> ( source venv/bin/activate) + +[comment]: <> (If you are starting without a database, you need to create one) + +[comment]: <> ( python manage.py migrate) + +[comment]: <> (Afterward add data...) \ No newline at end of file diff --git a/config_example/config.py b/config_example/config.py index fb8f272..ce928c4 100644 --- a/config_example/config.py +++ b/config_example/config.py @@ -5,19 +5,30 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # # General settings # + +# SECURITY WARNING: don't run with debug turned on in production! +# DEBUG = False + +# SECURITY WARNING: don't run with a dummy secret in production! # SECRET_KEY = 'define a secret key' + +# SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing! +# ALLOWED_HOSTS = ['127.0.0.1', ] + # # ITEM_ROOT = os.path.join(BASE_DIR, 'data', 'example_data') -# ALLOWED_HOSTS = [] # # Access Right settings # -# SUSPEND_PUBLIC = True # Set this to True to ensure, that unauthenticated users have no permission + +# Set this to True to ensure, that unauthenticated users have no permission +# SUSPEND_PUBLIC = True # # Style settings # + # DEFAULT_THEME = 'clear-red' # THUMBNAIL_SIZES = [137, 175, 250] # WEBNAIL_SIZES = [450, 1100, 1750] @@ -25,7 +36,9 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # # Content settings # -# SORT_BY_DATE = True # Sorting by name if False + +# Sorting by name if False +# SORT_BY_DATE = True # SHOW_IMAGE = True # SHOW_VIDEO = True # SHOW_AUDIO = False diff --git a/main/settings.py b/main/settings.py index 15a3732..665fdcc 100644 --- a/main/settings.py +++ b/main/settings.py @@ -31,9 +31,10 @@ if sys.platform == 'linux' or sys.platform == 'linux2': # Default values, if not defined in config.py # USER_CONFIG_DEFAULTS = { + 'DEBUG': False, 'SECRET_KEY': None, + 'ALLOWED_HOSTS': ['127.0.0.1', ], 'DEFAULT_THEME': 'clear-red', - 'ALLOWED_HOSTS': [], 'ITEM_ROOT': os.path.join(BASE_DIR, 'data', 'example_data'), 'THUMBNAIL_SIZES': [137, 175, 250], 'WEBNAIL_SIZES': [450, 1100, 1750], @@ -63,13 +64,9 @@ for property_name in USER_CONFIG_DEFAULTS: if SECRET_KEY is None: chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' s_key = ''.join([random.choice(chars) for n in range(50)]) - secret_key_warning = "You need to create a config.py file including a variable config which is a dict with at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key) + secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key) raise KeyError(secret_key_warning) -# SECURITY WARNING: don't run with debug turned on in production! -# -DEBUG = False - # Application definition #