Browse Source

Added admin "Update funds" button

adminvar
benarc 4 years ago
parent
commit
3736fbeb4b
  1. 20
      lnbits/core/templates/core/wallet.html
  2. 8
      lnbits/core/views/generic.py
  3. 1
      lnbits/settings.py

20
lnbits/core/templates/core/wallet.html

@ -20,9 +20,26 @@
<div class="col-12 col-md-7 q-gutter-y-md">
<q-card>
<q-card-section>
<div class="row q-pb-md q-px-md q-col-gutter-md">
<div class="col">
<h3 class="q-my-none">
<strong>{% raw %}{{ fbalance }}{% endraw %}</strong> sat
{% if admin %}
<q-btn
round
size="10px"
color="purple"
icon="add"
>
<q-tooltip>
Update balance
</q-tooltip>
</q-btn>
{% endif %}
</h3>
</div>
</div>
</q-card-section>
<div class="row q-pb-md q-px-md q-col-gutter-md">
<div class="col">
@ -43,6 +60,9 @@
>Receive</q-btn
>
</div>
</div>
</q-card>

8
lnbits/core/views/generic.py

@ -4,7 +4,7 @@ from os import path
from lnbits.core import core_app
from lnbits.decorators import check_user_exists, validate_uuids
from lnbits.settings import LNBITS_ALLOWED_USERS, SERVICE_FEE
from lnbits.settings import LNBITS_ALLOWED_USERS, SERVICE_FEE, LNBITS_ADMIN_USERS
from ..crud import (
create_account,
@ -50,7 +50,7 @@ def wallet():
wallet_id = request.args.get("wal", type=str)
wallet_name = request.args.get("nme", type=str)
service_fee = int(SERVICE_FEE) if int(SERVICE_FEE) == SERVICE_FEE else SERVICE_FEE
admin = False
# just wallet_name: create a new user, then create a new wallet for user with wallet_name
# just user_id: return the first user wallet or create one if none found (with default wallet_name)
# user_id and wallet_name: create a new wallet for user with wallet_name
@ -64,6 +64,8 @@ def wallet():
if LNBITS_ALLOWED_USERS and user_id not in LNBITS_ALLOWED_USERS:
abort(HTTPStatus.UNAUTHORIZED, "User not authorized.")
if LNBITS_ADMIN_USERS and user_id in LNBITS_ADMIN_USERS:
admin = True
if not wallet_id:
if user.wallets and not wallet_name:
@ -76,7 +78,7 @@ def wallet():
if wallet_id not in user.wallet_ids:
abort(HTTPStatus.FORBIDDEN, "Not your wallet.")
return render_template("core/wallet.html", user=user, wallet=user.get_wallet(wallet_id), service_fee=service_fee)
return render_template("core/wallet.html", user=user, wallet=user.get_wallet(wallet_id), service_fee=service_fee, admin=admin)
@core_app.route("/deletewallet")

1
lnbits/settings.py

@ -17,6 +17,7 @@ DEBUG = ENV == "development"
LNBITS_PATH = path.dirname(path.realpath(__file__))
LNBITS_DATA_FOLDER = env.str("LNBITS_DATA_FOLDER", default=path.join(LNBITS_PATH, "data"))
LNBITS_ALLOWED_USERS: List[str] = env.list("LNBITS_ALLOWED_USERS", default=[], subcast=str)
LNBITS_ADMIN_USERS: List[str] = env.list("LNBITS_ADMIN_USERS", default=[], subcast=str)
LNBITS_DISABLED_EXTENSIONS: List[str] = env.list("LNBITS_DISABLED_EXTENSIONS", default=[], subcast=str)
LNBITS_SITE_TITLE = env.str("LNBITS_SITE_TITLE", default="LNbits")

Loading…
Cancel
Save