Skip to content

Commit 4925f24

Browse files
Add "up to date" info to the "about" window
1 parent 18defcf commit 4925f24

4 files changed

Lines changed: 59 additions & 11 deletions

File tree

InvenTree/InvenTree/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def health_status(request):
4242

4343
status['system_healthy'] = all_healthy
4444

45+
status['up_to_date'] = InvenTree.version.isInvenTreeUpToDate()
46+
4547
return status
4648

4749

InvenTree/InvenTree/version.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ def inventreeVersion():
2525
return INVENTREE_SW_VERSION
2626

2727

28-
def inventreeVersionTuple():
28+
def inventreeVersionTuple(version=None):
2929
""" Return the InvenTree version string as (maj, min, sub) tuple """
3030

31-
match = re.match(r"^.*(\d+)\.(\d+)\.(\d+).*$", INVENTREE_SW_VERSION)
31+
if version is None:
32+
version = INVENTREE_SW_VERSION
33+
34+
match = re.match(r"^.*(\d+)\.(\d+)\.(\d+).*$", str(version))
3235

3336
return [int(g) for g in match.groups()]
3437

@@ -44,7 +47,30 @@ def versionTupleToInt(version):
4447
n += version[2]
4548

4649
return n
47-
50+
51+
52+
def isInvenTreeUpToDate():
53+
"""
54+
Test if the InvenTree instance is "up to date" with the latest version.
55+
56+
A background task periodically queries GitHub for latest version,
57+
and stores it to the database as INVENTREE_LATEST_VERSION
58+
"""
59+
60+
latest = common.models.InvenTreeSetting.get_setting('INVENTREE_LATEST_VERSION', None)
61+
62+
# No record for "latest" version - we must assume we are up to date!
63+
if not latest:
64+
return True
65+
66+
# Extract "tuple" version
67+
version = inventreeVersionTuple(latest)
68+
version_int = versionTupleToInt(version)
69+
70+
inventree_int = versionTupleToInt(inventreeVersionTuple())
71+
72+
return inventree_int >= version_int
73+
4874

4975
def inventreeApiVersion():
5076
return INVENTREE_API_VERSION

InvenTree/templates/about.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,30 @@ <h3>{% trans "InvenTree Version Information" %}</h3>
1919
<col width='25'>
2020
<tr>
2121
<td><span class='fas fa-hashtag'></span></td>
22-
<td>{% trans "InvenTree Version" %}</td><td><a href="https://github.com/inventree/InvenTree/releases">{% inventree_version %}</a></td>
22+
<td>{% trans "InvenTree Version" %}</td>
23+
<td>
24+
<a href="https://github.com/inventree/InvenTree/releases">{% inventree_version %}</a>
25+
{% if up_to_date %}
26+
<span class='label label-green float-right'>{% trans "Up to Date" %}</span>
27+
{% else %}
28+
<span class='label label-red float-right'>{% trans "Update Available" %}</span>
29+
{% endif %}
30+
</td>
2331
</tr>
2432
<tr>
2533
<td><span class='fas fa-hashtag'></span></td>
26-
<td>{% trans "Django Version" %}</td><td><a href="https://www.djangoproject.com/">{% django_version %}</a></td>
34+
<td>{% trans "Django Version" %}</td>
35+
<td><a href="https://www.djangoproject.com/">{% django_version %}</a></td>
2736
</tr>
2837
<tr>
2938
<td><span class='fas fa-code-branch'></span></td>
30-
<td>{% trans "Commit Hash" %}</td><td><a href="https://github.com/inventree/InvenTree/commit/{% inventree_commit_hash %}">{% inventree_commit_hash %}</a></td>
39+
<td>{% trans "Commit Hash" %}</td>
40+
<td><a href="https://github.com/inventree/InvenTree/commit/{% inventree_commit_hash %}">{% inventree_commit_hash %}</a></td>
3141
</tr>
3242
<tr>
3343
<td><span class='fas fa-calendar-alt'></span></td>
34-
<td>{% trans "Commit Date" %}</td><td>{% inventree_commit_date %}</td>
44+
<td>{% trans "Commit Date" %}</td>
45+
<td>{% inventree_commit_date %}</td>
3546
</tr>
3647
<tr>
3748
<td><span class='fas fa-book'></span></td>

InvenTree/templates/navbar.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
{% endif %}
6060
<li class='dropdown'>
6161
<a class='dropdown-toggle' data-toggle='dropdown' href="#">
62-
{% if not system_healthy %}
63-
<span title='{% trans "InvenTree server issues detected" %}' class='fas fa-exclamation-triangle icon-red'></span>
62+
{% if not system_healthy or not up_to_date %}
63+
<span class='fas fa-exclamation-triangle icon-red'></span>
6464
{% endif %}
6565
<span class="fas fa-user"></span> <b>{{ user.get_username }}</b></a>
6666
<ul class='dropdown-menu'>
@@ -78,11 +78,20 @@
7878
{% if system_healthy %}
7979
<span class='fas fa-server'>
8080
{% else %}
81-
<span class='fas fa-exclamation-triangle icon-red'>
81+
<span class='fas fa-server icon-red'>
8282
{% endif %}
8383
</span> {% trans "System Information" %}
8484
</a></li>
85-
<li id='launch-about'><a href='#'><span class="fas fa-info-circle"></span> {% trans "About InvenTree" %}</a></li>
85+
<li id='launch-about'>
86+
<a href='#'>
87+
{% if up_to_date %}
88+
<span class="fas fa-info-circle">
89+
{% else %}
90+
<span class='fas fa-info-circle icon-red'>
91+
{% endif %}
92+
</span> {% trans "About InvenTree" %}
93+
</a>
94+
</li>
8695
</ul>
8796
</li>
8897
</ul>

0 commit comments

Comments
 (0)