diff --git a/README.md b/README.md index 2f4fa0c..affbfb6 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,62 @@ Haldis ======= +[![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) +![Website](https://img.shields.io/website/https/haldis.zeus.gent.svg) +![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish) + +![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) +![GitHub issues](https://img.shields.io/github/issues/zeuswpi/haldis.svg) +![GitHub pull requests](https://img.shields.io/github/issues-pr/zeuswpi/haldis.svg) +![GitHub commit activity](https://img.shields.io/github/commit-activity/y/zeuswpi/haldis.svg) Haldis is your friendly neighbourhood servant. He exists so lazy fucks like you and me don't need to keep tabs of who is ordering what from where. Start an order and let people add items with a simple mouse-click! No more calculating prices and making lists! Be lazier today! -Local hosting steps -=================== -0. This is a Python 3 project so make sure to use python 3 and pip3 everywhere -1. Run `pip install -r requirements.txt` -2. `cd app` -3. Copy `config.example.py` to `config.py` -4. Copy the python files from `database/` to `app/` (yes, it's sad, I know) -5. Run `python create_database.py` in `app/` (if you want to fill the DB with sample data be sure to answer `Y` to `Do you still want to add something?`) -6. Run `rm -f add_* create_database.py*` in `app/` -7. Run `python haldis.py runserver` +## Local setup ---- -Or run `./first-setup.sh` in the root of the git folder (in linux) +There is a special script to get started with the project. Just run it in the root of the project. + + ./first-setup.sh + +This will create a virtual environment, install the necessary dependencies and will give you the option to seed the database. + +If you are using a database other then sqlite you will first need to configure the correct uri to the database in the generated 'config.py' file. +Afterwards upgrade the database to the latest version using + + python app/haldis.py db upgrade + +You can now still seed the database by running + + ./populate-db.sh + +in the root folder of the project. + + +Activate the virtual environment using + + source venv/bin/activate + +Finally run the webserver with + + python app/haldis.py runserver + +## Development + +### Changing the database + +1. Update models located in 'app/models.py' +2. Run `python app/haldis.py db migrate` to create a new migration. +3. Apply the changes to the database using `python app/haldis.py db upgrade` + +### Adding dependencies/libraries + +1. Add new dependency to the `requirements.in` file +2. Run `pip-compile` to freeze the dependency into the `requirements.txt` file together with it's own deps +3. Run `pip-sync` to download frozen deps + +### Updating dependencies +Run `pip-compile --upgrade` + +For more information about managing the dependencies see [jazzband/pip-tools: A set of tools to keep your pinned Python dependencies fresh.](https://github.com/jazzband/pip-tools) diff --git a/first-setup.sh b/first-setup.sh index 12c83b0..198eca1 100755 --- a/first-setup.sh +++ b/first-setup.sh @@ -2,15 +2,31 @@ # A simple file to run all instructions from the README ## this should be run in the root of the repository -if [ ! -d "vent" ]; then +bold=$(tput bold) +normal=$(tput sgr0) + +B="\n${bold}" +E="${normal}" + +if [ ! -d "venv" ]; then + echo -e "${B} No venv found, creating a new one ${E}" python -m venv venv fi +source venv/bin/activate -venv/bin/pip install -r requirements.txt + +echo -e "${B} Installing pip-tools ${E}" +pip install pip-tools + +echo -e "${B} Downloading dependencies ${E}" +pip-sync + +echo -e "${B} Copying config template. All custom config options can be set in the config.py file ${E}" cd app cp config.example.py config.py -cp -t . database/* -venv/bin/python create_database.py -rm -f add_* create_database.py -venv/bin/python haldis.py runserver cd .. + +echo -e "${B} Seeding database ${E}" +./populate-db.sh + +echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the server with 'python app/haldis.py runserver' ${E}" diff --git a/populate-db.sh b/populate-db.sh index 599127f..20c635c 100755 --- a/populate-db.sh +++ b/populate-db.sh @@ -2,5 +2,5 @@ cd app cp database/* . -../venv/bin/python create_database.py +python create_database.py rm -f add_* create_database.py muhscheme diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..b41e92c --- /dev/null +++ b/requirements.in @@ -0,0 +1,11 @@ +Flask +Flask-Login +Flask-Bootstrap +Flask-SQLAlchemy +Flask-DebugToolbar +airbrake +Flask-WTF +Flask-OAuthlib +Flask-Admin +Flask-Migrate +Flask-Script diff --git a/requirements.txt b/requirements.txt index 2d4c041..45ae639 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,25 +1,40 @@ -Flask==0.12 -Flask-Admin==1.4.2 -Flask-Bootstrap==3.3.7.1 -Flask-DebugToolbar==0.10.0 -Flask-Login==0.4.0 -Flask-Migrate==2.0.3 -Flask-OAuthlib==0.9.3 -Flask-SQLAlchemy==2.1 -Flask-Script==2.0.5 -Flask-WTF==0.14.2 -Jinja2==2.9.5 -Mako==1.0.6 -MarkupSafe==0.23 -PyMySQL==0.7.9 -SQLAlchemy==1.1.5 -WTForms==2.1 -Werkzeug==0.11.15 -airbrake==1.3.3 -alembic==0.8.10 -blinker==1.4 -itsdangerous==0.24 -oauthlib==2.0.1 -requests==2.13.0 -requests-oauthlib==0.7.0 -six==1.10.0 +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile +# +airbrake==2.1.2 +alembic==1.0.8 # via flask-migrate +blinker==1.4 # via flask-debugtoolbar +certifi==2019.3.9 # via requests +chardet==3.0.4 # via requests +click==7.0 # via flask, pip-tools +dominate==2.3.5 # via flask-bootstrap +flask-admin==1.5.3 +flask-bootstrap==3.3.7.1 +flask-debugtoolbar==0.10.1 +flask-login==0.4.1 +flask-migrate==2.4.0 +flask-oauthlib==0.9.5 +flask-script==2.0.6 +flask-sqlalchemy==2.3.2 +flask-wtf==0.14.2 +flask==1.0.2 +idna==2.8 # via requests +itsdangerous==1.1.0 # via flask, flask-debugtoolbar +jinja2==2.10 # via flask +mako==1.0.8 # via alembic +markupsafe==1.1.1 # via jinja2, mako +oauthlib==2.1.0 # via flask-oauthlib, requests-oauthlib +pip-tools==3.6.0 +python-dateutil==2.8.0 # via alembic +python-editor==1.0.4 # via alembic +requests-oauthlib==1.1.0 # via flask-oauthlib +requests==2.21.0 # via airbrake, requests-oauthlib +six==1.12.0 # via pip-tools, python-dateutil +sqlalchemy==1.3.2 # via alembic, flask-sqlalchemy +urllib3==1.24.1 # via requests +visitor==0.1.3 # via flask-bootstrap +werkzeug==0.15.2 # via flask, flask-debugtoolbar +wtforms==2.2.1 # via flask-admin, flask-wtf