Skip to content

Setup Project on MacOS

bartmika edited this page May 12, 2018 · 8 revisions

HOWTO: Setup Over Fifty Five on MacOS for Development

Description

The goal of this article is to provide step-by-step instructions on how to setup workery-django on your MacOS local machine.

Instructions

Prerequisites

You must have the following applications installed before proceeding. If you are missing any one of these then you cannot begin.

  • Python 3.6
  • brew
  • virtualenv
  • redis
  • PostGres

Installation

The following section explains how to setup the application.

  1. Clone a copy of the project somewhere on your machine, we'll be saving to the following locaiton.
mkdir ~/Developer/workery/;
cd ~/Developer/workery/
git clone https://github.com/workery/workery-django;
cd ~/Developer/over55/workery-django
  1. Setup our virtual environment
virtualenv -p python3.6 env
  1. Now lets activate virtual environment
source env/bin/activate
  1. Now lets install the libraries this project depends on.
pip install -r requirements.txt

Database Setup

This project uses the PostGres database and as a result requires setup before running. The following instructions are to be run in your PostGres console:

drop database workery_db;
create database workery_db;
\c workery_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE workery_db to django;
ALTER USER django CREATEDB;
ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;

Environment Variables Setup

  1. Populate the environment variables for our project.
./setup_credentials.sh
  1. Go inside the environment variables.
vi ./workery/workery/.env
  1. Edit the file to suite your needs.

Final Setup

Run the following commands to populate the database.

cd ../workery/workery-django/workery;
python manage.py makemigrations; \
python manage.py migrate_schemas; \
python manage.py init_app; \
python manage.py populate_site; \
python manage.py populate_public; \
python manage.py create_shared_account "bart@email.com" "123password" "Bart" "Mika" "123 123-1234" "" "123 123-1234" "CA" "London" "Ontario" "" "N6H 1B4" "78 Riverside Drive" ""; \
python manage.py create_franchise "london" "Over55" "Over55 (London) Inc." "Located at the Forks of the Thames in downtown London Ontario, Over 55 is a non profit charitable organization that applies business strategies to achieve philanthropic goals. The net profits realized from the services we provide will help fund our client and community programs. When you use our services and recommended products, you are helping to improve the quality of life of older adults and the elderly in our community." "CA" "London" "Ontario" "" "N6H 1B4" "78 Riverside Drive" "";

Host File Setup

This project is uses django-tenants library and is setup to work with multiple domains. As a result, we will need to bind the address workery.ca to your localhost. To do this follow these instructions.

  1. Update your hosts file to support our applications domain.
sudo vi /etc/hosts
  1. Append to the file...
127.0.0.1       workery.ca
127.0.0.1       workery.ca
127.0.0.1       london.workery.ca
127.0.0.1       london.workery.ca
  1. Refresh the dns on your machine to support our new domains.
dscacheutil -flushcache

Usage

To run the web-app, you’ll need to run the server instance and access the page from your browser.

Start up the web-server:

sudo python manage.py runserver workery.ca:80

And inside another seperate Terminal console, please run:

python manage.py rqworker

Finally, in your web-browser, load up the following url:

http://workery.ca/

Congratulations, you are all setup to run the web-app! Have fun coding!#