Use InstanceName around the place

- Report in /api/ endpoint
- Display in About window
- Include in any generated barcode
This commit is contained in:
Oliver Walters 2020-04-06 20:11:36 +10:00
parent 071c317bae
commit 751937e0c2
6 changed files with 37 additions and 12 deletions

View File

@ -13,6 +13,8 @@ from django.http import StreamingHttpResponse
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from .version import inventreeVersion, inventreeInstanceName
def TestIfImage(img): def TestIfImage(img):
""" Test if an image file is indeed an image """ """ Test if an image file is indeed an image """
@ -134,6 +136,8 @@ def MakeBarcode(object_type, object_id, object_url, data={}):
data['id'] = object_id data['id'] = object_id
data['url'] = object_url data['url'] = object_url
data['tool'] = 'InvenTree' data['tool'] = 'InvenTree'
data['instance'] = inventreeInstanceName()
data['version'] = inventreeVersion()
return json.dumps(data, sort_keys=True) return json.dumps(data, sort_keys=True)

View File

@ -3,9 +3,15 @@ Provides information on the current InvenTree version
""" """
import subprocess import subprocess
from common.models import InvenTreeSetting
INVENTREE_SW_VERSION = "0.0.10" INVENTREE_SW_VERSION = "0.0.10"
def inventreeInstanceName():
""" Returns the InstanceName settings for the current database """
return InvenTreeSetting.get_setting("InstanceName", "")
def inventreeVersion(): def inventreeVersion():
""" Returns the InvenTree version string """ """ Returns the InvenTree version string """

View File

@ -22,7 +22,7 @@ from common.models import InvenTreeSetting
from .forms import DeleteForm, EditUserForm, SetPasswordForm from .forms import DeleteForm, EditUserForm, SetPasswordForm
from .helpers import str2bool from .helpers import str2bool
from .version import inventreeVersion from .version import inventreeVersion, inventreeInstanceName
from rest_framework import views from rest_framework import views
@ -422,7 +422,8 @@ class InfoView(AjaxView):
data = { data = {
'server': 'InvenTree', 'server': 'InvenTree',
'version': inventreeVersion() 'version': inventreeVersion(),
'instance': inventreeInstanceName(),
} }
return JsonResponse(data) return JsonResponse(data)

View File

@ -43,6 +43,12 @@ def part_allocation_count(build, part, *args, **kwargs):
return decimal2string(build.getAllocatedQuantity(part)) return decimal2string(build.getAllocatedQuantity(part))
@register.simple_tag()
def inventree_instance_name(*args, **kwargs):
""" Return the InstanceName associated with the current database """
return version.inventreeInstanceName()
@register.simple_tag() @register.simple_tag()
def inventree_version(*args, **kwargs): def inventree_version(*args, **kwargs):
""" Return InvenTree version string """ """ Return InvenTree version string """

View File

@ -10,35 +10,41 @@
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
<img src="{% static 'img/inventree.png' %}" height='60' style='float: left;' alt='Inventree Logo'> <img src="{% static 'img/inventree.png' %}" height='60' style='float: left;' alt='Inventree Logo'>
<h3>{% trans "InvenTree Version Information" %}</h3>
</div> </div>
<div class='modal-form-content'> <div class='modal-form-content'>
<div> <div>
<!--
-->
<h4>{% trans "InvenTree Version Information" %}</h4>
<table class='table table-striped table-condensed'> <table class='table table-striped table-condensed'>
<tr> <tr>
<td>{% trans "Version" %}</td><td><a href="https://github.com/inventree/InvenTree/releases">{% inventree_version %}</a></td> <td></td>
<td>{% trans "Instance Name" %}</td>
<td>{% inventree_instance_name %}</td>
</tr> </tr>
<tr> <tr>
<td></td>
<td>{% trans "InvenTree Version" %}</td><td><a href="https://github.com/inventree/InvenTree/releases">{% inventree_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>
<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>
<tr> <tr>
<td colspan="2"></td> <td><span class='fas fa-book'></span></td>
</tr>
<tr>
<td>{% trans "InvenTree Documentation" %}</td> <td>{% trans "InvenTree Documentation" %}</td>
<td><a href="{% inventree_docs_url %}">{% inventree_docs_url %}</a></td> <td><a href="{% inventree_docs_url %}">{% inventree_docs_url %}</a></td>
</tr> </tr>
<tr> <tr>
<td><span class='fas fa-github'></span></td>
<td>{% trans "View Code on GitHub" %}</td><td><a href="{% inventree_github_url %}">{% inventree_github_url %}</a></td> <td>{% trans "View Code on GitHub" %}</td><td><a href="{% inventree_github_url %}">{% inventree_github_url %}</a></td>
</tr> </tr>
<tr> <tr>
<td></td> <td><span class='fas fa-exclamation-circle'></span></td>
<td><a href='https://github.com/inventree/InvenTree/issues'><button class='btn btn-default'>Submit Bug Report</button></a></td> <td>{% trans "Submit Bug Report" %}</td>
<td><a href='{% inventree_github_url %}/issues'>{% inventree_github_url %}/issues</a></td>
</tr> </tr>
</table> </table>

View File

@ -20,7 +20,7 @@
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'img/favicon/apple-icon-180x180.png' %}"> <link rel="apple-touch-icon" sizes="180x180" href="{% static 'img/favicon/apple-icon-180x180.png' %}">
<link rel="icon" type="image/png" sizes="192x192" href="{% static 'img/favicon/android-icon-192x192.png' %}"> <link rel="icon" type="image/png" sizes="192x192" href="{% static 'img/favicon/android-icon-192x192.png' %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'img/favicon/favicon-32x32.png' %}"> <link rel="icon" type="image/png" sizes="32x32" href="{% static 'img/favicon/favicon-32x32.png' %}">
<link rel="icon" type="image/png" sizes="96x96" href="{% static 'img/favicon/favicon-96x96.png' %}"> <link rel="icon" type="image/png" sizes="96x96" href="{% static 'img/favicon/f avicon-96x96.png' %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'img/favicon/favicon-16x16.png' %}"> <link rel="icon" type="image/png" sizes="16x16" href="{% static 'img/favicon/favicon-16x16.png' %}">
<link rel="manifest" href="{% static 'img/favicon/manifest.json' %}"> <link rel="manifest" href="{% static 'img/favicon/manifest.json' %}">
<meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileColor" content="#ffffff">
@ -29,6 +29,7 @@
<!-- CSS --> <!-- CSS -->
<link rel="stylesheet" href="{% static 'fontawesome/css/solid.css' %}"> <link rel="stylesheet" href="{% static 'fontawesome/css/solid.css' %}">
<link rel="stylesheet" href="{% static 'fontawesome/css/brands.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap_3.3.7_css_bootstrap.min.css' %}"> <link rel="stylesheet" href="{% static 'css/bootstrap_3.3.7_css_bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-table.css' %}"> <link rel="stylesheet" href="{% static 'css/bootstrap-table.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-table-group-by.css' %}"> <link rel="stylesheet" href="{% static 'css/bootstrap-table-group-by.css' %}">
@ -108,6 +109,7 @@ InvenTree
<script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script>
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script> <script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>
<script type='text/javascript' src="{% static 'fontawesome/js/brands.js' %}"></script>
<script type='text/javascript' src="{% static 'fontawesome/js/fontawesome.js' %}"></script> <script type='text/javascript' src="{% static 'fontawesome/js/fontawesome.js' %}"></script>
{% block js_load %} {% block js_load %}