diff --git a/Pipfile b/Pipfile index ed9c891..db6a8e7 100644 --- a/Pipfile +++ b/Pipfile @@ -17,6 +17,8 @@ flask-migrate = "*" pillow = "*" psycopg2 = "*" flask-login = "*" +wtforms = "*" +email-validator = "*" flask-wtf = "*" flask-assets = "*" # pyscss = "*" diff --git a/manage.sh b/manage.sh old mode 100644 new mode 100755 index 8dafc64..f33f40d --- a/manage.sh +++ b/manage.sh @@ -1,9 +1,10 @@ -#!/bin/bash +#!/bin/sh export FLASK_APP=yadc root="." pipenv="python3 -m pipenv" run="$pipenv run" +editor="nano" prepare_venv() { $pipenv install @@ -14,13 +15,18 @@ prepare_instance() { mkdir -p instance/post/img mkdir -p instance/post/jpeg mkdir -p instance/post/sample + mkdir -p instance/post/thumb_big mkdir -p instance/post/thumb cp yadc/config.def.py instance/config.py } +edit_config() { + $editor instance/config.py +} + prepare_db() { - $run flask upgrade + $run flask db upgrade } gunicorn_run() { @@ -34,13 +40,23 @@ case $1 in "init_instance") prepare_instance ;; + "config") + edit_config + ;; "init_db") prepare_db ;; "init") prepare_venv prepare_instance + + echo "Now please configure database access credentials and preferably other relevant settings." + sleep 4 + edit_config + prepare_db + + echo "Now (if no error occured) you are ready to launch your application using \'$0 run\'" ;; "run") gunicorn_run @@ -51,6 +67,7 @@ case $1 in echo " init - complete init" echo " init_venv" echo " init_instance" + echo " config" echo " init_db" ;; esac \ No newline at end of file diff --git a/yadc/__init__.py b/yadc/__init__.py index df8ad05..f9ddff7 100644 --- a/yadc/__init__.py +++ b/yadc/__init__.py @@ -1,5 +1,4 @@ import os -import shutil from flask import Flask from flask_sqlalchemy import SQLAlchemy @@ -16,19 +15,9 @@ def create_app(): app = Flask(__name__, instance_relative_config=True) app.config.from_mapping(POST_UPLOADS=os.path.join(app.instance_path, 'post'), SQLALCHEMY_TRACK_MODIFICATIONS=False) - # try: - # os.makedirs(app.instance_path) - - # # os.makedirs(app.config.get('POST_UPLOADS')) - # for d in ['img', 'jpeg', 'sample', 'thumb']: - # os.makedirs(os.path.join(app.config.get('POST_UPLOADS'), d)) - - # # shutil.copyfile(os.path.join(app.root_path, 'config.def.py'), os.path.join(app.instance_path, 'config.py')) - # except OSError: - # pass - - ## TO REDO + if not os.path.isfile(os.path.join(app.instance_path, 'config.py')): + raise OSError('Before starting application, please initialize environment using \'manage.sh\' script in the root directory.') app.config.from_pyfile('config.py') app.jinja_env.trim_blocks = True