Skip to content

kataya1/Casting-Agency

Repository files navigation

Casting Agency

The Casting Agency models a company that is responsible for creating movies and managing and assigning actors to those movies

Motivation

the motivation is to help the casting company through easing the procedures to achieve it's goals

hosting (APP URL)

The app is hosted at https://casting-agency1996.herokuapp.com/

Authentication (/authorize)

the base url will have a link for signing up (note: the roles and permission are added by the admin and there is no defaul role to new registers). here is the link for the login/signup page

mock accounts:

use the bearer token (access_token) in the callback url. For API calls for cURL commands check API cURL or import the the postman-collection Casting-Agency.postman_collection.json in postman and update the tokens there

RBAC tokens

are in the postman collection Casting-Agency.postman_collection.json

Getting Started

Installing Dependencies

Python 3.7

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

Virtual Enviornment

We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virual enviornment for your platform can be found in the python docs

PIP Dependencies

Once you have your virtual environment setup and running, install dependencies by naviging to the root directory and running:

$ pip install -r requirements.txt

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

Key Dependencies
  • Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.

  • SQLAlchemy is the Python SQL toolkit and ORM we'll use handle the lightweight sqlite database. You'll primarily work in app.py and can reference models.py.

  • jose The JavaScript Object Signing and Encryption (JOSE) technologies, used to handle JWT decrypton and verification in auth.py

 

Local Development

Auth0

there needs to be an auth0 application and api to handle user data and to assign roles and provide tokens with the following roles and permissions Roles:

  • Casting Assistant
    • Can view actors and movies
  • Casting Director
    • All permissions a Casting Assistant has and Add or delete an actor from the database Modify actors or movies
  • Executive Producer
    • All permissions a Casting Director has and… Add or delete a movie from the database

for more information check out heroku auth0 addon and auth0 Documentation.

or you can use the mock emails in the already configured app

 

Database Setup

With Postgres running, create a database. in terminal run.

$ dropdb <database name>
$ createdb <database name>

run to setup environment variables e.g. DATABASE_URL, you should change the DATABASE_URL with the new database name in setup.sh

$ source setup.sh

and setup the models(tables)

$ python3 manage.py db init
$ python3 manage.py db migrate
$ python3 manage.py db upgrade

 

or

run this for a quick setup after setting up the database (you need the above steps to be able to modify models and migrate for local development)

$ psql <database name>  < capstone.psql 

 

(optional) From the files in the misc folder provided you can make dummy database entries.(the server needs to be running first)

$ source misc/actornames.sh
$ source misc/movienames.sh

Running the server


from withing the root directory first ensure you are working using your created virtual environment. first ensure that the environment variables are setup in setup.sh change it as appropriate. To run the server execute:

$ python3 app.py

Testing

  • Unit-test: The tests is in test_app.py. There is a flag/parameter to the create_app() function create_app(test_config=None) so when unit testing it sets test_config with value 'unittest' i.g. create_app('unittest') and pass it as an argument to i.g. @requires_auth(test_config, permission='get:actors') for a simple if statement in auth.py to test for token validity or not. This way we can respect the unit-test concept and do no proprietary cryptographic algorithm like generating a token in code and such, to test run:
$ python3 test_app.py
  • RBAC(Role Based Acess Control) test: there is a postman collection for API testing in file: Casting-Agency.postman_collection.json you can import it into postman. it's extensive and covers almost every thing

API reference

API documentation is in it's own markdown file here API Documentation


Deployment

you can deploy on heroku for more info heroku deployment


Authors

I


Acknowledgemenet

stackoverflow, the knowledge hub and the FSND slack community

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published