From cc7abbcf32e5b7acc3249070dd6ad9567dd77f35 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 25 Oct 2017 20:28:43 +0300 Subject: [PATCH] Improve readme --- linux_install.md | 57 +++++++++++++++++++++++++++++++++++ readme.md | 74 +++++++++++++--------------------------------- windows_install.md | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 53 deletions(-) create mode 100644 linux_install.md create mode 100644 windows_install.md diff --git a/linux_install.md b/linux_install.md new file mode 100644 index 0000000..b96fce1 --- /dev/null +++ b/linux_install.md @@ -0,0 +1,57 @@ +# Linux/Mac installation instructions + +## Install dependencies + +### Dependency list + +* Python >3.5 +* PostgreSQL >9.5 +* pip3 +* virtualenv +* npm + +Install with apt: +``` +sudo apt install python3 +sudo apt install python3-pip +sudo apt install postgresql +sudo pip3 install virtualenv +sudo apt install npm +``` + +More info about PostgreSQL at: +[https://www.postgresql.org/](https://www.postgresql.org) + +These packages might be needed on certain platforms: + +* python3-dev +* libffi-dev +* python3-cffi +* libssl-dev + +## Create a virtual environment for python + +Create a virtualenv in the parent directory. +``` +virtualenv -p python3 ../virtualenv.sikweb +``` + +## Activate virtualenv + +Assuming we are at the root of this repository and virtualenv is one level above. + +``` +. ../virtualenv.sikweb/bin/activate +``` + +## Run install wizard + +Run the install wizard with + +``` +bash setup.sh +``` + +and follow the instructions. + +## Done! diff --git a/readme.md b/readme.md index fbcdcb6..a7be408 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,11 @@ Data table app for viewing and modifying the member register, member application ### Web app -Mostly static website with an event calendar. +Mostly static website with an event calendar and news feed. + +### Coffee scale + +Shows the current coffee scale status. ## Accessing the source @@ -28,60 +32,24 @@ cd web2.0 git checkout develop ``` -## Install dependencies +## Windows install instructions -### Dependency list +See [Windows install instructions](./windows_install.md) -* Python >3.5 -* PostgreSQL >9.5 -* pip3 -* virtualenv -* npm +## Linux/Mac install instructions -Install with apt: -``` -sudo apt install python3 -sudo apt install python3-pip -sudo apt install postgresql -sudo pip3 install virtualenv -sudo apt install npm -``` +See [Linux/Mac install instructions](./linux_install.md) -More info about PostgreSQL at: -[https://www.postgresql.org/](https://www.postgresql.org) +## Initializing data -These packages might be needed on certain platforms: - -* python3-dev -* libffi-dev -* python3-cffi -* libssl-dev - -## Create a virtual environment for python - -Create a virtualenv in the parent directory. -``` -virtualenv -p python3 ../virtualenv.sikweb -``` - -## Activate virtualenv - -Assuming we are at the root of this repository and virtualenv is one level above. +Run the following `manage.py` commands. Do not run these in production without thinking! ``` -. ../virtualenv.sikweb/bin/activate +python manage.py createdefaultadmin # creates an admin user +python manage.py initialize # creates user groups +python manage.py createdummydata # creates dummy members to the member register ``` -## Run install wizard - -Run the install wizard with - -``` -bash setup.sh -``` - -and follow the instructions. - ## Running ### Use runserver command @@ -90,7 +58,7 @@ and follow the instructions. python manage.py runserver 0.0.0.0:8000 ``` -Using address 0.0.0.0 will bind to all IP addresses. +Using address `0.0.0.0` will bind to all IP addresses. Using `localhost` will only bind to your machine. ### Visit the page @@ -98,14 +66,14 @@ Visit [https://localhost:8000](https://localhost:8000) in your browser! ## Running in production -A good way to run django in production is by using uWSGI. Install uWSGI with: +Run the project in production with gunicorn. Refer to [this page](https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04) for instructions. + +Install production dependencies. ``` pip install -r requirements.production.txt ``` -Create an uWSGI ini file and run the daemon according to online instructions. - ## Development workflow When pulling changes from the server, use `rebase` instead of `merge` for a nice and clean linear history. @@ -136,13 +104,13 @@ Lint python files using `pep8` with pep8 --config=setup.cfg --count . ``` -Lint javascript using `eslint` with +Lint javascript and markdown using `eslint` and `remark` with ``` -eslint . +npm test ``` -Use an editor with linting capabilities to write pretty code that passes linting. Examples include _Atom_ and _Pycharm_. +Use an editor with linting capabilities to write pretty code that passes linting. Examples include _VSCode_, _Atom_ and _Pycharm_. ### Unit tests diff --git a/windows_install.md b/windows_install.md new file mode 100644 index 0000000..3c39452 --- /dev/null +++ b/windows_install.md @@ -0,0 +1,55 @@ +# Windows installation instructions + +## Install dependencies + +### Install python3 + +Visit [The python website](https://www.python.org/downloads/windows/) to install the latest version of python3. + +Make sure to add the python binary directory to PATH. For instructions how to do this, refer to [this Stackoverflow answer](https://superuser.com/questions/143119/how-to-add-python-to-the-windows-path). + +### Install virtualenv with pip + +Run the following command to install `virtualenv`. + +``` +python -m pip install virtualenv +``` + +Setup a virtual python environment. + +``` +python -m virtualenv ../virtualenv.sikweb +``` + +## Activate virtualenv and install requirements + +Activate `virtualenv` (note that this has to be active at all times). + +``` +source ../virtualenv.sikweb/Scripts/activate +``` + +Run the following command to install python packages. + +``` +pip install -r requirements.txt +``` + +## Run migrations + +Run + +``` +python manage.py migrate +``` + +## Install npm for linting javascript + +Follow the instructions on [the npm website](https://www.npmjs.com/package/npm). + +## Set up database + +By default Django uses SQLite, which doesn't need any configuration. If you need PostgreSQL instead, refer to [their website](https://www.postgresql.org/download/windows/). + +## Done!