Skip to content

smegurus/smegurus-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bizmula Django App

Introduction

A cloud-based application used to help entrepreneurs throughout the lifecycle of their businesses.

Minimum Requirements

  • Python 3.4
  • Postgres 9.4
  • pip 8.1
  • virtualenv 15.0.0

Instructions

Setup

  1. Clone the projects.
git clone [email protected]:smegurus/smegurus-django.git
  1. Init the virtual environment.

OS X

python3 -m venv env

Linux / FreeBSD

virtualenv env
  1. Now lets activate virtualenv
source env/bin/activate
  1. Confirm we are using Python3
python --version  # Should return Python 3.4+
  1. OS X USERS ONLY: (a) Check what Postgres.app version you are using. (b) For Postgres we need the following $PATH, so just type it in. If you have a different version installed, please change it the 9.6 version to your current version.
export PATH="/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH"
  1. Install the required Python libraries.

Automatically

Note: Please use this method of installation.

pip install -r requirements.txt

Manually

Note: Use this method if your automatic installation breaks and you need to diagnose the problem. See: requirements.txt

  1. Load up pgsql console.
(OS X)
(Click Applications and click "postgres" icon)

(Linux / FreeBSD)
su pgsql
  1. Once in the pgsql console, write the following commands:

OS X

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

Linux

sudo -i -u postgres
psql

DROP DATABASE smegurus_db;
CREATE DATABASE smegurus_db;
\c smegurus_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE smegurus_db to django;
ALTER USER django CREATEDB;
-- ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;

FreeBSD

su postgres
/usr/local/bin/dropdb smegurus_db;
/usr/local/bin/createdb smegurus_db;

/usr/local/bin/psql smegurus_db;
CREATE USER django WITH PASSWORD '123password';
GRANT ALL PRIVILEGES ON DATABASE smegurus_db to django;
ALTER USER django CREATEDB;
-- ALTER ROLE django SUPERUSER;
CREATE EXTENSION postgis;
  1. Copy our sample .env file to be our new file and open it up:
touch ~/smegurus-django/smegurus/.env
vi ~/smegurus-django/smegurus/.env
  1. While inside the .env file, please fill it to match your configuration.

  2. Setup the database.

python manage.py makemigrations; \
python manage.py migrate; \
python manage.py migrate_schemas; \
python manage.py populate_public; \
python manage.py setup_fixtures; \
python manage.py populate_site;
  1. Setup your root user.
python manage.py createsuperuser;

Celery

MacOS
  1. Install redis.
brew install redis
  1. Afterwords lets get it started.
brew services start redis
  1. Confirm it is working by running the following command waiting to get a PONG response:
redis-cli ping
  1. Congratulations you are now setup.

  2. Addendum - Running this command will force redis to load up everytime your computer starts up.

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
  1. Addendum - Running this command will stop redis from loading up every time your computer starts up.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Setup Domain on OS X

  1. Go to hosts file
sudo vi /etc/hosts
  1. Add the following:
127.0.0.1  smegurus.co
127.0.0.1  www.smegurus.co
  1. Restart the DNS:
dscacheutil -flushcache

Usage

Running Development

Before you run the application, you need to load up celery in a separate console terminal:

celery -A smegurus worker -l info;

If you are developing locally from your machine, use this command.

sudo python manage.py runserver smegurus.co:80;

Notes:

  • When it asks for your password, use your MacOS password.

Running Unit Tests

Run All App Tests

This command will run all the unit tests our application has:

python manage.py test
Run Specific App Tests

If you want to run all the unit tests for a particular app. Run the following:

python manage.py test api.tests
Run Specific Tests within an App

There are cases where an application may have countless unit tests and you want to run a particular set. Run the following:

python manage.py test api.tests.test_authentication

Viewing Web-Application

In your browser, load up: http://smegurus.co.