mirror of
https://github.com/lnbits/lnbits.git
synced 2025-08-03 15:32:22 +02:00
Not making db entry
This commit is contained in:
@@ -16,7 +16,7 @@ async def create_copilot(
|
||||
"""
|
||||
INSERT INTO copilot.copilots (
|
||||
id,
|
||||
"user",
|
||||
user,
|
||||
lnurl_toggle,
|
||||
wallet,
|
||||
title,
|
||||
@@ -70,21 +70,20 @@ async def update_copilot(copilot_id: str, **kwargs) -> Optional[Copilots]:
|
||||
row = await db.fetchone(
|
||||
"SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,)
|
||||
)
|
||||
return Copilots.from_row(row) if row else None
|
||||
return Copilots(**row) if row else None
|
||||
|
||||
|
||||
async def get_copilot(copilot_id: str) -> Copilots:
|
||||
row = await db.fetchone(
|
||||
"SELECT * FROM copilot.copilots WHERE id = ?", (copilot_id,)
|
||||
)
|
||||
return Copilots.from_row(row) if row else None
|
||||
return Copilots(**row) if row else None
|
||||
|
||||
|
||||
async def get_copilots(user: str) -> List[Copilots]:
|
||||
rows = await db.fetchall(
|
||||
"""SELECT * FROM copilot.copilots WHERE "user" = ?""", (user,)
|
||||
)
|
||||
return [Copilots.from_row(row) for row in rows]
|
||||
rows = await db.fetchall("SELECT * FROM copilot.copilots WHERE user = ?", (user,))
|
||||
print(user)
|
||||
return [Copilots(**row) for row in rows]
|
||||
|
||||
|
||||
async def delete_copilot(copilot_id: str) -> None:
|
||||
|
@@ -61,7 +61,6 @@
|
||||
</p>
|
||||
</q-page>
|
||||
{% endblock %} {% block scripts %}
|
||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
||||
<style>
|
||||
body.body--dark .q-drawer,
|
||||
body.body--dark .q-footer,
|
||||
|
@@ -390,6 +390,7 @@
|
||||
|
||||
var mapCopilot = obj => {
|
||||
obj._data = _.clone(obj)
|
||||
|
||||
obj.theTime = obj.time * 60 - (Date.now() / 1000 - obj.timestamp)
|
||||
obj.time = obj.time + 'mins'
|
||||
|
||||
@@ -488,6 +489,8 @@
|
||||
self.formDialogCopilot.data
|
||||
)
|
||||
} else {
|
||||
console.log(self.g.user.wallets[0].adminkey)
|
||||
console.log(self.formDialogCopilot.data)
|
||||
this.createCopilot(
|
||||
self.g.user.wallets[0].adminkey,
|
||||
self.formDialogCopilot.data
|
||||
@@ -512,6 +515,9 @@
|
||||
updatedData[property] = parseInt(data[property])
|
||||
}
|
||||
}
|
||||
console.log('updatedData')
|
||||
console.log(updatedData)
|
||||
console.log('updatedData')
|
||||
LNbits.api
|
||||
.request('POST', '/copilot/api/v1/copilot', wallet, updatedData)
|
||||
.then(function (response) {
|
||||
|
@@ -97,7 +97,6 @@
|
||||
</div>
|
||||
|
||||
{% endblock %} {% block scripts %}
|
||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
||||
<script>
|
||||
Vue.component(VueQrcode.name, VueQrcode)
|
||||
|
||||
|
@@ -42,8 +42,10 @@ async def api_copilot_create_or_update(
|
||||
copilot_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||
):
|
||||
print(data)
|
||||
if not copilot_id:
|
||||
copilot = await create_copilot(data, user=wallet.wallet.user)
|
||||
copilot = await create_copilot(data, inkey=wallet.wallet.inkey)
|
||||
|
||||
return copilot, HTTPStatus.CREATED
|
||||
else:
|
||||
copilot = await update_copilot(data, copilot_id=copilot_id)
|
||||
@@ -53,7 +55,8 @@ async def api_copilot_create_or_update(
|
||||
@copilot_ext.get("/api/v1/copilot", response_class=HTMLResponse)
|
||||
async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
try:
|
||||
return [{copilot} for copilot in await get_copilots(wallet.wallet.user)]
|
||||
print(wallet.wallet.user)
|
||||
return [copilot.dict() for copilot in await get_copilots(wallet.wallet.user)]
|
||||
except:
|
||||
return ""
|
||||
|
||||
|
Reference in New Issue
Block a user