-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from OscarMoya/add_lint_tools
Add lint tools to the project
- Loading branch information
Showing
13 changed files
with
230 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
exclude = .git, | ||
__pycache__, | ||
docs/source/conf.py, | ||
old,build, | ||
dist, | ||
venv, | ||
.venv, | ||
.tox, | ||
.eggs, | ||
*.egg, | ||
*.egg-info, | ||
*.egg-info/* | ||
__init__.py | ||
ignore = E203, E266, W503 | ||
max-complexity = 18 | ||
select = B,C,E,F,W,T4,B9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[mypy] | ||
check_untyped_defs = True | ||
disallow_untyped_calls = True | ||
ignore_missing_imports = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mypy | ||
flake8 | ||
autopep8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ psycopg2==2.9.9 | |
jinja2==3.1.3 | ||
pyyaml==6.0.1 | ||
pytest | ||
types-requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#DB | ||
# DB | ||
|
||
##Driver | ||
DRIVER="sqlite" | ||
# Driver | ||
DRIVER = "sqlite" | ||
|
||
##SQLite | ||
SQLITE_FILE="./data/backend.db" | ||
# SQLite | ||
SQLITE_FILE = "./data/backend.db" | ||
|
||
##Postgres | ||
POSTGRES_HOST="127.0.0.1" | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB="stack" | ||
POSTGRES_USERNAME="postgres" | ||
POSTGRES_PASSWORD="test" | ||
# Postgres | ||
POSTGRES_HOST = "127.0.0.1" | ||
POSTGRES_PORT = 5432 | ||
POSTGRES_DB = "stack" | ||
POSTGRES_USERNAME = "postgres" | ||
POSTGRES_PASSWORD = "test" | ||
|
||
#API | ||
URL_PATH="/rest" | ||
# API | ||
URL_PATH = "/rest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,77 @@ | ||
from fastapi import APIRouter, Depends, HTTPException, status, Path | ||
from fastapi import APIRouter, Depends, HTTPException | ||
from typing import List | ||
from sqlalchemy.orm import Session | ||
from models.turnilo_dashboard import TurniloDashboard | ||
from services.turnilo_dashboards import * | ||
from services import turnilo_dashboards as td | ||
|
||
from constants import * | ||
import constants | ||
import data.database as db | ||
|
||
api_router = APIRouter() | ||
|
||
### Dashboards ### | ||
|
||
#GET | ||
# GET | ||
|
||
|
||
@api_router.get( | ||
URL_PATH+"/turnilo/dashboards/", | ||
constants.URL_PATH + "/turnilo/dashboards/", | ||
response_model=List[TurniloDashboard], | ||
summary="Gets all Turnilo dashboards" | ||
) | ||
def turnilo_get_dashboards(db_session: Session = Depends(db.get_session)): | ||
return dashboards_get_all(db_session) | ||
return td.dashboards_get_all(db_session) | ||
|
||
|
||
@api_router.get( | ||
URL_PATH+"/turnilo/dashboards/{id}", | ||
constants.URL_PATH + "/turnilo/dashboards/{id}", | ||
response_model=TurniloDashboard, | ||
summary="Get a Turnilo dashboard by id (integer)" | ||
) | ||
def turnilo_get_dashboard_id(id:str, db_session: Session = Depends(db.get_session)): | ||
def turnilo_get_dashboard_id(id: str, db_session: Session = Depends(db.get_session)): | ||
try: | ||
int_id = int(id) | ||
except: | ||
except BaseException: | ||
raise HTTPException(status_code=400, detail="Id is not an integer") | ||
return dashboards_get_id(db_session, int_id) | ||
return td.dashboards_get_id(db_session, int_id) | ||
|
||
# POST | ||
|
||
|
||
#POST | ||
@api_router.post( | ||
URL_PATH+"/turnilo/dashboards/", | ||
constants.URL_PATH + "/turnilo/dashboards/", | ||
response_model=TurniloDashboard, | ||
summary="Create a Turnilo dashboard. A unique id will be assigned." | ||
) | ||
def turnilo_create_dashboard(dashboard: TurniloDashboard, db_session: Session = Depends(db.get_session)): | ||
return dashboards_create(db_session, dashboard) | ||
return td.dashboards_create(db_session, dashboard) | ||
|
||
|
||
#PUT | ||
# PUT | ||
@api_router.put( | ||
URL_PATH+"/turnilo/dashboards/{id}", | ||
constants.URL_PATH + "/turnilo/dashboards/{id}", | ||
response_model=TurniloDashboard, | ||
summary="Update/replace a Turnilo dashboard. The dashboard (id) must exist" | ||
) | ||
def turnilo_update_dashboard(id:str, dashboard: TurniloDashboard, db_session: Session = Depends(db.get_session)): | ||
def turnilo_update_dashboard(id: str, dashboard: TurniloDashboard, db_session: Session = Depends(db.get_session)): | ||
try: | ||
int_id = int(id) | ||
dashboard.id = int_id | ||
except: | ||
except BaseException: | ||
raise HTTPException(status_code=400, detail="Id is not an integer") | ||
return dashboards_update(db_session, dashboard) | ||
return td.dashboards_update(db_session, dashboard) | ||
|
||
# DELETE | ||
|
||
|
||
#DELETE | ||
@api_router.delete( | ||
URL_PATH+"/turnilo/dashboards/{id}", | ||
constants.URL_PATH + "/turnilo/dashboards/{id}", | ||
response_model=TurniloDashboard, | ||
summary="Delete a Turnilo dashboard" | ||
) | ||
def turnilo_delete_dashboard(id: str, db_session: Session = Depends(db.get_session)): | ||
try: | ||
int_id = int(id) | ||
except: | ||
except BaseException: | ||
raise HTTPException(status_code=400, detail="Id is not an integer") | ||
return dashboards_delete(db_session, id) | ||
return td.dashboards_delete(db_session, int_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.