This is an app for a casting agency that is responsible for creating movies and managing and assigning actors to those movies. The motivation for the app is to create a system to simplify and streamline the process. This flask-based app features a PostgreSQL database and uses role based access controls on Auth0 for authentication. Casting assistants can view actors and movies, casting directors can add, update, and delete actors as well as update movies, and finally executive producers can add and delete movies.
Set-up a virtual environment and activate it:
python3 -m venv env
source env/bin/activate
You should see (env) before your command prompt now. (You can type deactivate
to exit the virtual environment any time.)
Install the requirements:
pip install -U pip
pip install -r requirements.txt
Set up an Auth0 domain at Auth0.
- Create a single page app
- Set "Allowed Callback URLs", "Allowed Logout URLs", and "Allowed Web Origins" to
http://127.0.0.1:5000
- Create an API
- Check the options "Enable RBAC" and "Add Permissions in the Access Token"
Set up your environment variables:
touch .env
echo AUTH0_DOMAIN="XXX.auth0.com" >> .env
echo AUTH0_CLIENT_ID="XXX" >> .env
echo API_IDENTIFIER="XXX" >> .env
echo DATABASE_URL="postgresql://XXX:5432/movies" >> .env
Initialize and set up the database:
dropdb movies
createdb movies
psql movies < movies.psql
You can run this app either locally or deploy it to Heroku.
Make sure you are in the virtual environment (you should see (env) before your command prompt). If not source /env/bin/activate
to enter it.
Usage: flask run
You will need the Heroku CLI installed. On Ubuntu:
sudo snap install --classic heroku
Then you can setup PostgreSQL and deploy to Heroku.
heroku create fs-casting-agency
heroku addons:create heroku-postgresql:hobby-dev --app fs-casting-agency
heroku pg:push movies DATABASE_URL --app fs-casting-agency
git push heroku master
The API reference documentation is available here.
There is currently an example running on Heroku here. Below are a variety of test users with differing role-based permissions assigned.
email:password
[email protected]:CastingAssistant1
[email protected]:CastingDirector1
[email protected]:ExecutiveProducer1
The API has a testing suite to test all of the API endpoints.
To set up the test database:
dropdb movies_test
createdb movies_test
psql movies_test < movies.psql
Set the test database url and casting assistant, casting director, and executive producer tokens from Auth0 in your environmental variables:
echo TEST_DATABASE_URL="postgresql://XXX:5432/movies_test" >> .env
echo CASTING_ASSISTANT_TOKEN="XXX" >> .env
echo CASTING_DIRECTOR_TOKEN="XXX" >> .env
echo EXECUTIVE_PRODUCER_TOKEN="XXX" >> .env
set -a; source .env; set +a
To run all the tests:
Usage: test_app.py
Udacity's Full Stack Web Developer Nanodegree Program
FS Casting Agency is licensed under the MIT license.