Zones are saving/updating

This commit is contained in:
benarc 2022-02-04 13:05:48 +00:00
parent ecaea51a1c
commit 44f7fae2d4
7 changed files with 924 additions and 1006 deletions

View file

@ -9,17 +9,9 @@ from lnbits.tasks import catch_everything_and_restart
db = Database("ext_diagonalley")
diagonalley_static_files = [
{
"path": "/diagonalley/static",
"app": StaticFiles(directory="lnbits/extensions/diagonalley/static"),
"name": "diagonalley_static",
}
]
diagonalley_ext: APIRouter = APIRouter(
prefix="/diagonalley", tags=["diagonalley"]
# "diagonalley", __name__, static_folder="static", template_folder="templates"
)
def diagonalley_renderer():
@ -33,5 +25,4 @@ from .views_api import * # noqa
def diagonalley_start():
loop = asyncio.get_event_loop()
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))

View file

@ -22,28 +22,12 @@ from .models import (
createZones,
)
regex = re.compile(
r"^(?:http|ftp)s?://" # http:// or https://
r"(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|"
r"localhost|"
r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
r"(?::\d+)?"
r"(?:/?|[/?]\S+)$",
re.IGNORECASE,
)
###Products
async def create_diagonalley_product(
data: createProduct
) -> Products:
# returning = "" if db.type == SQLITE else "RETURNING ID"
# method = db.execute if db.type == SQLITE else db.fetchone
product_id = urlsafe_short_hash()
# with open_ext_db("diagonalley") as db:
# result = await (method)(
await db.execute(
f"""
INSERT INTO diagonalley.products (id, stall, product, categories, description, image, price, quantity)
@ -110,7 +94,7 @@ async def delete_diagonalley_product(product_id: str) -> None:
async def create_diagonalley_zone(
wallet,
user,
data: createZones
) -> Zones:
zone_id = urlsafe_short_hash()
@ -118,14 +102,14 @@ async def create_diagonalley_zone(
f"""
INSERT INTO diagonalley.zones (
id,
wallet,
user,
cost,
countries
)
VALUES (?, ?, ?, ?)
""",
(zone_id, wallet, data.cost, data.countries),
(zone_id, user, data.cost, data.countries.lower()),
)
zone = await get_diagonalley_zone(zone_id)
@ -148,41 +132,8 @@ async def get_diagonalley_zone(zone_id: str) -> Optional[Zones]:
return Zones(**row) if row else None
async def get_diagonalley_zones(wallet_ids: Union[str, List[str]]) -> List[Zones]:
if isinstance(wallet_ids, str):
wallet_ids = [wallet_ids]
print(wallet_ids)
q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM diagonalley.zones WHERE wallet IN ({q})", (*wallet_ids,)
)
for r in rows:
try:
x = httpx.get(r["zoneaddress"] + "/" + r["ratingkey"])
if x.status_code == 200:
await db.execute(
"UPDATE diagonalley.zones SET online = ? WHERE id = ?",
(
True,
r["id"],
),
)
else:
await db.execute(
"UPDATE diagonalley.zones SET online = ? WHERE id = ?",
(
False,
r["id"],
),
)
except:
print("An exception occurred")
q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM diagonalley.zones WHERE wallet IN ({q})", (*wallet_ids,)
)
async def get_diagonalley_zones(user: str) -> List[Zones]:
rows = await db.fetchall("SELECT * FROM diagonalley.zones WHERE user = ?", (user,))
return [Zones(**row) for row in rows]
@ -217,7 +168,7 @@ async def create_diagonalley_stall(
data.publickey,
data.privatekey,
data.relays,
data.shippingzones),
repr(data.shippingzones)),
)
stall = await get_diagonalley_stall(stall_id)
@ -238,32 +189,6 @@ async def update_diagonalley_stall(stall_id: str, **kwargs) -> Optional[Stalls]:
async def get_diagonalley_stall(stall_id: str) -> Optional[Stalls]:
roww = await db.fetchone(
"SELECT * FROM diagonalley.stalls WHERE id = ?", (stall_id,)
)
try:
x = httpx.get(roww["stalladdress"] + "/" + roww["ratingkey"])
if x.status_code == 200:
await db.execute(
"UPDATE diagonalley.stalls SET online = ? WHERE id = ?",
(
True,
stall_id,
),
)
else:
await db.execute(
"UPDATE diagonalley.stalls SET online = ? WHERE id = ?",
(
False,
stall_id,
),
)
except:
print("An exception occurred")
# with open_ext_db("diagonalley") as db:
row = await db.fetchone(
"SELECT * FROM diagonalley.stalls WHERE id = ?", (stall_id,)
)
@ -271,35 +196,6 @@ async def get_diagonalley_stall(stall_id: str) -> Optional[Stalls]:
async def get_diagonalley_stalls(wallet_ids: Union[str, List[str]]) -> List[Stalls]:
if isinstance(wallet_ids, str):
wallet_ids = [wallet_ids]
q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM diagonalley.stalls WHERE wallet IN ({q})", (*wallet_ids,)
)
for r in rows:
try:
x = httpx.get(r["stalladdress"] + "/" + r["ratingkey"])
if x.status_code == 200:
await db.execute(
"UPDATE diagonalley.stalls SET online = ? WHERE id = ?",
(
True,
r["id"],
),
)
else:
await db.execute(
"UPDATE diagonalley.stalls SET online = ? WHERE id = ?",
(
False,
r["id"],
),
)
except:
print("An exception occurred")
q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM diagonalley.stalls WHERE wallet IN ({q})", (*wallet_ids,)

View file

@ -28,7 +28,8 @@ async def m001_initial(db):
name TEXT NOT NULL,
publickey TEXT NOT NULL,
privatekey TEXT NOT NULL,
relays TEXT NOT NULL
relays TEXT NOT NULL,
shippingzones TEXT NOT NULL
);
"""
)
@ -40,7 +41,7 @@ async def m001_initial(db):
"""
CREATE TABLE diagonalley.zones (
id TEXT PRIMARY KEY,
wallet TEXT NOT NULL,
user TEXT NOT NULL,
cost TEXT NOT NULL,
countries TEXT NOT NULL
);
@ -55,7 +56,8 @@ async def m001_initial(db):
CREATE TABLE diagonalley.orders (
id TEXT PRIMARY KEY,
productid TEXT NOT NULL,
wallet TEXT NOT NULL,
usr TEXT NOT NULL,
pubkey TEXT NOT NULL,
product TEXT NOT NULL,
quantity INTEGER NOT NULL,
shippingzone INTEGER NOT NULL,

View file

@ -49,13 +49,13 @@ class Products(BaseModel):
quantity: int
class createZones(BaseModel):
cost: str = Query(None)
cost: int = Query(0, ge=0)
countries: str = Query(None)
class Zones(BaseModel):
id: str
wallet: str
cost: str
user: str
cost: int
countries: str
@ -73,6 +73,7 @@ class Orders(BaseModel):
id: str
productid: str
stall: str
pubkey: str
product: str
quantity: int
shippingzone: int

View file

@ -1,853 +0,0 @@
/* globals Quasar, Vue, _, VueQrcode, windowMixin, LNbits, LOCALE */
Vue.component(VueQrcode.name, VueQrcode)
//const pica = window.pica()
var mapStalls = obj => {
obj._data = _.clone(obj)
return obj
}
var mapProducts = obj => {
obj._data = _.clone(obj)
return obj
}
var mapZone = obj => {
obj._data = _.clone(obj)
return obj
}
var mapOrders = obj => {
obj._data = _.clone(obj)
return obj
}
new Vue({
el: '#vue',
mixins: [windowMixin],
data: function () {
return {
products: [],
orders: [],
stalls: [],
zones: [],
customerKeys: [],
customerKey: '',
customerMessages: {},
shippedModel: false,
shippingZoneOptions: [
'Australia',
'Austria',
'Belgium',
'Brazil',
'Canada',
'Denmark',
'Finland',
'France*',
'Germany',
'Greece',
'Hong Kong',
'Hungary',
'Ireland',
'Indonesia',
'Israel',
'Italy',
'Japan',
'Kazakhstan',
'Korea',
'Luxembourg',
'Malaysia',
'Mexico',
'Netherlands',
'New Zealand',
'Norway',
'Poland',
'Portugal',
'Russia',
'Saudi Arabia',
'Singapore',
'Spain',
'Sweden',
'Switzerland',
'Thailand',
'Turkey',
'Ukraine',
'United Kingdom**',
'United States***',
'Vietnam',
'China'
],
categories: [
'Fashion (clothing and accessories)',
'Health (and beauty)',
'Toys (and baby equipment)',
'Media (Books and CDs)',
'Groceries (Food and Drink)',
'Technology (Phones and Computers)',
'Home (furniture and accessories)',
'Gifts (flowers, cards, etc)',
'Adult'
],
relayOptions: [
'wss://nostr-relay.herokuapp.com/ws',
'wss://nostr-relay.bigsun.xyz/ws',
'wss://freedom-relay.herokuapp.com/ws'
],
label: '',
ordersTable: {
columns: [
{
name: 'product',
align: 'left',
label: 'Product',
field: 'product'
},
{
name: 'quantity',
align: 'left',
label: 'Quantity',
field: 'quantity'
},
{
name: 'address',
align: 'left',
label: 'Address',
field: 'address'
},
{
name: 'invoiceid',
align: 'left',
label: 'InvoiceID',
field: 'invoiceid'
},
{name: 'paid', align: 'left', label: 'Paid', field: 'paid'},
{name: 'shipped', align: 'left', label: 'Shipped', field: 'shipped'}
],
pagination: {
rowsPerPage: 10
}
},
productsTable: {
columns: [
{
name: 'stall',
align: 'left',
label: 'Stall',
field: 'stall'
},
{
name: 'product',
align: 'left',
label: 'Product',
field: 'product'
},
{
name: 'description',
align: 'left',
label: 'Description',
field: 'description'
},
{
name: 'categories',
align: 'left',
label: 'Categories',
field: 'categories'
},
{name: 'price', align: 'left', label: 'Price', field: 'price'},
{
name: 'quantity',
align: 'left',
label: 'Quantity',
field: 'quantity'
},
{name: 'id', align: 'left', label: 'ID', field: 'id'}
],
pagination: {
rowsPerPage: 10
}
},
stallTable: {
columns: [
{
name: 'id',
align: 'left',
label: 'ID',
field: 'id'
},
{
name: 'name',
align: 'left',
label: 'Name',
field: 'name'
},
{
name: 'wallet',
align: 'left',
label: 'Wallet',
field: 'wallet'
},
{
name: 'publickey',
align: 'left',
label: 'Public key',
field: 'publickey'
},
{
name: 'privatekey',
align: 'left',
label: 'Private key',
field: 'privatekey'
}
],
pagination: {
rowsPerPage: 10
}
},
zonesTable: {
columns: [
{
name: 'id',
align: 'left',
label: 'ID',
field: 'id'
},
{
name: 'countries',
align: 'left',
label: 'Countries',
field: 'countries'
},
{
name: 'cost',
align: 'left',
label: 'Cost',
field: 'cost'
}
],
pagination: {
rowsPerPage: 10
}
},
productDialog: {
show: false,
data: {}
},
stallDialog: {
show: false,
data: {}
},
zoneDialog: {
show: false,
data: {}
},
shopDialog: {
show: false,
data: {activate: false}
},
orderDialog: {
show: false,
data: {}
},
relayDialog: {
show: false,
data: {}
}
}
},
computed: {
categoryOther: function () {
cats = trim(this.productDialog.data.categories.split(','))
for (let i = 0; i < cats.length; i++) {
if (cats[i] == 'Others') {
return true
}
}
return false
}
},
methods: {
errorMessage: function (error) {
this.$q.notify({
color: 'primary',
message: error
})
},
////////////////////////////////////////
///////////SUPPORT MESSAGES/////////////
////////////////////////////////////////
getMessages: function (customerKey) {
var self = this
console.log('fuck')
messages = []
messages.push(['in', 'blah blah'])
messages.push(['out', 'blah blah'])
self.customerMessages = messages
},
////////////////////////////////////////
////////////////STALLS//////////////////
////////////////////////////////////////
getStalls: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/stalls?all_wallets',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.stalls.push(mapStalls(response.data))
})
},
openStallUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.stalls, {id: linkId})
this.stallDialog.data = _.clone(link._data)
this.stallDialog.show = true
},
sendStallFormData: function () {
if (this.stallDialog.data.id) {
} else {
var data = {
name: this.stallDialog.data.name,
wallet: this.stallDialog.data.wallet,
publickey: this.stallDialog.data.publickey,
privatekey: this.stallDialog.data.privatekey,
relays: this.stallDialog.data.relays
}
}
if (this.stallDialog.data.id) {
this.updateStall(this.stallDialog.data)
} else {
this.createStall(data)
}
},
updateStall: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/stalls' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.stallDialog.data.wallet
}).inkey,
_.pick(data, 'name', 'wallet', 'publickey', 'privatekey')
)
.then(function (response) {
self.stalls = _.reject(self.stalls, function (obj) {
return obj.id == data.id
})
self.stalls.push(mapStalls(response.data))
self.stallDialog.show = false
self.stallDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createStall: function (data) {
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/stalls',
_.findWhere(self.g.user.wallets, {
id: self.stallDialog.data.wallet
}).inkey,
data
)
.then(function (response) {
self.stalls.push(mapStalls(response.data))
self.stallDialog.show = false
self.stallDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteStall: function (stallId) {
var self = this
var stall = _.findWhere(self.stalls, {id: stallId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this Stall link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/stalls/' + stallId,
_.findWhere(self.g.user.wallets, {id: stall.wallet}).inkey
)
.then(function (response) {
self.stalls = _.reject(self.stalls, function (obj) {
return obj.id == stallId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportStallsCSV: function () {
LNbits.utils.exportCSV(this.stallsTable.columns, this.stalls)
},
////////////////////////////////////////
///////////////PRODUCTS/////////////////
////////////////////////////////////////
getProducts: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/products?all_stalls',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.products.push(mapProducts(response.data))
})
},
openProductUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.products, {id: linkId})
self.productDialog.data = _.clone(link._data)
self.productDialog.show = true
},
sendProductFormData: function () {
if (this.productDialog.data.id) {
} else {
var data = {
product: this.productDialog.data.product,
categories:
this.productDialog.data.categories +
this.productDialog.categoriesextra,
description: this.productDialog.data.description,
image: this.productDialog.data.image,
price: this.productDialog.data.price,
quantity: this.productDialog.data.quantity
}
}
if (this.productDialog.data.id) {
this.updateProduct(this.productDialog.data)
} else {
this.createProduct(data)
}
},
imageAdded(file) {
let blobURL = URL.createObjectURL(file)
let image = new Image()
image.src = blobURL
image.onload = async () => {
let canvas = document.createElement('canvas')
canvas.setAttribute('width', 100)
canvas.setAttribute('height', 100)
await pica.resize(image, canvas, {
quality: 0,
alpha: true,
unsharpAmount: 95,
unsharpRadius: 0.9,
unsharpThreshold: 70
})
this.productDialog.data.image = canvas.toDataURL()
this.productDialog = {...this.productDialog}
}
},
imageCleared() {
this.productDialog.data.image = null
this.productDialog = {...this.productDialog}
},
updateProduct: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/products' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.productDialog.data.wallet
}).inkey,
_.pick(
data,
'shopname',
'relayaddress',
'shippingzone1',
'zone1cost',
'shippingzone2',
'zone2cost',
'email'
)
)
.then(function (response) {
self.products = _.reject(self.products, function (obj) {
return obj.id == data.id
})
self.products.push(mapProducts(response.data))
self.productDialog.show = false
self.productDialog.data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createProduct: function (data) {
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/products',
_.findWhere(self.g.user.wallets, {
id: self.productDialog.data.wallet
}).inkey,
data
)
.then(function (response) {
self.products.push(mapProducts(response.data))
self.productDialog.show = false
self.productDialog.data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteProduct: function (productId) {
var self = this
var product = _.findWhere(this.products, {id: productId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this products link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/products/' + productId,
_.findWhere(self.g.user.wallets, {id: product.wallet}).inkey
)
.then(function (response) {
self.products = _.reject(self.products, function (obj) {
return obj.id == productId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportProductsCSV: function () {
LNbits.utils.exportCSV(this.productsTable.columns, this.products)
},
////////////////////////////////////////
//////////////////ZONE//////////////////
////////////////////////////////////////
getZones: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/zones?all_wallets',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.zones.push(mapZone(response.data))
})
},
openZoneUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.zones, {id: linkId})
this.zoneDialog.data = _.clone(link._data)
this.zoneDialog.show = true
},
sendZoneFormData: function () {
if (this.zoneDialog.data.id) {
} else {
var data = {
countries: toString(this.zoneDialog.data.countries),
cost: parseInt(this.zoneDialog.data.cost)
}
}
if (this.zoneDialog.data.id) {
this.updateZone(this.zoneDialog.data)
} else {
this.createZone(data)
}
},
updateZone: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/zones' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.zoneDialog.data.wallet
}).inkey,
_.pick(data, 'countries', 'cost')
)
.then(function (response) {
self.zones = _.reject(self.zones, function (obj) {
return obj.id == data.id
})
self.zones.push(mapZone(response.data))
self.zoneDialog.show = false
self.zoneDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createZone: function (data) {
var self = this
console.log(self.g.user.wallets[0])
console.log(data)
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/zones',
self.g.user.wallets[0].inkey,
data
)
.then(function (response) {
self.zones.push(mapZone(response.data))
self.zoneDialog.show = false
self.zoneDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteZone: function (zoneId) {
var self = this
var zone = _.findWhere(self.zones, {id: zoneId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this Zone link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/zones/' + zoneId,
_.findWhere(self.g.user.wallets, {id: zone.wallet}).inkey
)
.then(function (response) {
self.zones = _.reject(self.zones, function (obj) {
return obj.id == zoneId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportZonesCSV: function () {
LNbits.utils.exportCSV(this.zonesTable.columns, this.zones)
},
////////////////////////////////////////
//////////////////SHOP//////////////////
////////////////////////////////////////
getShops: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/shops?all_wallets',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.shops.push(mapShops(response.data))
})
},
openShopUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.shops, {id: linkId})
this.shopDialog.data = _.clone(link._data)
this.shopDialog.show = true
},
sendShopFormData: function () {
if (this.shopDialog.data.id) {
} else {
var data = {
countries: this.shopDialog.data.countries,
cost: this.shopDialog.data.cost
}
}
if (this.shopDialog.data.id) {
this.updateZone(this.shopDialog.data)
} else {
this.createZone(data)
}
},
updateShop: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/shops' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.shopDialog.data.wallet
}).inkey,
_.pick(data, 'countries', 'cost')
)
.then(function (response) {
self.shops = _.reject(self.shops, function (obj) {
return obj.id == data.id
})
self.shops.push(mapShops(response.data))
self.shopDialog.show = false
self.shopDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createShop: function (data) {
var self = this
console.log('cuntywoo')
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/shops',
_.findWhere(self.g.user.wallets, {
id: self.shopDialog.data.wallet
}).inkey,
data
)
.then(function (response) {
self.shops.push(mapShops(response.data))
self.shopDialog.show = false
self.shopDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteShop: function (shopId) {
var self = this
var shop = _.findWhere(self.shops, {id: shopId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this Shop link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/shops/' + shopId,
_.findWhere(self.g.user.wallets, {id: shop.wallet}).inkey
)
.then(function (response) {
self.shops = _.reject(self.shops, function (obj) {
return obj.id == shopId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportShopsCSV: function () {
LNbits.utils.exportCSV(this.shopsTable.columns, this.shops)
},
////////////////////////////////////////
////////////////ORDERS//////////////////
////////////////////////////////////////
getOrders: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/orders?all_wallets',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.orders.push(mapOrders(response.data))
})
},
createOrder: function () {
var data = {
address: this.orderDialog.data.address,
email: this.orderDialog.data.email,
quantity: this.orderDialog.data.quantity,
shippingzone: this.orderDialog.data.shippingzone
}
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/orders',
_.findWhere(self.g.user.wallets, {id: self.orderDialog.data.wallet})
.inkey,
data
)
.then(function (response) {
self.orders.push(mapOrders(response.data))
self.orderDialog.show = false
self.orderDialog.data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteOrder: function (orderId) {
var self = this
var order = _.findWhere(self.orders, {id: orderId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this order link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/orders/' + orderId,
_.findWhere(self.g.user.wallets, {id: order.wallet}).inkey
)
.then(function (response) {
self.orders = _.reject(self.orders, function (obj) {
return obj.id == orderId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
shipOrder: function (order_id) {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/orders/shipped/' + order_id,
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.orders.push(mapOrders(response.data))
})
},
exportOrdersCSV: function () {
LNbits.utils.exportCSV(this.ordersTable.columns, this.orders)
}
},
created: function () {
if (this.g.user.wallets.length) {
this.getStalls()
this.getProducts()
this.getZones()
this.getOrders()
this.customerKeys = [
'cb4c0164fe03fcdadcbfb4f76611c71620790944c24f21a1cd119395cdedfe1b',
'a9c17358a6dc4ceb3bb4d883eb87967a66b3453a0f3199f0b1c8eef8070c6a07'
]
}
}
})

View file

@ -300,8 +300,9 @@
<div class="col-12 col-md-8 col-lg-7 q-gutter-y-md">
<q-card>
<q-card-section>
<q-btn unelevated v-if="stalls.length === 0" color="primary" @click="productDialog.show = true"
>+ Product <q-tooltip> List a product </q-tooltip></q-btn
<q-btn unelevated v-if="stalls.length === 1" color="primary" @click="productDialog.show = true"
>+ Product <q-tooltip> List a produc </q-tooltip></q-btn
>
<q-btn unelevated v-else color="primary" @click="errorMessage('First set shipping zone(s), then create a stall.')"
>+ Product <q-tooltip> List a product </q-tooltip></q-btn
@ -309,7 +310,7 @@
<q-btn unelevated color="primary" @click="zoneDialog.show = true"
>+ Shipping Zone<q-tooltip> Create a shipping zone </q-tooltip></q-btn
>
<q-btn unelevated v-if="zones.length === 0" color="primary" @click="stallDialog.show = true"
<q-btn unelevated v-if="zones.length === 1" color="primary" @click="stallDialog.show = true"
>+ Stall
<q-tooltip> Create a stall to list products on </q-tooltip></q-btn
>
@ -321,6 +322,7 @@
>Launch frontend shop (not Nostr)
<q-tooltip> Makes a simple frontend shop for your stalls</q-tooltip></q-btn
>
</q-card-section>
</q-card>
@ -638,7 +640,890 @@
</div>
</div>
</div>
</div>
{% endblock %} {% block scripts %} {{ window_vars(user) }}
<script src="https://cdn.jsdelivr.net/npm/pica@6.1.1/dist/pica.min.js"></script>
<script src="/diagonalley/static/js/index.js"></script>
<script>
Vue.component(VueQrcode.name, VueQrcode)
//const pica = window.pica()
var mapStalls = obj => {
obj._data = _.clone(obj)
return obj
}
var mapProducts = obj => {
obj._data = _.clone(obj)
return obj
}
var mapZone = obj => {
obj._data = _.clone(obj)
return obj
}
var mapOrders = obj => {
obj._data = _.clone(obj)
return obj
}
new Vue({
el: '#vue',
mixins: [windowMixin],
data: function () {
return {
products: [],
orders: [],
stalls: [],
zones: [],
customerKeys: [],
customerKey: '',
customerMessages: {},
shippedModel: false,
shippingZoneOptions: [
'Australia',
'Austria',
'Belgium',
'Brazil',
'Canada',
'Denmark',
'Finland',
'France',
'Germany',
'Greece',
'Hong Kong',
'Hungary',
'Ireland',
'Indonesia',
'Israel',
'Italy',
'Japan',
'Kazakhstan',
'Korea',
'Luxembourg',
'Malaysia',
'Mexico',
'Netherlands',
'New Zealand',
'Norway',
'Poland',
'Portugal',
'Russia',
'Saudi Arabia',
'Singapore',
'Spain',
'Sweden',
'Switzerland',
'Thailand',
'Turkey',
'Ukraine',
'United Kingdom**',
'United States***',
'Vietnam',
'China'
],
categories: [
'Fashion (clothing and accessories)',
'Health (and beauty)',
'Toys (and baby equipment)',
'Media (Books and CDs)',
'Groceries (Food and Drink)',
'Technology (Phones and Computers)',
'Home (furniture and accessories)',
'Gifts (flowers, cards, etc)',
'Adult'
],
relayOptions: [
'wss://nostr-relay.herokuapp.com/ws',
'wss://nostr-relay.bigsun.xyz/ws',
'wss://freedom-relay.herokuapp.com/ws'
],
label: '',
ordersTable: {
columns: [
{
name: 'product',
align: 'left',
label: 'Product',
field: 'product'
},
{
name: 'quantity',
align: 'left',
label: 'Quantity',
field: 'quantity'
},
{
name: 'address',
align: 'left',
label: 'Address',
field: 'address'
},
{
name: 'invoiceid',
align: 'left',
label: 'InvoiceID',
field: 'invoiceid'
},
{name: 'paid', align: 'left', label: 'Paid', field: 'paid'},
{name: 'shipped', align: 'left', label: 'Shipped', field: 'shipped'}
],
pagination: {
rowsPerPage: 10
}
},
productsTable: {
columns: [
{
name: 'stall',
align: 'left',
label: 'Stall',
field: 'stall'
},
{
name: 'product',
align: 'left',
label: 'Product',
field: 'product'
},
{
name: 'description',
align: 'left',
label: 'Description',
field: 'description'
},
{
name: 'categories',
align: 'left',
label: 'Categories',
field: 'categories'
},
{name: 'price', align: 'left', label: 'Price', field: 'price'},
{
name: 'quantity',
align: 'left',
label: 'Quantity',
field: 'quantity'
},
{name: 'id', align: 'left', label: 'ID', field: 'id'}
],
pagination: {
rowsPerPage: 10
}
},
stallTable: {
columns: [
{
name: 'id',
align: 'left',
label: 'ID',
field: 'id'
},
{
name: 'name',
align: 'left',
label: 'Name',
field: 'name'
},
{
name: 'wallet',
align: 'left',
label: 'Wallet',
field: 'wallet'
},
{
name: 'publickey',
align: 'left',
label: 'Public key',
field: 'publickey'
},
{
name: 'privatekey',
align: 'left',
label: 'Private key',
field: 'privatekey'
}
],
pagination: {
rowsPerPage: 10
}
},
zonesTable: {
columns: [
{
name: 'id',
align: 'left',
label: 'ID',
field: 'id'
},
{
name: 'countries',
align: 'left',
label: 'Countries',
field: 'countries'
},
{
name: 'cost',
align: 'left',
label: 'Cost',
field: 'cost'
}
],
pagination: {
rowsPerPage: 10
}
},
productDialog: {
show: false,
data: {}
},
stallDialog: {
show: false,
data: {}
},
zoneDialog: {
show: false,
data: {countries:[]}
},
shopDialog: {
show: false,
data: {activate: false}
},
orderDialog: {
show: false,
data: {}
},
relayDialog: {
show: false,
data: {}
}
}
},
computed: {
categoryOther: function () {
cats = trim(this.productDialog.data.categories.split(','))
for (let i = 0; i < cats.length; i++) {
if (cats[i] == 'Others') {
return true
}
}
return false
}
},
methods: {
capitalizeFirstLetter: function (string) {
return string.charAt(0).toUpperCase() + string.slice(1);
},
errorMessage: function (error) {
this.$q.notify({
color: 'primary',
message: error
})
},
////////////////////////////////////////
///////////SUPPORT MESSAGES/////////////
////////////////////////////////////////
getMessages: function (customerKey) {
var self = this
messages = []
messages.push(['in', 'blah blah'])
messages.push(['out', 'blah blah'])
self.customerMessages = messages
},
////////////////////////////////////////
////////////////STALLS//////////////////
////////////////////////////////////////
getStalls: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/stalls?all_wallets',
self.g.user.wallets[0].adminkey
)
.then(function (response) {
if (response.data) {
self.stalls = response.data.map(mapStalls)
}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
openStallUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.stalls, {id: linkId})
this.stallDialog.data = _.clone(link._data)
this.stallDialog.show = true
},
sendStallFormData: function () {
if (this.stallDialog.data.id) {
} else {
var data = {
name: this.stallDialog.data.name,
wallet: this.stallDialog.data.wallet,
publickey: this.stallDialog.data.publickey,
privatekey: this.stallDialog.data.privatekey,
relays: this.stallDialog.data.relays
}
}
if (this.stallDialog.data.id) {
this.updateStall(this.stallDialog.data)
} else {
this.createStall(data)
}
},
updateStall: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/stalls' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.stallDialog.data.wallet
}).inkey,
_.pick(data, 'name', 'wallet', 'publickey', 'privatekey')
)
.then(function (response) {
self.stalls = _.reject(self.stalls, function (obj) {
return obj.id == data.id
})
self.stalls.push(mapStalls(response.data))
self.stallDialog.show = false
self.stallDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createStall: function (data) {
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/stalls',
_.findWhere(self.g.user.wallets, {
id: self.stallDialog.data.wallet
}).inkey,
data
)
.then(function (response) {
self.stalls.push(mapStalls(response.data))
self.stallDialog.show = false
self.stallDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteStall: function (stallId) {
var self = this
var stall = _.findWhere(self.stalls, {id: stallId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this Stall link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/stalls/' + stallId,
_.findWhere(self.g.user.wallets, {id: stall.wallet}).inkey
)
.then(function (response) {
self.stalls = _.reject(self.stalls, function (obj) {
return obj.id == stallId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportStallsCSV: function () {
LNbits.utils.exportCSV(this.stallsTable.columns, this.stalls)
},
////////////////////////////////////////
///////////////PRODUCTS/////////////////
////////////////////////////////////////
getProducts: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/products?all_stalls',
self.g.user.wallets[0].inkey
)
.then(function (response) {
if (response.data) {
self.products = response.data.map(mapProducts)
}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
openProductUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.products, {id: linkId})
self.productDialog.data = _.clone(link._data)
self.productDialog.show = true
},
sendProductFormData: function () {
if (this.productDialog.data.id) {
} else {
var data = {
product: this.productDialog.data.product,
categories:
this.productDialog.data.categories +
this.productDialog.categoriesextra,
description: this.productDialog.data.description,
image: this.productDialog.data.image,
price: this.productDialog.data.price,
quantity: this.productDialog.data.quantity
}
}
if (this.productDialog.data.id) {
this.updateProduct(this.productDialog.data)
} else {
this.createProduct(data)
}
},
imageAdded(file) {
let blobURL = URL.createObjectURL(file)
let image = new Image()
image.src = blobURL
image.onload = async () => {
let canvas = document.createElement('canvas')
canvas.setAttribute('width', 100)
canvas.setAttribute('height', 100)
await pica.resize(image, canvas, {
quality: 0,
alpha: true,
unsharpAmount: 95,
unsharpRadius: 0.9,
unsharpThreshold: 70
})
this.productDialog.data.image = canvas.toDataURL()
this.productDialog = {...this.productDialog}
}
},
imageCleared() {
this.productDialog.data.image = null
this.productDialog = {...this.productDialog}
},
updateProduct: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/products' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.productDialog.data.wallet
}).inkey,
_.pick(
data,
'shopname',
'relayaddress',
'shippingzone1',
'zone1cost',
'shippingzone2',
'zone2cost',
'email'
)
)
.then(function (response) {
self.products = _.reject(self.products, function (obj) {
return obj.id == data.id
})
self.products.push(mapProducts(response.data))
self.productDialog.show = false
self.productDialog.data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createProduct: function (data) {
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/products',
_.findWhere(self.g.user.wallets, {
id: self.productDialog.data.wallet
}).inkey,
data
)
.then(function (response) {
self.products.push(mapProducts(response.data))
self.productDialog.show = false
self.productDialog.data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteProduct: function (productId) {
var self = this
var product = _.findWhere(this.products, {id: productId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this products link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/products/' + productId,
_.findWhere(self.g.user.wallets, {id: product.wallet}).inkey
)
.then(function (response) {
self.products = _.reject(self.products, function (obj) {
return obj.id == productId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportProductsCSV: function () {
LNbits.utils.exportCSV(this.productsTable.columns, this.products)
},
////////////////////////////////////////
//////////////////ZONE//////////////////
////////////////////////////////////////
getZones: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/zones',
this.g.user.wallets[0].inkey
)
.then(function (response) {
if (response.data) {
console.log(response)
self.zones = response.data.map(mapZone)
}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
openZoneUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.zones, {id: linkId})
countriesArray = link._data.countries.split(",")
for (let i = 0; i < countriesArray.length; i++) {
countriesArray[i] = self.capitalizeFirstLetter(countriesArray[i])
}
link._data.countries = countriesArray
this.zoneDialog.data = _.clone(link._data)
this.zoneDialog.show = true
},
sendZoneFormData: function () {
var data = {
countries: String(this.zoneDialog.data.countries),
cost: parseInt(this.zoneDialog.data.cost)
}
if (this.zoneDialog.data.id) {
data.id = this.zoneDialog.data.id
this.updateZone(data)
} else {
this.createZone(data)
}
},
updateZone: function (data) {
console.log(data)
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/zones/' + data.id,
self.g.user.wallets[0].adminkey,
data
)
.then(function (response) {
console.log(response)
self.zones = _.reject(self.zones, function (obj) {
return obj.id == data.id
})
self.zones.push(mapZone(response.data))
self.zoneDialog.show = false
self.zoneDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createZone: function (data) {
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/zones',
self.g.user.wallets[0].inkey,
data
)
.then(function (response) {
self.zones.push(mapZone(response.data))
self.zoneDialog.show = false
self.zoneDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteZone: function (zoneId) {
var self = this
var zone = _.findWhere(self.zones, {id: zoneId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this Zone link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/zones/' + zoneId,
self.g.user.wallets[0].adminkey
)
.then(function (response) {
self.zones = _.reject(self.zones, function (obj) {
return obj.id == zoneId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportZonesCSV: function () {
LNbits.utils.exportCSV(this.zonesTable.columns, this.zones)
},
////////////////////////////////////////
//////////////////SHOP//////////////////
////////////////////////////////////////
getShops: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/shops?all_wallets',
this.g.user.wallets[0].inkey
)
.then(function (response) {
if (response.data) {
self.shops = response.data.map(mapShops)
}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
openShopUpdateDialog: function (linkId) {
var self = this
var link = _.findWhere(self.shops, {id: linkId})
this.shopDialog.data = _.clone(link._data)
this.shopDialog.show = true
},
sendShopFormData: function () {
if (this.shopDialog.data.id) {
} else {
var data = {
countries: this.shopDialog.data.countries,
cost: this.shopDialog.data.cost
}
}
if (this.shopDialog.data.id) {
this.updateZone(this.shopDialog.data)
} else {
this.createZone(data)
}
},
updateShop: function (data) {
var self = this
LNbits.api
.request(
'PUT',
'/diagonalley/api/v1/shops' + data.id,
_.findWhere(self.g.user.wallets, {
id: self.shopDialog.data.wallet
}).inkey,
_.pick(data, 'countries', 'cost')
)
.then(function (response) {
self.shops = _.reject(self.shops, function (obj) {
return obj.id == data.id
})
self.shops.push(mapShops(response.data))
self.shopDialog.show = false
self.shopDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createShop: function (data) {
var self = this
console.log('cuntywoo')
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/shops',
_.findWhere(self.g.user.wallets, {
id: self.shopDialog.data.wallet
}).inkey,
data
)
.then(function (response) {
self.shops.push(mapShops(response.data))
self.shopDialog.show = false
self.shopDialog.data = {}
data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteShop: function (shopId) {
var self = this
var shop = _.findWhere(self.shops, {id: shopId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this Shop link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/shops/' + shopId,
_.findWhere(self.g.user.wallets, {id: shop.wallet}).inkey
)
.then(function (response) {
self.shops = _.reject(self.shops, function (obj) {
return obj.id == shopId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
exportShopsCSV: function () {
LNbits.utils.exportCSV(this.shopsTable.columns, this.shops)
},
////////////////////////////////////////
////////////////ORDERS//////////////////
////////////////////////////////////////
getOrders: function () {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/orders?all_wallets',
this.g.user.wallets[0].inkey
)
.then(function (response) {
if (response.data) {
self.orders = response.data.map(mapOrders)
}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
createOrder: function () {
var data = {
address: this.orderDialog.data.address,
email: this.orderDialog.data.email,
quantity: this.orderDialog.data.quantity,
shippingzone: this.orderDialog.data.shippingzone
}
var self = this
LNbits.api
.request(
'POST',
'/diagonalley/api/v1/orders',
_.findWhere(self.g.user.wallets, {id: self.orderDialog.data.wallet})
.inkey,
data
)
.then(function (response) {
self.orders.push(mapOrders(response.data))
self.orderDialog.show = false
self.orderDialog.data = {}
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
deleteOrder: function (orderId) {
var self = this
var order = _.findWhere(self.orders, {id: orderId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this order link?')
.onOk(function () {
LNbits.api
.request(
'DELETE',
'/diagonalley/api/v1/orders/' + orderId,
_.findWhere(self.g.user.wallets, {id: order.wallet}).inkey
)
.then(function (response) {
self.orders = _.reject(self.orders, function (obj) {
return obj.id == orderId
})
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
})
},
shipOrder: function (order_id) {
var self = this
LNbits.api
.request(
'GET',
'/diagonalley/api/v1/orders/shipped/' + order_id,
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.orders.push(mapOrders(response.data))
})
},
exportOrdersCSV: function () {
LNbits.utils.exportCSV(this.ordersTable.columns, this.orders)
}
},
created: function () {
if (this.g.user.wallets.length) {
this.getStalls()
this.getProducts()
this.getZones()
this.getOrders()
this.customerKeys = [
'cb4c0164fe03fcdadcbfb4f76611c71620790944c24f21a1cd119395cdedfe1b',
'a9c17358a6dc4ceb3bb4d883eb87967a66b3453a0f3199f0b1c8eef8070c6a07'
]
console.log(this.products.length)
}
}
})
</script>
{% endblock %}

View file

@ -121,36 +121,32 @@ async def api_diagonalley_products_delete(product_id, wallet: WalletTypeInfo = D
@diagonalley_ext.get("/api/v1/zones")
async def api_diagonalley_zones(wallet: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = Query(False)):
wallet_ids = [wallet.wallet.id]
async def api_diagonalley_zones(wallet: WalletTypeInfo = Depends(get_key_type)):
if all_wallets:
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
return ([zone.dict() for zone in await get_diagonalley_zones(wallet_ids)])
return await get_diagonalley_zones(wallet.wallet.user)
@diagonalley_ext.post("/api/v1/zones")
@diagonalley_ext.put("/api/v1/zones/{zone_id}")
async def api_diagonalley_zone_create(
data: createZones,
zone_id: str = Query(None),
wallet: WalletTypeInfo = Depends(get_key_type)
):
if zone_id:
zone = await get_diagonalley_zone(zone_id)
if not zone:
return ({"message": "Zone does not exist."})
if zone.wallet != wallet.wallet.id:
return ({"message": "Not your record."})
zone = await update_diagonalley_zone(zone_id, **data.dict())
else:
zone = await create_diagonalley_zone(wallet=wallet.wallet.id, data=data)
zone = await create_diagonalley_zone(user=wallet.wallet.user, data=data)
return zone.dict()
@diagonalley_ext.post("/api/v1/zones/{zone_id}")
async def api_diagonalley_zone_update(
data: createZones,
zone_id: str = Query(None),
wallet: WalletTypeInfo = Depends(require_admin_key)
):
zone = await get_diagonalley_zone(zone_id)
if not zone:
return ({"message": "Zone does not exist."})
if zone.user != wallet.wallet.user:
return ({"message": "Not your record."})
zone = await update_diagonalley_zone(zone_id, **data.dict())
return zone
@diagonalley_ext.delete("/api/v1/zones/{zone_id}")
async def api_diagonalley_zone_delete(zone_id, wallet: WalletTypeInfo = Depends(require_admin_key)):
@ -159,7 +155,7 @@ async def api_diagonalley_zone_delete(zone_id, wallet: WalletTypeInfo = Depends(
if not zone:
return ({"message": "zone does not exist."})
if zone.wallet != wallet.wallet.id:
if zone.user != wallet.wallet.user:
return ({"message": "Not your zone."})
await delete_diagonalley_zone(zone_id)