Notifications Widget Added

This commit is contained in:
Michatec
2025-11-23 12:58:22 +01:00
parent 3332a9ca7c
commit 1c05248829
2 changed files with 6 additions and 1 deletions

View File

@@ -44,7 +44,7 @@ def notifications_api():
{ {
'name': User.query.get(n.user_id).username, 'name': User.query.get(n.user_id).username,
'data': n.message, 'data': n.message,
'timestamp': n.created_at 'created_at': n.created_at
} for n in notifications } for n in notifications
] ]
) )

View File

@@ -102,9 +102,13 @@
{% if user.is_admin %} {% if user.is_admin %}
<p class="text-success">{{ _('You are logged in as an admin.') }}</p> <p class="text-success">{{ _('You are logged in as an admin.') }}</p>
{% endif %} {% endif %}
{% if user.is_authenticated %}
<span class="badge bg-secondary" id="check_notify">{{ _('You dont have any notifications.') }}</span>
{% endif %}
{% if SHOPITEM_ID_PREMIUM in user.shop_items | map(attribute='item_id') | list %} {% if SHOPITEM_ID_PREMIUM in user.shop_items | map(attribute='item_id') | list %}
<span class="badge bg-warning text-dark"><i class="bi bi-star"></i> Premium</span> <span class="badge bg-warning text-dark"><i class="bi bi-star"></i> Premium</span>
{% endif %} {% endif %}
<hr>
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<footer class="footer mt-auto py-3"> <footer class="footer mt-auto py-3">
@@ -121,6 +125,7 @@
<script> <script>
function set_message_count(n) { function set_message_count(n) {
$('#message_count').text(n); $('#message_count').text(n);
$('#check_notify').text('{{ _("You have ") }}' + n + '{{ _(" new notification/s") }}');
} }
{% if current_user.is_authenticated %} {% if current_user.is_authenticated %}
$(function() { $(function() {