cleaned
This commit is contained in:
parent
551d77a7d9
commit
5ca331134c
7 changed files with 11 additions and 13 deletions
|
|
@ -12,7 +12,7 @@ from fastapi.responses import JSONResponse
|
||||||
db = Database("ext_temp")
|
db = Database("ext_temp")
|
||||||
|
|
||||||
temp_ext: APIRouter = APIRouter(
|
temp_ext: APIRouter = APIRouter(
|
||||||
prefix="/temp", tags=["Temp"]
|
prefix="/temp", tags=["temp"]
|
||||||
)
|
)
|
||||||
|
|
||||||
temp_static_files = [
|
temp_static_files = [
|
||||||
|
|
@ -23,7 +23,7 @@ temp_static_files = [
|
||||||
]
|
]
|
||||||
|
|
||||||
def template_renderer():
|
def template_renderer():
|
||||||
return template_renderer(["temp/temps"])
|
return template_renderer(["temp/templates"])
|
||||||
|
|
||||||
from .lnurl import *
|
from .lnurl import *
|
||||||
from .tasks import wait_for_paid_invoices
|
from .tasks import wait_for_paid_invoices
|
||||||
|
|
|
||||||
2
crud.py
2
crud.py
|
|
@ -3,7 +3,7 @@ from typing import List, Optional, Union
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
from .models import CreateTempData, Temp, TempClean, LNURLCharge
|
from .models import CreateTempData, Temp
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,11 @@ async def m001_initial(db):
|
||||||
wallet TEXT NOT NULL,
|
wallet TEXT NOT NULL,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
total INTEGER DEFAULT 0,
|
total INTEGER DEFAULT 0,
|
||||||
lnurlpayamount INTEGER DEFAULT 0,
|
lnurlpayamount INTEGER DEFAULT 0
|
||||||
lnurlwithdrawamount INTEGER DEFAULT 0,
|
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Here we are adding an extra field to the database
|
# Here we are adding an extra field to the database
|
||||||
|
|
||||||
async def m002_addtip_wallet(db):
|
async def m002_addtip_wallet(db):
|
||||||
|
|
@ -26,6 +24,6 @@ async def m002_addtip_wallet(db):
|
||||||
"""
|
"""
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
ALTER TABLE temp.temp ADD lnurlwithdrawamount withdrawlimit INTEGER DEFAULT 0,;
|
ALTER TABLE temp.temp ADD lnurlwithdrawamount INTEGER DEFAULT 0;
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
@ -23,5 +23,5 @@ class Temp(BaseModel):
|
||||||
def from_row(cls, row: Row) -> "Temp":
|
def from_row(cls, row: Row) -> "Temp":
|
||||||
return cls(**dict(row))
|
return cls(**dict(row))
|
||||||
|
|
||||||
class CreateUpdateItemData(BaseModel):
|
class CreateUpdateTempData(BaseModel):
|
||||||
items: List[Temp]
|
items: List[Temp]
|
||||||
2
tasks.py
2
tasks.py
|
|
@ -41,7 +41,7 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||||
# update something
|
# update something
|
||||||
|
|
||||||
data_to_update = {
|
data_to_update = {
|
||||||
"total" temp.total + payment.amount
|
"total": temp.total + payment.amount
|
||||||
}
|
}
|
||||||
|
|
||||||
await update_temp(temp_id=temp_id, **data_to_update.dict())
|
await update_temp(temp_id=temp_id, **data_to_update.dict())
|
||||||
|
|
|
||||||
4
views.py
4
views.py
|
|
@ -1,7 +1,7 @@
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import Depends, Request
|
from fastapi import Depends, Request
|
||||||
from fastapi.templating import Jinja2Temps
|
from fastapi.templating import Jinja2Templates
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
from starlette.responses import HTMLResponse
|
from starlette.responses import HTMLResponse
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ from lnbits.settings import settings
|
||||||
from . import temp_ext, template_renderer
|
from . import temp_ext, template_renderer
|
||||||
from .crud import get_temp
|
from .crud import get_temp
|
||||||
|
|
||||||
temps = Jinja2Temps(directory="temps")
|
temps = Jinja2Templates(directory="temps")
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ from .crud import (
|
||||||
get_temp,
|
get_temp,
|
||||||
get_temps
|
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
|
## 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(
|
async def api_tpos_create_invoice(
|
||||||
temp_id: str, amount: int = Query(..., ge=1), memo: str = ""
|
temp_id: str, amount: int = Query(..., ge=1), memo: str = ""
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue