The Casting Agency models a company that is responsible for creating movies and managing and assigning actors to those movies
the motivation is to help the casting company through easing the procedures to achieve it's goals
The app is hosted at https://casting-agency1996.herokuapp.com/
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
- Role: no role assigned: email: rachael97@qacmemphis.com pw: 3432stnrM
- Role: Casting Assistant: email: michial7@gannoyingl.com pw: rst23ST2232
- Role: Casting Director: email: rosalbaa4@gannoyingl.com pw: rosalbaa4@gannoyingl.com
- Role: Executive Producer: email: tess5@kweekendci.com pw: 165svbX5
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
are in the postman collection Casting-Agency.postman_collection.json
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 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.
-
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 referencemodels.py
. -
jose The JavaScript Object Signing and Encryption (JOSE) technologies, used to handle JWT decrypton and verification in
auth.py
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
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
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
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
- Unit-test: The tests is in
test_app.py
. There is a flag/parameter to the create_app() functioncreate_app(test_config=None)
so when unit testing it setstest_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 inauth.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 documentation is in it's own markdown file here API Documentation
you can deploy on heroku for more info heroku deployment
I
stackoverflow, the knowledge hub and the FSND slack community