mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-08 03:48:30 +02:00
Formatting
This commit is contained in:
parent
a5825f1aa9
commit
936e9342a2
@ -3,7 +3,7 @@ from typing import List, Optional, Union
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
from . import db
|
||||
from .models import Address, CreateAddressData, CreateDomainData, EditDomainData, Domain
|
||||
from .models import Address, CreateAddressData, CreateDomainData, Domain, EditDomainData
|
||||
|
||||
|
||||
async def get_domain(domain_id: str) -> Optional[Domain]:
|
||||
@ -169,6 +169,7 @@ async def create_address_internal(domain_id: str, data: CreateAddressData) -> Ad
|
||||
assert address, "Newly created address couldn't be retrieved"
|
||||
return address
|
||||
|
||||
|
||||
async def update_domain_internal(wallet_id: str, data: EditDomainData) -> Domain:
|
||||
if data.currency != "Satoshis":
|
||||
amount = data.amount * 100
|
||||
@ -188,6 +189,7 @@ async def update_domain_internal(wallet_id: str, data: EditDomainData) -> Domain
|
||||
assert domain, "Domain couldn't be updated"
|
||||
return domain
|
||||
|
||||
|
||||
async def create_domain_internal(wallet_id: str, data: CreateDomainData) -> Domain:
|
||||
domain_id = urlsafe_short_hash()
|
||||
|
||||
|
@ -24,8 +24,9 @@ class CreateDomainData(BaseModel):
|
||||
amount: float = Query(..., ge=0.01)
|
||||
domain: str
|
||||
|
||||
|
||||
class EditDomainData(BaseModel):
|
||||
id: str
|
||||
id: str
|
||||
currency: str
|
||||
amount: float = Query(..., ge=0.01)
|
||||
|
||||
@ -33,6 +34,7 @@ class EditDomainData(BaseModel):
|
||||
def from_row(cls, row: Row) -> "Domain":
|
||||
return cls(**dict(row))
|
||||
|
||||
|
||||
class Domain(BaseModel):
|
||||
id: str
|
||||
wallet: str
|
||||
|
@ -235,7 +235,11 @@
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog v-model="editFormDialog.show" position="top" @hide="closeFormDialog">
|
||||
<q-dialog
|
||||
v-model="editFormDialog.show"
|
||||
position="top"
|
||||
@hide="closeFormDialog"
|
||||
>
|
||||
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">
|
||||
<q-form @submit="saveEditedDomain" class="q-gutter-md">
|
||||
<q-select
|
||||
@ -254,12 +258,7 @@
|
||||
placeholder="How much do you want to charge?"
|
||||
></q-input>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
type="submit"
|
||||
>Update Amount</q-btn
|
||||
>
|
||||
<q-btn unelevated color="primary" type="submit">Update Amount</q-btn>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||
>Cancel</q-btn
|
||||
>
|
||||
@ -627,13 +626,14 @@
|
||||
saveEditedDomain: function () {
|
||||
var data = this.editFormDialog.data
|
||||
var self = this
|
||||
|
||||
|
||||
LNbits.api
|
||||
.request(
|
||||
'PUT',
|
||||
'/nostrnip5/api/v1/domain',
|
||||
_.findWhere(this.g.user.wallets, {id: this.editFormDialog.data.wallet})
|
||||
.inkey,
|
||||
_.findWhere(this.g.user.wallets, {
|
||||
id: this.editFormDialog.data.wallet
|
||||
}).inkey,
|
||||
data
|
||||
)
|
||||
.then(function (response) {
|
||||
@ -647,7 +647,7 @@
|
||||
editDomain: function (domain_id) {
|
||||
var self = this
|
||||
var data = _.findWhere(this.domains, {id: domain_id})
|
||||
|
||||
|
||||
self.editFormDialog.show = true
|
||||
self.editFormDialog.data = data
|
||||
},
|
||||
|
@ -28,7 +28,12 @@ from .crud import (
|
||||
rotate_address,
|
||||
update_domain_internal,
|
||||
)
|
||||
from .models import CreateAddressData, CreateDomainData, RotateAddressData, EditDomainData
|
||||
from .models import (
|
||||
CreateAddressData,
|
||||
CreateDomainData,
|
||||
EditDomainData,
|
||||
RotateAddressData,
|
||||
)
|
||||
|
||||
|
||||
@nostrnip5_ext.get("/api/v1/domains", status_code=HTTPStatus.OK)
|
||||
@ -89,6 +94,7 @@ async def api_domain_create(
|
||||
|
||||
return domain
|
||||
|
||||
|
||||
@nostrnip5_ext.put("/api/v1/domain", status_code=HTTPStatus.OK)
|
||||
async def api_domain_update(
|
||||
data: EditDomainData, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
@ -98,6 +104,7 @@ async def api_domain_update(
|
||||
|
||||
return domain
|
||||
|
||||
|
||||
@nostrnip5_ext.delete("/api/v1/domain/{domain_id}", status_code=HTTPStatus.CREATED)
|
||||
async def api_domain_delete(
|
||||
domain_id: str,
|
||||
|
Loading…
x
Reference in New Issue
Block a user