show live counter of registered users

pull/83/head
Aevann 2022-12-30 15:54:49 +02:00
parent a62168a7a6
commit 7cc9170711
3 changed files with 36 additions and 1 deletions

View File

@ -74,6 +74,9 @@ def calc_users():
'loggedout_counter':loggedout_counter,
'loggedin_chat':loggedin_chat}
def current_registered_users():
return g.db.query(User).count()
@app.context_processor
def inject_constants():
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL,
@ -96,5 +99,5 @@ def inject_constants():
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":IMAGE_FORMATS,
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME,
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "HOLIDAY_EVENT":HOLIDAY_EVENT, "get_alt_graph":get_alt_graph
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "HOLIDAY_EVENT":HOLIDAY_EVENT, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users
}

View File

@ -12,6 +12,22 @@
</a>
{% endif %}
{% if v and v.admin_level %}
<a href="/admin/users">
<div class="mb-3 d-flex" style="background:none!important">
<h5 class="mx-auto">
Current registered users: {{current_registered_users()}}
</h5>
</div>
</a>
{% else %}
<div class="mb-3 d-flex" style="background:none!important">
<h5 class="mx-auto">
Current registered users: {{current_registered_users()}}
</h5>
</div>
{% endif %}
<p class="text-center text-md mb-4">
<a class="sidebar-link d-md-none" href="/random_user" data-bs-toggle="tooltip" data-bs-placement="top" title="Random User"><i class="fas fa-music"></i></a>
<a class="sidebar-link" href="/badges" data-bs-toggle="tooltip" data-bs-placement="top" title="Badges"><i class="fas fa-hexagon"></i></a>

View File

@ -8,6 +8,22 @@
{% set image = macros.random_image("assets/images/" ~ SITE_NAME ~ "/sidebar") %}
{% endif %}
{% if v and v.admin_level %}
<a href="/admin/users">
<div class="mb-3 d-flex" style="background:none!important">
<h5 class="mx-auto">
Current registered users: {{current_registered_users()}}
</h5>
</div>
</a>
{% else %}
<div class="mb-3 d-flex" style="background:none!important">
<h5 class="mx-auto">
Current registered users: {{current_registered_users()}}
</h5>
</div>
{% endif %}
{% if request.path != '/sidebar' %}
{% if v and (v.is_banned or v.agendaposter) %}
<a href="/i/{{SITE_NAME}}/sidebar2.webp">