[![Translation](http://translate.ojuso.org/widgets/platform/-/svg-badge.svg)](http://translate.ojuso.org/engage/platform/?utm_source=widget) [![pipeline status](https://gitlab.com/autonomic-cooperative/ojuso-map/badges/master/pipeline.svg)](https://gitlab.com/autonomic-cooperative/ojuso-map/commits/master) [![coverage report](https://gitlab.com/autonomic-cooperative/ojuso-map/badges/master/coverage.svg)](https://gitlab.com/autonomic-cooperative/ojuso-map/commits/master) # ojuso-map Kickass map for the Ojuso Project # Getting Started ## Check out the code ```bash $ git clone git@gitlab.com:autonomic-cooperative/ojuso-map.git $ cd ojuso-map ``` All commands from here on should be run in the `ojuso-map` directory. ## Install System Dependencies ### Debian / Ubuntu ```bash $ xargs < system-requirements-debian.txt sudo apt-get install -y ``` ### Fedora ```bash $ xargs < system-requirements-fedora.txt sudo dnf install ``` If you hadn't previously installed Postgres, you will need to initialise the database and start the server: ```bash $ sudo postgresql-setup --initdb --unit postgresql $ sudo systemctl start postgresql ``` ## Bootstrap the Virtual Environment Set up your Python virtual environment in the `.venv` folder: ```bash $ python3 -m venv .venv $ source .venv/bin/activate ``` (to leave the virtual environment, the command is simply `deactivate`) ## Configure the Environment ```bash $ export DEBUG=1 $ export DJANGO_SETTINGS_MODULE=ojusomap.settings ``` ## Install the Python Dependencies ```bash $ pip3 install --upgrade pip setuptools $ pip3 install -r requirements-devel.txt ``` If you run into issues with `psycopg2` you may need to run the following: ```bash $ pip3 uninstall psycopg2 && pip3 install --no-binary :all: psycopg2 ``` ## Set up database ### Method 1 You should be able to connect to Postgres: ```bash $ psql -U postgres -h localhost ``` (enter "postgres" as the password) If not, follow [these instructions](https://stackoverflow.com/a/51872624/399367) to change the Postgres authentication options (NB on Fedora / Centos, `pg_hba.conf` is located in `/var/lib/pgsql/data`), then run: ```bash $ echo "ALTER USER postgres WITH PASSWORD 'postgres';" | psql -U postgres ``` ### Method 2 First you need to switch to the user called postgres - in Linux do ```bash $ sudo su postgres ``` Then get an interactive postgres shell ``` $ psql ``` Then create a database and a user, and ensure to make the user a superuser (otherwise you will run into trouble when doing the migration and it tries to enable the postgis extension). ```bash postgres=# create database ojuso; postgres=# create user ojuso WITH PASSWORD 'ojuso'; postgres=# alter role ojuso SET client_encoding TO 'utf8'; // this is recommended for django postgres=# alter role ojuso SET default_transaction_isolation TO 'read committed'; // so is this postgres=# grant all privileges on database ojuso to ojuso; postgres=# alter user ojuso with superuser; ``` Type `\q` to exist the postgres shell. Then, in `ojuso-map/ojusomap/settings.py`, edit the `DATABASES` section to add the database name, user and password, which are all 'ojuso' unless you chose different ones in the previous step. ## Run The Migrations ```bash $ python manage.py migrate ``` ## Start the server ```bash $ python manage.py runserver ``` # Resuming work For each new terminal session, you will need to run: ```bash $ cd ojuso-map $ source .venv/bin/activate $ export DEBUG=1 $ export DJANGO_SETTINGS_MODULE=ojusomap.settings $ python manage.py runserver ``` # Running The Tests ```bash $ pip install -r requirements-test.txt $ pytest -v ```