From 5ca331134c3c33c58bbddefed0cc14c315018075 Mon Sep 17 00:00:00 2001 From: arcbtc Date: Fri, 8 Dec 2023 22:09:40 +0000 Subject: [PATCH] cleaned --- __init__.py | 4 ++-- crud.py | 2 +- migrations.py | 6 ++---- models.py | 2 +- tasks.py | 2 +- views.py | 4 ++-- views_api.py | 4 ++-- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/__init__.py b/__init__.py index 73a34ff..b463fc3 100644 --- a/__init__.py +++ b/__init__.py @@ -12,7 +12,7 @@ from fastapi.responses import JSONResponse db = Database("ext_temp") temp_ext: APIRouter = APIRouter( - prefix="/temp", tags=["Temp"] + prefix="/temp", tags=["temp"] ) temp_static_files = [ @@ -23,7 +23,7 @@ temp_static_files = [ ] def template_renderer(): - return template_renderer(["temp/temps"]) + return template_renderer(["temp/templates"]) from .lnurl import * from .tasks import wait_for_paid_invoices diff --git a/crud.py b/crud.py index 9165075..1594f2d 100644 --- a/crud.py +++ b/crud.py @@ -3,7 +3,7 @@ from typing import List, Optional, Union from lnbits.helpers import urlsafe_short_hash from . import db -from .models import CreateTempData, Temp, TempClean, LNURLCharge +from .models import CreateTempData, Temp from loguru import logger diff --git a/migrations.py b/migrations.py index a3d9c66..4017ab7 100644 --- a/migrations.py +++ b/migrations.py @@ -11,13 +11,11 @@ async def m001_initial(db): wallet TEXT NOT NULL, name TEXT NOT NULL, total INTEGER DEFAULT 0, - lnurlpayamount INTEGER DEFAULT 0, - lnurlwithdrawamount INTEGER DEFAULT 0, + lnurlpayamount INTEGER DEFAULT 0 ); """ ) - # Here we are adding an extra field to the database async def m002_addtip_wallet(db): @@ -26,6 +24,6 @@ async def m002_addtip_wallet(db): """ await db.execute( """ - ALTER TABLE temp.temp ADD lnurlwithdrawamount withdrawlimit INTEGER DEFAULT 0,; + ALTER TABLE temp.temp ADD lnurlwithdrawamount INTEGER DEFAULT 0; """ ) \ No newline at end of file diff --git a/models.py b/models.py index 5a4d793..ae031ff 100644 --- a/models.py +++ b/models.py @@ -23,5 +23,5 @@ class Temp(BaseModel): def from_row(cls, row: Row) -> "Temp": return cls(**dict(row)) -class CreateUpdateItemData(BaseModel): +class CreateUpdateTempData(BaseModel): items: List[Temp] \ No newline at end of file diff --git a/tasks.py b/tasks.py index 214bcd1..8b952ea 100644 --- a/tasks.py +++ b/tasks.py @@ -41,7 +41,7 @@ async def on_invoice_paid(payment: Payment) -> None: # update something data_to_update = { - "total" temp.total + payment.amount + "total": temp.total + payment.amount } await update_temp(temp_id=temp_id, **data_to_update.dict()) diff --git a/views.py b/views.py index 0f73d38..a050351 100644 --- a/views.py +++ b/views.py @@ -1,7 +1,7 @@ from http import HTTPStatus from fastapi import Depends, Request -from fastapi.templating import Jinja2Temps +from fastapi.templating import Jinja2Templates from starlette.exceptions import HTTPException from starlette.responses import HTMLResponse @@ -12,7 +12,7 @@ from lnbits.settings import settings from . import temp_ext, template_renderer from .crud import get_temp -temps = Jinja2Temps(directory="temps") +temps = Jinja2Templates(directory="temps") ####################################### diff --git a/views_api.py b/views_api.py index 3da98d1..bb0f83b 100644 --- a/views_api.py +++ b/views_api.py @@ -27,7 +27,7 @@ from .crud import ( get_temp, get_temps ) -from .models import CreateTempData, PayLnurlWData, LNURLCharge, CreateUpdateItemData +from .models import CreateTempData ####################################### @@ -102,7 +102,7 @@ async def api_temp_delete( ## This endpoint creates a payment -@tpos_ext.post("/api/v1/temps/payment/{temp_id}", status_code=HTTPStatus.CREATED) +@temp_ext.post("/api/v1/temps/payment/{temp_id}", status_code=HTTPStatus.CREATED) async def api_tpos_create_invoice( temp_id: str, amount: int = Query(..., ge=1), memo: str = "" ) -> dict: