Skip to content

Fabio-Ottaviani-Dev/itemCMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Item CMS

Overview

Item CMS is a basic RESTful APIs framework design to manage items, the not typed structure is designed to be suitable for a wide range of products / items.

Tech Stack (Key Dependencies)

The tech stack will include:

Installing Dependencies

Python 3.8

Follow instructions to install the latest version of python for your platform in the python docs

Virtual Environment

Instructions for setting up a virtual environment for your platform can be found in the python docs

Venv on Ubuntu 18.04 LTS

# https://linuxize.com/post/how-to-create-python-virtual-environments-on-ubuntu-18-04/
sudo apt install python3-venv
# Within the directory
python3 -m venv env
source env/bin/activate

Database Setup

With Postgres running, in terminal run:

# On Ubuntu 18.04
sudo -u postgres psql
create user billy password 'billy123';
create database itemcms owner billy;

PIP Dependencies

With your virtual environment setup and running, install dependencies by running:

# with active virtual environment
pip3 install -r requirements.txt

This will install all of the required packages we selected within the requirements.txt file.

Running the server

# -----------------------------------------------------------------------------
# gunicorn
# -----------------------------------------------------------------------------

# Heroku
web: gunicorn --bind 127.0.0.1:5000 --pythonpath backend/src wsgi:app


# Local
# NOTE change "billy" with your postgresql user
cd <mainDir>
source env/bin/activate
export DATABASE_URL="postgresql://billy:billy123@127.0.0.1:5432/itemcms" &&
export DEBUG=True &&
gunicorn --bind 127.0.0.1:5000 --pythonpath backend/src wsgi:app --reload --log-level debug

# -----------------------------------------------------------------------------

db drop and create all

Got to: http://127.0.0.1:5000/reset-db

Test with Unit Test

cd <mainDir>
source env/bin/activate

# run the tests
export DATABASE_URL="postgresql://billy:billy123@127.0.0.1:5432/itemcms" && export DEBUG=True && python backend/src/test_api.py

Authentication

The authentication, related profiles, privileges and roles are implemented with Auth0

Profile roles and privileges

Actor Role CURD Privileges
Admin Administrator (Login required) All privileges
User User (Login required) See the schema below
Public Public (NO login required) See the schema below

Public CURD privileges

Tables Create Read Update Delete
items False True False False
categories False True False False

User CURD privileges

Tables Create Read Update Delete
items False True True False
categories False True True False

Test Auth0 role / endpoint

Get the token

Login Page

------------------------------------------
Admin:
------------------------------------------
email: -----> admin@itemcms.herokuapp.com
password: --> PoloCottoBene123
------------------------------------------
User
------------------------------------------
email: -----> user@itemcms.herokuapp.com
password: --> PolloCottoMale123
------------------------------------------

NOTE: Look on the address bar and grab your access token from the url

Check the token

  1. jwt.io Admin token debug
  2. jwt.io User token debug

Check the endpoint

Endpoints

Endpoint Method Requires Auth
/categories POST create:category
/categories GET None
/categories/id PATCH update:category
/categories/id DELETE delete:category
/items POST create:item
/items GET None
/items/id PATCH update:item
/items/id DELETE delete:item

About

Item CMS is a basic RESTful APIs framework design to manage items

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published