From d5d92ef1c2ae1e860e74cb18fc023896c212410c Mon Sep 17 00:00:00 2001 From: benarc Date: Wed, 30 Sep 2020 20:34:32 +0100 Subject: [PATCH] Extension updates admin tables --- .../admin/templates/admin/index.html | 29 ++++++++++--------- lnbits/extensions/admin/views.py | 19 ++++++++---- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lnbits/extensions/admin/templates/admin/index.html b/lnbits/extensions/admin/templates/admin/index.html index 5c07e6b..80cc7e0 100644 --- a/lnbits/extensions/admin/templates/admin/index.html +++ b/lnbits/extensions/admin/templates/admin/index.html @@ -10,7 +10,7 @@ https://quasar.dev/vue-components/form#Example--Basic -->
-
+
-
+
Wallet topup
-
+
-
+
-
+
+
-
+
@@ -547,7 +548,7 @@ if (usr != null) { self.cancel.on = true } - self.data.admin.user = '{{ admin_user }}' + self.data.admin.user = '{{ user.id }}' self.data.admin.allowed_users = '' self.data.admin.site_title = '{{admin.site_title}}' self.data.admin.tagline = '{{admin.tagline}}' @@ -688,17 +689,19 @@ LNbits.api .request('POST', '/api/v1/admin', 'wallet.inkey', data.admin.senddata) .then(function (response) { - window.location.href = '/wallet?usr=' + response.data.admin[0] + + self.$q.notify({ + type: 'positive', + message: 'Updated', + icon: 'thumb_up' + }) + }) .catch(function (error) { LNbits.utils.notifyApiError(error) }) }, - cancelAdmin: function () { - if (usr != null) { - window.location.href = '/wallet?usr=' + usr - } - }, + processing: function () { this.$q.notify({ diff --git a/lnbits/extensions/admin/views.py b/lnbits/extensions/admin/views.py index cc371ba..6671257 100644 --- a/lnbits/extensions/admin/views.py +++ b/lnbits/extensions/admin/views.py @@ -11,13 +11,20 @@ from lnbits.settings import WALLET @check_user_exists() def index(): user_id = request.args.get("usr", type=str) + print(user_id) admin = get_admin() - if admin.user != user_id: - abort(HTTPStatus.FORBIDDEN, "Admin only") + if admin != None: + if admin[0] == None: + admin_user = get_user(create_account().id).id + if admin.user != user_id: + abort(HTTPStatus.FORBIDDEN, "Admin only") + if not user_id: + admin_user = get_user(create_account().id).id + print(admin_user) + admin = get_admin() + else: + admin_user = user_id + funding = get_funding() - if admin[0] != None: - admin_user = admin[0] - if admin.user != None and admin.user != user_id: - abort(HTTPStatus.FORBIDDEN, "Admin only") return render_template("admin/index.html", user=g.user, admin=admin, funding=funding)