Skip to content

Commit a9605fe

Browse files
committed
pretty
1 parent 6f52727 commit a9605fe

14 files changed

+105
-90
lines changed

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def tpos_start():
4242
__all__ = [
4343
"db",
4444
"tpos_ext",
45-
"tpos_static_files",
4645
"tpos_start",
46+
"tpos_static_files",
4747
"tpos_stop",
4848
]

crud.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
from lnbits.db import Database
55
from lnbits.helpers import urlsafe_short_hash
6+
from loguru import logger
67

78
from .models import CreateTposData, LnurlCharge, Tpos, TposClean
8-
from loguru import logger
9+
910
db = Database("ext_tpos")
1011

1112

@@ -85,5 +86,6 @@ async def get_tposs(wallet_ids: Union[str, list[str]]) -> list[Tpos]:
8586
logger.debug(tposs)
8687
return tposs
8788

89+
8890
async def delete_tpos(tpos_id: str) -> None:
8991
await db.execute("DELETE FROM tpos.pos WHERE id = :id", {"id": tpos_id})

helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from lnbits.core.views.api import api_lnurlscan
33
from loguru import logger
44

5+
56
async def get_pr(ln_address, amount):
67
logger.debug(ln_address)
78
logger.debug(amount)
@@ -10,10 +11,12 @@ async def get_pr(ln_address, amount):
1011
if data.get("status") == "ERROR":
1112
return
1213
async with httpx.AsyncClient() as client:
13-
response = await client.get(url=f"{data['callback']}?amount={int(amount) * 1000}")
14+
response = await client.get(
15+
url=f"{data['callback']}?amount={int(amount) * 1000}"
16+
)
1417
if response.status_code != 200:
1518
logger.debug(response.status_code)
1619
return
1720
return response.json()["pr"]
1821
except Exception:
19-
return None
22+
return None

migrations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ async def m010_rename_tpos_withdraw_columns(db: Database):
166166
await db.execute("DROP TABLE tpos.pos")
167167
await db.execute("ALTER TABLE tpos.pos_backup RENAME TO pos")
168168

169+
169170
async def m011_lnaddress(db: Database):
170171
"""
171172
Add lnaddress to tpos table
@@ -176,6 +177,7 @@ async def m011_lnaddress(db: Database):
176177
"""
177178
)
178179

180+
179181
async def m012_addlnaddress(db: Database):
180182
"""
181183
Add lnaddress_cut to tpos table
@@ -184,4 +186,4 @@ async def m012_addlnaddress(db: Database):
184186
"""
185187
ALTER TABLE tpos.pos ADD lnaddress_cut TEXT NULL;
186188
"""
187-
)
189+
)

models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ class HashCheck(BaseModel):
9595
class PayLnurlWData(BaseModel):
9696
lnurl: str
9797

98+
9899
class LNaddress(BaseModel):
99100
lnaddress: str
100101

102+
101103
class Item(BaseModel):
102104
image: Optional[str]
103105
price: float

poetry.lock

Lines changed: 36 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ authors = ["Alan Bits <[email protected]>"]
77
[tool.poetry.dependencies]
88
python = "^3.10 | ^3.9"
99
lnbits = {version = "*", allow-prereleases = true}
10+
mypy = "^1.13.0"
1011

1112
[tool.poetry.group.dev.dependencies]
1213
black = "^24.3.0"

static/js/tpos.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,19 @@ window.app = Vue.createApp({
296296
)
297297
.then(response => {
298298
if (response.data) {
299-
this.$q.localStorage.set('tpos.lnaddress', this.lnaddressDialog.lnaddress);
299+
this.$q.localStorage.set(
300+
'tpos.lnaddress',
301+
this.lnaddressDialog.lnaddress
302+
)
300303
this.lnaddressDialog.show = false
301304
this.lnaddress = true
302305
}
303306
})
304307
.catch(error => {
305-
const errorMessage = error.response?.data?.detail || "An unknown error occurred.";
306-
LNbits.utils.notifyApiError(errorMessage);
307-
});
308+
const errorMessage =
309+
error.response?.data?.detail || 'An unknown error occurred.'
310+
LNbits.utils.notifyApiError(errorMessage)
311+
})
308312
},
309313
atmGetWithdraw() {
310314
var dialog = this.invoiceDialog
@@ -467,13 +471,13 @@ window.app = Vue.createApp({
467471
}
468472
})
469473

470-
params.details = {
471-
currency: this.currency,
472-
exchangeRate: this.exchangeRate,
473-
items: details,
474-
taxIncluded: this.taxInclusive,
475-
taxValue: this.cartTax
476-
}
474+
params.details = {
475+
currency: this.currency,
476+
exchangeRate: this.exchangeRate,
477+
items: details,
478+
taxIncluded: this.taxInclusive,
479+
taxValue: this.cartTax
480+
}
477481
}
478482
if (this.lnaddress) {
479483
params.user_lnaddress = this.lnaddressDialog.lnaddress
@@ -700,9 +704,9 @@ window.app = Vue.createApp({
700704
clearLNaddress() {
701705
this.$q.localStorage.remove('tpos.lnaddress')
702706
this.lnaddressDialog.lnaddress = ''
703-
const url = new URL(window.location.href);
704-
url.searchParams.delete('lnaddress');
705-
window.history.replaceState({}, document.title, url.toString());
707+
const url = new URL(window.location.href)
708+
url.searchParams.delete('lnaddress')
709+
window.history.replaceState({}, document.title, url.toString())
706710
this.lnaddressDialog.show = true
707711
this.lnaddress = false
708712
},
@@ -774,18 +778,20 @@ window.app = Vue.createApp({
774778
this.showPoS = false
775779
this.categories = this.extractCategories(this.items)
776780
}
777-
if (this.tposLNaddress){
778-
this.lnaddressDialog.lnaddress = this.$q.localStorage.getItem('tpos.lnaddress')
779-
if(lnaddressparam != ""){
781+
if (this.tposLNaddress) {
782+
this.lnaddressDialog.lnaddress =
783+
this.$q.localStorage.getItem('tpos.lnaddress')
784+
if (lnaddressparam != '') {
780785
this.lnaddressDialog.lnaddress = lnaddressparam
781-
this.$q.localStorage.set('tpos.lnaddress', this.lnaddressDialog.lnaddress);
786+
this.$q.localStorage.set(
787+
'tpos.lnaddress',
788+
this.lnaddressDialog.lnaddress
789+
)
782790
this.lnaddress = true
783-
}
784-
else if (!this.lnaddressDialog.lnaddress){
791+
} else if (!this.lnaddressDialog.lnaddress) {
785792
this.lnaddress = false
786793
this.lnaddressDialog.show = true
787-
}
788-
else{
794+
} else {
789795
this.lnaddress = true
790796
}
791797
}

tasks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from lnbits.core.models import Payment
44
from lnbits.core.services import create_invoice, pay_invoice, websocket_updater
55
from lnbits.tasks import register_invoice_listener
6-
from .helpers import get_pr
76
from loguru import logger
7+
88
from .crud import get_tpos
9+
from .helpers import get_pr
910

1011

1112
async def wait_for_paid_invoices():
@@ -41,7 +42,7 @@ async def on_invoice_paid(payment: Payment) -> None:
4142
tpos = await get_tpos(tpos_id)
4243
assert tpos
4344
logger.debug(payment.extra.get("lnaddress"))
44-
if (payment.extra.get("lnaddress") and payment.extra["lnaddress"] != ""):
45+
if payment.extra.get("lnaddress") and payment.extra["lnaddress"] != "":
4546
logger.debug("poo")
4647
calc_amount = payment.amount - ((payment.amount / 100) * tpos.lnaddress_cut)
4748
logger.debug(calc_amount)
@@ -50,7 +51,7 @@ async def on_invoice_paid(payment: Payment) -> None:
5051
if pr:
5152
payment.extra["lnaddress"] = ""
5253
paid_payment = await pay_invoice(
53-
payment_request = pr,
54+
payment_request=pr,
5455
wallet_id=payment.wallet_id,
5556
extra={**payment.extra},
5657
)

templates/tpos/dialogs.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,7 @@ <h5 class="q-mt-none q-mb-sm">
200200
</q-card-section>
201201
<q-card-section>
202202
<q-form autofocus @submit="lnaddressSubmit" class="q-gutter-md">
203-
<q-input
204-
filled
205-
type="text"
206-
v-model="lnaddressDialog.lnaddress"
207-
>
203+
<q-input filled type="text" v-model="lnaddressDialog.lnaddress">
208204
</q-input>
209205
<div>
210206
<q-btn label="Submit" type="submit" color="primary"></q-btn>

templates/tpos/index.html

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -321,25 +321,27 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} TPoS extension</h6>
321321
v-model="formDialog.data.lnaddress"
322322
label="LNaddress funding"
323323
>
324-
<q-tooltip>
325-
<span
326-
v-text="'If enabled, the tpos can be funded with a LNaddress in the public page.'"
327-
></span></q-tooltip>
328-
</q-checkbox>
324+
<q-tooltip>
325+
<span
326+
v-text="'If enabled, the tpos can be funded with a LNaddress in the public page.'"
327+
></span
328+
></q-tooltip>
329+
</q-checkbox>
329330
</div>
330331
<div class="col">
331332
<q-input
332-
filled
333-
dense
333+
filled
334+
dense
334335
:disable="!formDialog.data.lnaddress"
335336
v-model="formDialog.data.lnaddress_cut"
336337
type="number"
337338
label="LNaddress cut 0-100 percent"
338-
><q-tooltip>
339-
<span
340-
v-text="'Percent charge for using the LNaddress funding option. To go to the TPoS wallet.'"
341-
></span></q-tooltip>
342-
</q-input>
339+
><q-tooltip>
340+
<span
341+
v-text="'Percent charge for using the LNaddress funding option. To go to the TPoS wallet.'"
342+
></span
343+
></q-tooltip>
344+
</q-input>
343345
</div>
344346
</div>
345347
<div class="row">

templates/tpos/tpos.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ <h5>
243243
fab
244244
icon="cancel_schedule_send"
245245
color="primary"
246-
247-
><q-tooltip>Clear LNaddress</q-tooltip></q-btn>
246+
><q-tooltip>Clear LNaddress</q-tooltip></q-btn
247+
>
248248
</q-page-sticky>
249249
</template>
250250
<template v-else>

views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
from lnbits.decorators import check_user_exists
77
from lnbits.helpers import template_renderer
88
from lnbits.settings import settings
9-
from starlette.responses import HTMLResponse
109
from loguru import logger
10+
from starlette.responses import HTMLResponse
11+
1112
from .crud import get_clean_tpos, get_tpos
1213
from .models import TposClean
1314

0 commit comments

Comments
 (0)