mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 13:58:47 +00:00
Add "up to date" info to the "about" window
This commit is contained in:
parent
18defcff16
commit
4925f24ca9
@ -42,6 +42,8 @@ def health_status(request):
|
|||||||
|
|
||||||
status['system_healthy'] = all_healthy
|
status['system_healthy'] = all_healthy
|
||||||
|
|
||||||
|
status['up_to_date'] = InvenTree.version.isInvenTreeUpToDate()
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,10 +25,13 @@ def inventreeVersion():
|
|||||||
return INVENTREE_SW_VERSION
|
return INVENTREE_SW_VERSION
|
||||||
|
|
||||||
|
|
||||||
def inventreeVersionTuple():
|
def inventreeVersionTuple(version=None):
|
||||||
""" Return the InvenTree version string as (maj, min, sub) tuple """
|
""" 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()]
|
return [int(g) for g in match.groups()]
|
||||||
|
|
||||||
@ -46,6 +49,29 @@ def versionTupleToInt(version):
|
|||||||
return n
|
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():
|
def inventreeApiVersion():
|
||||||
return INVENTREE_API_VERSION
|
return INVENTREE_API_VERSION
|
||||||
|
|
||||||
|
@ -19,19 +19,30 @@
|
|||||||
<col width='25'>
|
<col width='25'>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-hashtag'></span></td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-hashtag'></span></td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-code-branch'></span></td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-calendar-alt'></span></td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-book'></span></td>
|
<td><span class='fas fa-book'></span></td>
|
||||||
|
@ -59,8 +59,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<li class='dropdown'>
|
<li class='dropdown'>
|
||||||
<a class='dropdown-toggle' data-toggle='dropdown' href="#">
|
<a class='dropdown-toggle' data-toggle='dropdown' href="#">
|
||||||
{% if not system_healthy %}
|
{% if not system_healthy or not up_to_date %}
|
||||||
<span title='{% trans "InvenTree server issues detected" %}' class='fas fa-exclamation-triangle icon-red'></span>
|
<span class='fas fa-exclamation-triangle icon-red'></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="fas fa-user"></span> <b>{{ user.get_username }}</b></a>
|
<span class="fas fa-user"></span> <b>{{ user.get_username }}</b></a>
|
||||||
<ul class='dropdown-menu'>
|
<ul class='dropdown-menu'>
|
||||||
@ -78,11 +78,20 @@
|
|||||||
{% if system_healthy %}
|
{% if system_healthy %}
|
||||||
<span class='fas fa-server'>
|
<span class='fas fa-server'>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class='fas fa-exclamation-triangle icon-red'>
|
<span class='fas fa-server icon-red'>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span> {% trans "System Information" %}
|
</span> {% trans "System Information" %}
|
||||||
</a></li>
|
</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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user