This is a simple flash application that asks for an employee number and displays the order for today or a selected time.
In this project:
- Factory flask app
- SQLAlchemy + PostgreSQL
- Testing app and models with pytest
- Running app with Docker
- Before doing all of this you need:
- Installed Docker and some database
- Clone the repository or download the zip file
git clone https://github.com/NikZip/WorkingOrderFlask
- Setup
.env
by renaming .env_template file and setting up params
SECRET_KEY
- your secret key for app
FLASK_DEBUG
- set it to 0 to use production config and to 1 if you wanna use dev config
DATABASE
- set your database options: engine, user, pass and etc
- Docker:
docker-compose up --build
- Without Docker
pip install -r requirements.txt
- To run test start
run_test.py
file ``
Project/
├─ FlaskApp/
│ ├─ blueprint-folder/
│ │ ├─ blueprint-templates/
│ ├─ templates/
│ ├─ static/
│ ├─ tests/
├─ run.py
├─ run_tests.py
Blueprint functions:
main
- get function. Renders main page
render_order
- post function.
It takes in a form object containing personal_n and date fields and validates it.
If the form's data is valid, it retrieves the corresponding WorkingOrder data from the database and renders it on the web page.
Otherwise, it just renders an empty web page.
Model functions:
get_by_personal_n
- Retrieving all WorkingOrder records from the database that match the provided personal_n and date.
It then orders the results by departure_time and returns all of the results as a list.
Config
- base config class
ProductionConfig
- config will be used if in .env
is FLASK_DEBUG=0
.
You can set different SQLALCHEMY_DATABASE_URI
for prod database
DevelopmentConfig
- config will be used if in .env
is FLASK_DEBUG=1
.
Use this config for dev
TestingConfig
- config will be used when testing app with pytest.
- Model method
get_be_personal_n
- Right config conf and if there is
.env
file - App functions
create_app
- Factory app function
create_database_url
- creates url from .env
params
This app is distributed under the MIT license.