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.
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
Follow instructions to install the latest version of python for your platform in the python docs
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
Once you have your virtual environment setup and running, install dependencies by running:
pip install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt
file.
- Flask is a lightweight backend microservices framework.
- SQLAlchemy is the Python SQL toolkit and ORM.
- DOT-ENV extension handling reading .env variables.
- View application hosted on heroku.
https://arty-agency.herokuapp.com
. - To test endpoints you could use Postman with the collection agency.postman_collection.json
- To test api using live documentation click here
- Create a database and complete the database URL in .env.
- Apply db migrations using the command.
python manage.py db upgrade
.
Create a .env file in following the example (.env_example). Ensure to put database url for the app to use and for testing.
Ensure you are working using your created virtual environment.
To run the server, execute:
python manage.py runserver
- To test endpoints you can use Postman.
- Alteratively you can use the live documentation.
https://documenter.getpostman.com/view/2022116/SzKYNbdD
. - Click here to view login page.
Casting assistant credentials.
email: assistant@example.com
password: asG8Bwqg!#
Casting director credentials.
email: director@example.com
password: gaKGS234Gal!@
Executive producer
email: producer@example.com
password: stGS12gzLoi74@$E
- Fetchs a list of actors from the database.
- Request Arguments: None
- Required permission:
get:actors
.
Example of expected output.
{
"actors": [
{
"age": 20,
"gender": "Female",
"id": 1,
"movies_in": [
{
"id": 1,
"title": "Tebatusasula"
}
],
"name": "Julie Ivans"
},
{
"age": 25,
"gender": "Male",
"id": 2,
"movies_in": [
{
"id": 1,
"title": "Tebatusasula"
}
],
"name": "Matthew Bam"
}
],
"success": true
}
- Creates a new actor and returns the id of the new actor.
- Required fields: name, age, gender.
- Required permission:
create:actors
.
Example of json data to post.
{
"name": "John Doe",
"age": 35,
"gender": "Male"
}
Example of output.
``` json
{
"actors": [
{
"age": 20,
"gender": "Female",
"id": 1,
"movies_in": [
{
"id": 1,
"title": "Tebatusasula"
}
],
"name": "Julie Ivans"
},
{
"age": 25,
"gender": "Male",
"id": 2,
"movies_in": [
{
"id": 1,
"title": "Tebatusasula"
}
],
"name": "Matthew Bam"
},
{
"age": 25,
"gender": "Male",
"id": 5,
"movies_in": [],
"name": "John Doe"
}
],
"created": 5,
"success": true,
"total_actors": 3
}
- Deletes an actor from the database whose id has been specified.
- Example request. http://127.0.0.1:5000/actors/5
- HTTP method: Delete
- Required permission:
delete:actors
.
Example of output.
{
"actor_list": [
{
"age": 20,
"gender": "Female",
"id": 1,
"movies_in": [
{
"id": 1,
"title": "Tebatusasula"
}
],
"name": "Julie Ivans"
},
{
"age": 25,
"gender": "Male",
"id": 2,
"movies_in": [
{
"id": 1,
"title": "Tebatusasula"
}
],
"name": "Matthew Bam"
}
],
"deleted": 5,
"success": true
}
- Fetches a list of movies. Each formated as a dictionary.
- Required permission:
get:movies
.
Example of output.
{
"movies": [
{
"cast": [
{
"id": 2,
"name": "Matthew Bam"
},
{
"id": 1,
"name": "Julie Ivans"
}
],
"id": 1,
"release_date": "Mon, 19 Oct 2020 00:00:00 GMT",
"title": "Tebatusasula"
},
{
"cast": [],
"id": 2,
"release_date": "Sun, 19 Jan 2020 00:00:00 GMT",
"title": "Who killed Captain Alex"
},
{
"cast": [],
"id": 3,
"release_date": "Sun, 19 Jan 2020 00:00:00 GMT",
"title": "Coming to America"
}
],
"success": true
}
- Creates a new movie.
- Required fields: title, release_date
- Required permission:
create:movies
.
Example json data to send.
{
"title": "Coming to America",
"release_date": "2020-1-19"
}
Example of output.
{
"created": 4,
"movies": [
{
"cast": [
{
"id": 2,
"name": "Matthew Bam"
},
{
"id": 1,
"name": "Julie Ivans"
}
],
"id": 1,
"release_date": "Mon, 19 Oct 2020 00:00:00 GMT",
"title": "Tebatusasula"
},
{
"cast": [],
"id": 2,
"release_date": "Sun, 19 Jan 2020 00:00:00 GMT",
"title": "Who killed Captain Alex"
},
{
"cast": [],
"id": 3,
"release_date": "Thu, 25 Jan 2001 00:00:00 GMT",
"title": "Going to America"
},
{
"cast": [],
"id": 4,
"release_date": "Sun, 19 Jan 2020 00:00:00 GMT",
"title": "Secret life of pets"
}
],
"success": true,
"total_movies": 4
}
- Edits a movie with given id.
- Possible fields to edit: title, release_date.
- Required permission:
patch:movies
.
Example of json data to send.
{
"release_date": "2001-1-25"
}
Example of output.
{
"movies": [
{
"cast": [
{
"id": 2,
"name": "Matthew Bam"
},
{
"id": 1,
"name": "Julie Ivans"
}
],
"id": 1,
"release_date": "Mon, 19 Oct 2020 00:00:00 GMT",
"title": "Tebatusasula"
},
{
"cast": [],
"id": 2,
"release_date": "Sun, 19 Jan 2020 00:00:00 GMT",
"title": "Who killed Captain Alex"
},
{
"cast": [],
"id": 3,
"release_date": "Thu, 25 Jan 2001 00:00:00 GMT",
"title": "Going to America"
},
{
"cast": [],
"id": 4,
"release_date": "Thu, 25 Jan 2001 00:00:00 GMT",
"title": "Secret life of pets"
}
],
"success": true
}
- 400 - Bad request. Request missing a required field.
- 401 - Unauthorized. Authentication needed.
- 403 - Forbidden. User does not have rights to perform action.
- 404 - Resource not found.
- 405 - Method not allowed on given endpoint.
- 422 - Request unprocessable.
- 500 - Internal server error.
- Tokens for each role are needed to run tests.
- Click here to view login page.
Casting assistant credentials.
email: assistant@example.com
password: asG8Bwqg!#
Casting director credentials.
email: director@example.com
password: gaKGS234Gal!@
Executive producer
email: producer@example.com
password: stGS12gzLoi74@$E
- Add the tokens from each of the above to the .env file following the .env_example.
- Create a test database and its database url to the .env file.
- Now you can run the command
pytest
to run the tests.
- Nangai Arthur
- Irzelindo Joaquim S
- Udacity