The Casting Agency models a company that is responsible for creating movies and managing and assigning actors to those movies. You are an Executive Producer within the company and are creating a system to simplify and streamline your process. The application must:
- Create a movie or actor.
- Read all movies or actors.
- Update a movie or actor.
- Delete a movie or actor.
The above operations must be authorized before being performed. The authorization includes the following 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
The Application is deployed using Render and it is available in the following URL
`https://capstone-fsdn-final.onrender.com`
-
Python >= 3.7 - Follow instructions to install the latest version of python for your platform in the python docs
-
Virtual Environment - We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organized. Instructions for setting up a virual environment for your platform can be found in the python docs
python -m venv venv
source venv/Scripts/activate # for windows
source venv/bin/activate # for linux
- PIP Dependencies - Once your virtual environment is setup and running, install the required dependencies by running:
pip install -r requirements.txt
The environment variables are listed in .\setup.sh
file, you may need to modify accordingly based on your needs
setup.sh
With Postgres running, create a casting
database:
createdb casting
Migration script available in ./migrations
directory
DB upgrade
flask db upgrade
From within the directory first ensure you are working using your created virtual environment.
To run the server, execute:
flask run --reload
The --reload
flag will detect file changes and restart the server automatically.
GET '/api/v1.0/'
- Fetches index page
- Returns - JSON
{
"HelloWorld": "Welcome to FSND capstone project..."
}
GET '/api/v1.0/auth'
- Redirects to AUTH0 page for authentication
- Returns - JSON
{
"auth-url": "https://dev-gz5tjefp2qw5ta7u.us.auth0.com/authorize?audience=casting&response_type=token&client_id=QDgll2Kz5legko3qqcZOQqvpn0ksolEi&redirect_uri=https://capstone-fsdn-final.onrender.com"
}
GET '/api/v1.0/movies'
- Fetches all movies
- Request Arguments: None
- Returns: An object with success flag,
movies
, that contains an array of movie objects
{
"movies": [
{
"release_date": "Sun, 26 Mar 2023 00:00:00 GMT",
"title": "Frozen"
},
{
"release_date": "Tue, 12 Dec 2006 00:00:00 GMT",
"title": "The Number 23"
}
],
"success": true
}
GET '/api/v1.0/actors'
- Fetches all actors
- Request Arguments: None
- Returns: An object with success flag,
actors
, that contains an array of actor objects
{
"actors": [
{
"age": 70,
"gender": "Male",
"name": "stone gold steve austin"
},
{
"age": 2,
"gender": "Female",
"name": "S.Nakshatra"
}
],
"success": true
}
DELETE '/api/v1.0/movies/${id}'
- Deletes a specified movie using the id of the movie
- Request Arguments:
id
- integer - Returns: An object with success flag, deleted movie id
{
"delete": 11,
"success": true
}
DELETE '/api/v1.0/actors/${id}'
- Deletes a specified actor using the id of the actor
- Request Arguments:
id
- integer - Returns: An object with success flag, deleted actor id
{
"delete": 10,
"success": true
}
POST '/api/v1.0/movies'
- Sends a post request in order to create a movie
- Request Body:
{
"title": "Frozen 2",
"release_date": "2022-03-26"
}
- Returns: a success flag and
movies
, that contains an array of new movie object
{
"movies": [
{
"id": 46,
"release_date": "Sun, 26 Mar 2022 00:00:00 GMT",
"title": "Frozen 2"
}
],
"success": true
}
POST '/api/v1.0/actors'
- Sends a post request in order to create a actor
- Request Body:
{
"name": "Dwayne Johnson",
"age": 50,
"gender": "Male"
}
- Returns: a success flag and
actors
, that contains an array of new actor object
{
"actors": [
{
"age": 50,
"gender": "Male",
"id": 22,
"name": "Dwayne Johnson"
}
],
"success": true
}
PATCH '/api/v1.0/movies/${id}'
- Sends a patch request in order to update a movie
- Request Arguments:
id
- integer - Request Body:
{
"title": "The Fall",
"release_date": "2023-03-25"
}
- Returns: a success flag and
movies
, that contains an array of new movie object
{
"movies": [
{
"id": 10,
"release_date": "Sat, 25 Mar 2023 00:00:00 GMT",
"title": "The Fall"
}
],
"success": true
}
PATCH '/api/v1.0/actors/${id}'
- Sends a patch request in order to update an actor
- Request Arguments:
id
- integer - Request Body:
{
"name": "Halle Berry",
"age": 34,
"gender": "Female"
}
- Returns: a success flag and
actors
, that contains an array of new actor object
{
"actors": [
{
"age": 34,
"gender": "Female",
"id": 12,
"name": "Halle Berry"
}
],
"success": true
}
With Postgres running, create a casting_test
database (in case if you want to use separate db):
createdb casting_test
The environment variables are listed in .\test_setup.sh
file, you may need to modify accordingly based on your needs
test_setup.sh
To deploy the tests, run
python test_app.py
or
python -m unittest test_app.py
The Postman test collection is available in the .\POSTMAN_collections
folder. You may need to modify the test case token and id's which you want to delete or patch based on the needs.