This commit is contained in:
arcbtc 2023-12-08 22:09:40 +00:00
parent 551d77a7d9
commit 5ca331134c
7 changed files with 11 additions and 13 deletions

View file

@ -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

View file

@ -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

View file

@ -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;
"""
)

View file

@ -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]

View file

@ -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())

View file

@ -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")
#######################################

View file

@ -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: