###Capstone project "Casting Agency" Two sets of specifications have been created for this project. The first set is general and not domain specified. This is for students who want to practice and have their own topic they want to use as the content for the project. Students who may not have their own idea can use the Casting Agency specifications to have slightly more structure when you get started.
General Specifications Models will include at least… Two classes with primary keys at at least two attributes each [Optional but encouraged] One-to-many or many-to-many relationships between classes Endpoints will include at least… Two GET requests One POST request One PATCH request One DELETE request Roles will include at least… Two roles with different permissions Permissions specified for all endpoints Tests will include at least…. One test for success behavior of each endpoint One test for error behavior of each endpoint At least two tests of RBAC for each role Casting Agency Specifications 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.
Models:
Movies with attributes title and release date Actors with attributes name, age and gender Endpoints: GET /actors and /movies DELETE /actors/ and /movies/ POST /actors and /movies and PATCH /actors/ and /movies/ 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 Tests: One test for success behavior of each endpoint One test for error behavior of each endpoint At least two tests of RBAC for each role
mkvirtualenv capstone
- Install the dependencies:
pip install -r requirements.txt
-
Setup database in config.py
-
Setup Auth0: create an account on auth0, Create a web application and configure it. Following permissions defined :
role assistant
read:actors
read:movies
role director
add:actor
modify:actor
modify:movie
delete:actor
role producer
add:movie
delete:movie
- Give permissions to the roles Define role: Casting assistant, casting director and casting producer
-
set FLASK_APP=app.py
-
Now start local development server
flask run
-
All endpoints written in
app.py
, models inmodels.py
, config variable inconfig.py
and all dependencies are inrequirements.txt
-
To tun the
test_app.py
file, executepython test_app.py
. The result of the dough is stored in a folder.result_tests
###Attention to this stage would have to develop your application !
- register on the site:
heroku.com
2)I nstall heroku on your device.
https://devcenter.heroku.com/categories/command-line
-
Login to the command line.
heroku login
https://devcenter.heroku.com/articles/heroku-cli#download-and-install -
Create a file with the name.
Procfile
Write this inside the file.web: gunicorn app:app
5)Run this commands
pip install flask_script
pip install flask_migrate
pip install psycopg2-binary
- Create a file with the name:
manage.py
Write this inside the file:
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import app
from models import db
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
- Run this commands Database migration.
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
Creating applications on git heroku.
heroku create name_of_your_app
Open the git console with your application.
git remote add heroku heroku_git_url
automatic creation and configuration of the database on hiroku
heroku addons:create heroku-postgresql:hobby-dev --app name_of_your_application
Announce your application on heroku.
git push heroku master
Database migration from local to heroku platform.
heroku run python manage.py db upgrade --app name_of_your_application
#On this you will find all the following instructions in the course.
SaidAbbos Khudoykulov abbos.xudoyqulov@gmail.com