Skip to content

Commit

Permalink
Show current server time in navbar. Refs #545, #1206
Browse files Browse the repository at this point in the history
by default Kiwi TCMS is configured for UTC time and this is
confusing some users. All timestamps are displayed according to
configured timezone.
  • Loading branch information
atodorov committed Nov 25, 2019
1 parent 401aca8 commit 710de1e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tcms/core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.utils import timezone


def request_contents_processor(request):
Expand All @@ -14,3 +15,7 @@ def settings_processor(_request):
Django settings RequestContext Handler
"""
return {'SETTINGS': settings}


def server_time_processor(_request):
return {'SERVER_TIME': timezone.now() }
1 change: 1 addition & 0 deletions tcms/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@

'tcms.core.context_processors.request_contents_processor',
'tcms.core.context_processors.settings_processor',
'tcms.core.context_processors.server_time_processor',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
Expand Down
10 changes: 10 additions & 0 deletions tcms/templates/navbar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load i18n %}
{% load static %}
{% load tz %}

<!-- PatternFly Horizontal Nav -->
<nav class="navbar navbar-default navbar-pf" role="navigation">
Expand Down Expand Up @@ -97,6 +98,15 @@
<li><a target="_parent" href="https://kiwitcms.readthedocs.io/en/latest/contribution.html#translation">{% trans "Translation guide" %}</a></li>
</ul>
</li>

<li style="float:right">
<a>
<span class="fa fa-clock-o">
{% get_current_timezone as TIME_ZONE %}
{{ SERVER_TIME }} {{ TIME_ZONE }}
</span>
</a>
</li>
</ul>

<ul class="nav navbar-nav navbar-primary">
Expand Down

0 comments on commit 710de1e

Please sign in to comment.