general cleanup and unused imports removal

This commit is contained in:
Tiago vasconcelos
2021-11-25 18:52:16 +00:00
parent 2b0bd43974
commit cfac70d394
62 changed files with 159 additions and 442 deletions
-5
View File
@@ -18,7 +18,6 @@ withdraw_static_files = [
withdraw_ext: APIRouter = APIRouter(
prefix="/withdraw",
tags=["withdraw"],
# "withdraw", __name__, static_folder="static", template_folder="templates"
)
@@ -29,7 +28,3 @@ def withdraw_renderer():
from .lnurl import * # noqa
from .views import * # noqa
from .views_api import * # noqa
# @withdraw_ext.on_event("startup")
# def _do_it():
# register_listeners()
+1 -9
View File
@@ -22,20 +22,16 @@ from .crud import get_withdraw_link_by_hash, update_withdraw_link
name="withdraw.api_lnurl_response",
)
async def api_lnurl_response(request: Request, unique_hash):
print("NOT UNIQUE")
link = await get_withdraw_link_by_hash(unique_hash)
if not link:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
)
# return ({"status": "ERROR", "reason": "LNURL-withdraw not found."},
# HTTPStatus.OK,
# )
if link.is_spent:
raise HTTPException(
# WHAT STATUS_CODE TO USE??
detail="Withdraw is spent."
)
url = request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
@@ -52,9 +48,6 @@ async def api_lnurl_response(request: Request, unique_hash):
# CALLBACK
#https://5650-2001-8a0-fa12-2900-4c13-748a-fbb9-a47f.ngrok.io/withdraw/api/v1/lnurl/cb/eJHybS8hqcBWajZM63H3FP?k1=MUaYBGrUPuAs8SLpfizmCk&pr=lnbc100n1pse2tsypp5ju0yn3w9j0n8rr3squg0knddawu2ude2cgrm6zje5f34e9jzpmlsdq8w3jhxaqxqyjw5qcqpjsp5tyhu78pamqg5zfy96kup329zt40ramc8gs2ev6jxgp66zca2348qrzjqwac3nxyg3f5mfa4ke9577c4u8kvkx8pqtdsusqdfww0aymk823x6znwa5qqzyqqqyqqqqlgqqqqppgq9q9qy9qsq66zp6pctnlmk59xwtqjga5lvqrkyccmafmn43enhhc6ugew80sanxymepshpv44m9yyhfgh8r2upvxhgk00d36rpqzfy3fxemeu4jhqp96l8hx
@withdraw_ext.get(
"/api/v1/lnurl/cb/{unique_hash}",
name="withdraw.api_lnurl_callback",
@@ -126,7 +119,6 @@ async def api_lnurl_callback(
name="withdraw.api_lnurl_multi_response",
)
async def api_lnurl_multi_response(request: Request, unique_hash, id_unique_hash):
print("UNIQUE")
link = await get_withdraw_link_by_hash(unique_hash)
if not link:
+1 -11
View File
@@ -18,8 +18,6 @@ templates = Jinja2Templates(directory="templates")
@withdraw_ext.get("/", response_class=HTMLResponse)
# @validate_uuids(["usr"], required=True)
# @check_user_exists()
async def index(request: Request, user: User = Depends(check_user_exists)):
return withdraw_renderer().TemplateResponse(
"withdraw/index.html", {"request": request, "user": user.dict()}
@@ -34,9 +32,6 @@ async def display(request: Request, link_id):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
)
# response.status_code = HTTPStatus.NOT_FOUND
# return "Withdraw link does not exist." #probably here is where we should return the 404??
print("LINK", link)
return withdraw_renderer().TemplateResponse(
"withdraw/display.html",
{
@@ -55,10 +50,7 @@ async def img(request: Request, link_id):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
)
# response.status_code = HTTPStatus.NOT_FOUND
# return "Withdraw link does not exist."
qr = pyqrcode.create(link.lnurl(request))
print(qr)
stream = BytesIO()
qr.svg(stream, scale=3)
stream.seek(0)
@@ -102,13 +94,11 @@ async def print_qr(request: Request, link_id):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
)
# response.status_code = HTTPStatus.NOT_FOUND
# return "Withdraw link does not exist."
links.append(str(linkk.lnurl(request)))
count = count + 1
page_link = list(chunks(links, 2))
linked = list(chunks(page_link, 5))
print("LINKED", linked)
return withdraw_renderer().TemplateResponse(
"withdraw/print_qr.html", {"request": request, "link": linked, "unique": True}
)