talkative-tangs / Bangazon-LLC

https://github.com/nashville-software-school/bangazon-llc/blob/js-bag-o-loot/EMPLOYEE_HANDBOOK.md
1 stars 3 forks source link

Bangazon-LLC

This is an API for Bangazon LLC. This API will allow user to GET/POST/PUT and (sometimes) DELETE items from the Bangazon Database. Before you can utilize the database, there are a few things you need to make sure you have installed.

Link to ERD

Bangazon-ERD

Core Technologies

SQLite

Installation of SQLite (if needed)

To get started, type the following command to check if you already have SQLite installed.

$ sqlite3

And you should see:

SQLite version 3.7.15.2 2014-08-15 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

If you do not see above result, then it means you do not have SQLite installed on your machine. Follow the appropriate instructions below.

For Windows

Go to SQLite Download page and download the precompiled binaries for your machine. You will need to download sqlite-shell-win32-*.zip and sqlite-dll-win32-*.zip zipped files.

Create a folder C:\sqlite and unzip the files in this folder which will give you sqlite3.def, sqlite3.dll and sqlite3.exe files.

Add C:\sqlite to your PATH environment variable and finally go to the command prompt and issue sqlite3 command.

For Mac

First, try to install via Homebrew:

brew install sqlite3

If not, download the package from above. After downloading the files, follow these steps:

$tar -xvzf sqlite-autoconf-3071502.tar.gz
$cd sqlite-autoconf-3071502
$./configure --prefix=/usr/local
$make
$make install

For Linux

sudo apt-get update
sudo apt-get install sqlite3

SQL Browser - DB Browser

The DB browser for SQLite will let you view, query and manage your databases during the course.

Visual Studio Code

Visual Studio Code is Microsoft's cross-platform editor that we'll be using during orientation for writing Python and building Django applications. Make sure you add the Python extension immediately after installation completes.

Python

This project uses Python and its web framework Django.

Python Getting Started

Download Python

If you are using a Mac, see the Python for Mac OS X page. MacOS 10.2 (Jaguar), 10.3 (Panther), 10.4 (Tiger) and 10.5 (Leopard) already include various versions of Python.

If you're running Windows: the most stable Windows downloads are available from the Python for Windows page.

Setup Virtual Environment

Enable a virtual environment at the level above your project.

Use the following commands in your terminal:

virtualenv env
source env/bin/activate

Dependencies

Activate your vim and run pip install -r requirements.txt

Django Project / Django App

Django is a Python Web framework. This project uses Django and requires Python to be installed. See above note on installing Python.

Django Install

Django for Windows

Django safedelete

Django safedelete

You can choose what happens when you delete an object :

* it can be masked from your database (soft delete, the default behavior)

* it can be masked from your database and mask any dependent models. (cascading soft delete)

* it can be normally deleted (hard delete)

* it can be hard-deleted, but if its deletion would delete other objects, it will only be masked

* it can be never deleted or masked from your database (no delete, use with caution)

This project uses SOFT_DELETE_CASCADE

example

# imports
from safedelete.models import SafeDeleteModel
from safedelete.models import SOFT_DELETE_CASCADE

# Models

# We create a new model, with the given policy : Objects will be hard-deleted, or soft deleted if other objects would have been deleted too.
class Article(SafeDeleteModel):
    _safedelete_policy = SOFT_DELETE_CASCADE

    name = models.CharField(max_length=100)

class Order(SafeDeleteModel):
    _safedelete_policy = SOFT_DELETE_CASCADE

    name = models.CharField(max_length=100)
    articles = models.ManyToManyField(Article)

Installing Bangazon API

As of now, the database is going to be hosted on your local computer. There are a few things you need to make sure are in place before the database can be up and running.

Fork and clone the repo on to you local machine.

Run makemigrations python manage.py makemigrations Website Run migrate python manage.py migrate

This will create all the migrations needed for Django Framework to post items to the database based on the models in the Models/ directory Create initial SQL data. Nagivate to the Bangazon-LLC directory and run: sqlite3 db.sqlite < data.sql

Run Server

python manage.py runserver 8000 Ctrl+C to quit

Using the API

For now, all calls to the API will be made from http://localhost:8000 as the domain. All calls will be made from here.

Employees

Departments

Computers

Training Programs

This repo created by the Talkative Tangs of Cohort 28:

Bryan Nilsen: Training Programs Module - Team Lead

Lesley Boyd: Computers Module

Ousama Elayan: Departments Module

Elyse Dawson: Employees Module