Add "up to date" info to the "about" window

This commit is contained in:
Oliver Walters 2021-03-11 20:07:59 +11:00
parent 18defcff16
commit 4925f24ca9
4 changed files with 59 additions and 11 deletions

View File

@ -42,6 +42,8 @@ def health_status(request):
status['system_healthy'] = all_healthy
status['up_to_date'] = InvenTree.version.isInvenTreeUpToDate()
return status

View File

@ -25,10 +25,13 @@ def inventreeVersion():
return INVENTREE_SW_VERSION
def inventreeVersionTuple():
def inventreeVersionTuple(version=None):
""" Return the InvenTree version string as (maj, min, sub) tuple """
match = re.match(r"^.*(\d+)\.(\d+)\.(\d+).*$", INVENTREE_SW_VERSION)
if version is None:
version = INVENTREE_SW_VERSION
match = re.match(r"^.*(\d+)\.(\d+)\.(\d+).*$", str(version))
return [int(g) for g in match.groups()]
@ -44,7 +47,30 @@ def versionTupleToInt(version):
n += version[2]
return n
def isInvenTreeUpToDate():
"""
Test if the InvenTree instance is "up to date" with the latest version.
A background task periodically queries GitHub for latest version,
and stores it to the database as INVENTREE_LATEST_VERSION
"""
latest = common.models.InvenTreeSetting.get_setting('INVENTREE_LATEST_VERSION', None)
# No record for "latest" version - we must assume we are up to date!
if not latest:
return True
# Extract "tuple" version
version = inventreeVersionTuple(latest)
version_int = versionTupleToInt(version)
inventree_int = versionTupleToInt(inventreeVersionTuple())
return inventree_int >= version_int
def inventreeApiVersion():
return INVENTREE_API_VERSION

View File

@ -19,19 +19,30 @@
<col width='25'>
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td>{% trans "InvenTree Version" %}</td><td><a href="https://github.com/inventree/InvenTree/releases">{% inventree_version %}</a></td>
<td>{% trans "InvenTree Version" %}</td>
<td>
<a href="https://github.com/inventree/InvenTree/releases">{% inventree_version %}</a>
{% if up_to_date %}
<span class='label label-green float-right'>{% trans "Up to Date" %}</span>
{% else %}
<span class='label label-red float-right'>{% trans "Update Available" %}</span>
{% endif %}
</td>
</tr>
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Django Version" %}</td><td><a href="https://www.djangoproject.com/">{% django_version %}</a></td>
<td>{% trans "Django Version" %}</td>
<td><a href="https://www.djangoproject.com/">{% django_version %}</a></td>
</tr>
<tr>
<td><span class='fas fa-code-branch'></span></td>
<td>{% trans "Commit Hash" %}</td><td><a href="https://github.com/inventree/InvenTree/commit/{% inventree_commit_hash %}">{% inventree_commit_hash %}</a></td>
<td>{% trans "Commit Hash" %}</td>
<td><a href="https://github.com/inventree/InvenTree/commit/{% inventree_commit_hash %}">{% inventree_commit_hash %}</a></td>
</tr>
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td>{% trans "Commit Date" %}</td><td>{% inventree_commit_date %}</td>
<td>{% trans "Commit Date" %}</td>
<td>{% inventree_commit_date %}</td>
</tr>
<tr>
<td><span class='fas fa-book'></span></td>

View File

@ -59,8 +59,8 @@
{% endif %}
<li class='dropdown'>
<a class='dropdown-toggle' data-toggle='dropdown' href="#">
{% if not system_healthy %}
<span title='{% trans "InvenTree server issues detected" %}' class='fas fa-exclamation-triangle icon-red'></span>
{% if not system_healthy or not up_to_date %}
<span class='fas fa-exclamation-triangle icon-red'></span>
{% endif %}
<span class="fas fa-user"></span> <b>{{ user.get_username }}</b></a>
<ul class='dropdown-menu'>
@ -78,11 +78,20 @@
{% if system_healthy %}
<span class='fas fa-server'>
{% else %}
<span class='fas fa-exclamation-triangle icon-red'>
<span class='fas fa-server icon-red'>
{% endif %}
</span> {% trans "System Information" %}
</a></li>
<li id='launch-about'><a href='#'><span class="fas fa-info-circle"></span> {% trans "About InvenTree" %}</a></li>
<li id='launch-about'>
<a href='#'>
{% if up_to_date %}
<span class="fas fa-info-circle">
{% else %}
<span class='fas fa-info-circle icon-red'>
{% endif %}
</span> {% trans "About InvenTree" %}
</a>
</li>
</ul>
</li>
</ul>