removed authorize stuff
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi import APIRouter, Request, Depends
|
||||
from datetime import date
|
||||
from database import session
|
||||
from sqlalchemy.orm import Session
|
||||
from database import get_db
|
||||
from pyowm import OWM
|
||||
from decimal import Decimal
|
||||
from app.models.auto import Auto_Delivery, Tickets_Auto_Delivery
|
||||
@@ -19,14 +20,14 @@ router = APIRouter(
|
||||
|
||||
|
||||
@router.put("/auto/update/{autoid}")
|
||||
async def update_auto(autoid: int, request: Request):
|
||||
async def update_auto(autoid: int, request: Request, db: Session = Depends(get_db)):
|
||||
|
||||
request_body = await request.json()
|
||||
gallons_delivered = request_body['gallons_delivered']
|
||||
gallons_delivered = Decimal(gallons_delivered)
|
||||
|
||||
|
||||
get_auto_delivery = (session
|
||||
get_auto_delivery = (db
|
||||
.query(Auto_Delivery)
|
||||
.filter(Auto_Delivery.id == autoid)
|
||||
.first())
|
||||
@@ -50,9 +51,9 @@ async def update_auto(autoid: int, request: Request):
|
||||
get_auto_delivery.auto_status = 1
|
||||
get_auto_delivery.days_since_last_fill = 0
|
||||
|
||||
session.add(get_auto_delivery)
|
||||
db.add(get_auto_delivery)
|
||||
|
||||
session.commit()
|
||||
db.commit()
|
||||
|
||||
return ({"ok": True}), 200
|
||||
|
||||
@@ -60,7 +61,7 @@ async def update_auto(autoid: int, request: Request):
|
||||
|
||||
|
||||
@router.post("/auto/create/{autoid}")
|
||||
async def create_auto_ticket(autoid: int, request: Request):
|
||||
async def create_auto_ticket(autoid: int, request: Request, db: Session = Depends(get_db)):
|
||||
|
||||
|
||||
request_body = await request.json()
|
||||
@@ -68,11 +69,11 @@ async def create_auto_ticket(autoid: int, request: Request):
|
||||
gallons_delivered = Decimal(gallons_delivered)
|
||||
|
||||
|
||||
get_auto_delivery = (session
|
||||
get_auto_delivery = (db
|
||||
.query(Auto_Delivery)
|
||||
.filter(Auto_Delivery.id == autoid)
|
||||
.first())
|
||||
get_todays_price = (session.query(Pricing_Oil_Oil)
|
||||
get_todays_price = (db.query(Pricing_Oil_Oil)
|
||||
.order_by(Pricing_Oil_Oil.id.desc())
|
||||
.first())
|
||||
gallons_put_in_home = Decimal(gallons_delivered)
|
||||
@@ -95,9 +96,9 @@ async def create_auto_ticket(autoid: int, request: Request):
|
||||
)
|
||||
|
||||
|
||||
session.add(create_new_ticket)
|
||||
db.add(create_new_ticket)
|
||||
|
||||
session.commit()
|
||||
db.commit()
|
||||
|
||||
return ({
|
||||
"ok": True,
|
||||
|
||||
Reference in New Issue
Block a user