diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 0abe5313ee..5492f13a05 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -13,6 +13,8 @@ from django.http import StreamingHttpResponse from django.core.exceptions import ValidationError from django.utils.translation import ugettext as _ +from .version import inventreeVersion, inventreeInstanceName + def TestIfImage(img): """ 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['url'] = object_url data['tool'] = 'InvenTree' + data['instance'] = inventreeInstanceName() + data['version'] = inventreeVersion() return json.dumps(data, sort_keys=True) diff --git a/InvenTree/InvenTree/static/script/inventree/order.js b/InvenTree/InvenTree/static/script/inventree/order.js index d811cc5ea1..a54a464b88 100644 --- a/InvenTree/InvenTree/static/script/inventree/order.js +++ b/InvenTree/InvenTree/static/script/inventree/order.js @@ -113,6 +113,14 @@ function loadPurchaseOrderTable(table, options) { title: 'ID', visible: false, }, + { + sortable: true, + field: 'reference', + title: 'Purchase Order', + formatter: function(value, row, index, field) { + return renderLink(value, "/order/purchase-order/" + row.pk + "/"); + } + }, { sortable: true, field: 'supplier', @@ -121,14 +129,6 @@ function loadPurchaseOrderTable(table, options) { return imageHoverIcon(row.supplier__image) + renderLink(row.supplier__name, '/company/' + value + '/purchase-orders/'); } }, - { - sortable: true, - field: 'reference', - title: 'Reference', - formatter: function(value, row, index, field) { - return renderLink(value, "/order/purchase-order/" + row.pk + "/"); - } - }, { sortable: true, field: 'creation_date', diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index be4e6c708e..ae812a2695 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -3,10 +3,16 @@ Provides information on the current InvenTree version """ import subprocess +from common.models import InvenTreeSetting INVENTREE_SW_VERSION = "0.0.10" +def inventreeInstanceName(): + """ Returns the InstanceName settings for the current database """ + return InvenTreeSetting.get_setting("InstanceName", "") + + def inventreeVersion(): """ Returns the InvenTree version string """ return INVENTREE_SW_VERSION diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 5121b1bad9..9cdfecbd8a 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -22,7 +22,7 @@ from common.models import InvenTreeSetting from .forms import DeleteForm, EditUserForm, SetPasswordForm from .helpers import str2bool -from .version import inventreeVersion +from .version import inventreeVersion, inventreeInstanceName from rest_framework import views @@ -422,7 +422,8 @@ class InfoView(AjaxView): data = { 'server': 'InvenTree', - 'version': inventreeVersion() + 'version': inventreeVersion(), + 'instance': inventreeInstanceName(), } return JsonResponse(data) diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 4011ca7dfb..8b8a53023b 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -10,6 +10,7 @@
+ diff --git a/InvenTree/common/apps.py b/InvenTree/common/apps.py index d055aeba74..4661c69370 100644 --- a/InvenTree/common/apps.py +++ b/InvenTree/common/apps.py @@ -2,7 +2,7 @@ from django.apps import AppConfig from django.db.utils import OperationalError, ProgrammingError import os - +import uuid import yaml @@ -10,14 +10,19 @@ class CommonConfig(AppConfig): name = 'common' def ready(self): + """ Will be called when the Common app is first loaded """ self.populate_default_settings() + self.add_instance_name() def populate_default_settings(self): """ Populate the default values for InvenTree key:value pairs. If a setting does not exist, it will be created. """ + # Import this here, rather than at the global-level, + # otherwise it is called all the time, and we don't want that, + # as the InvenTreeSetting model may have not been instantiated yet. from .models import InvenTreeSetting here = os.path.dirname(os.path.abspath(__file__)) @@ -46,3 +51,30 @@ class CommonConfig(AppConfig): except (OperationalError, ProgrammingError): # Migrations have not yet been applied - table does not exist break + + def add_instance_name(self): + """ + Check if an InstanceName has been defined for this database. + If not, create a random one! + """ + + # See note above + from .models import InvenTreeSetting + + try: + if not InvenTreeSetting.objects.filter(key='InstanceName').exists(): + + val = uuid.uuid4().hex + + print("No 'InstanceName' found - generating random name '{n}'".format(n=val)) + + name = InvenTreeSetting( + key="InstanceName", + value=val, + description="Instance name for this InvenTree database installation." + ) + + name.save() + except (OperationalError, ProgrammingError): + # Migrations have not yet been applied - table does not exist + pass diff --git a/InvenTree/common/kvp.yaml b/InvenTree/common/kvp.yaml index 9200b22c31..d0f7249dff 100644 --- a/InvenTree/common/kvp.yaml +++ b/InvenTree/common/kvp.yaml @@ -4,6 +4,9 @@ # Note: The description strings provided here will be translatable, # so ensure that any translations are provided as appropriate. +# TODO: Update the formatting here to include logical separators e.g. double-underscore +# TODO: This is so when there are enough options, we will be able to display them as a tree + - key: 'part_ipn_regex' default: '' description: 'Format string for internal part number' diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 873d6747be..19ef2a0e60 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -43,6 +43,7 @@ InvenTree | {% trans "Company" %} - {{ company.name }}
{% trans "Title" %}
+ {% if company.website %} diff --git a/InvenTree/company/templates/company/detail.html b/InvenTree/company/templates/company/detail.html index 93e9e5bbb9..adb999fb4d 100644 --- a/InvenTree/company/templates/company/detail.html +++ b/InvenTree/company/templates/company/detail.html @@ -9,14 +9,18 @@
- - - - - - - - + + + + + + + + + + + +
{% trans "Customer" %}{% include 'yesnolabel.html' with value=company.is_customer %}
{% trans "Supplier" %}{% include 'yesnolabel.html' with value=company.is_supplier %}
{% trans "Customer" %}{% include 'yesnolabel.html' with value=company.is_customer %}
{% trans "Supplier" %}{% include 'yesnolabel.html' with value=company.is_supplier %}
{% endblock %} diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 6452f8ab2c..e5ed77cf4f 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -60,6 +60,7 @@ InvenTree | {{ order }}

{% trans "Purchase Order Details" %}

+ diff --git a/InvenTree/part/migrations/0034_auto_20200404_1238.py b/InvenTree/part/migrations/0034_auto_20200404_1238.py index e292202b68..aba533ff40 100644 --- a/InvenTree/part/migrations/0034_auto_20200404_1238.py +++ b/InvenTree/part/migrations/0034_auto_20200404_1238.py @@ -1,7 +1,7 @@ # Generated by Django 2.2.10 on 2020-04-04 12:38 from django.db import migrations -from django.db.utils import OperationalError +from django.db.utils import OperationalError, ProgrammingError from part.models import Part from stdimage.utils import render_variations @@ -17,8 +17,9 @@ def create_thumbnails(apps, schema_editor): # Render thumbnail for each existing Part if part.image: part.image.render_variations() - except OperationalError: - print("Error - could not generate Part thumbnails") + except (OperationalError, ProgrammingError): + # Migrations have not yet been applied - table does not exist + print("Could not generate Part thumbnails") class Migration(migrations.Migration): diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index ec8fd8d8e0..2161ff1bd9 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -33,6 +33,7 @@ {% if category %}

{% trans "Category Details" %}

{% trans "Supplier" %}
+ @@ -71,6 +72,7 @@ {% else %}

{% trans "Category Details" %}

{% trans "Category Path" %}
+ diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 64e0bed5bc..2c3e5a2884 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -13,6 +13,7 @@
{% trans "Part Categories" %}
+ diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index b75b01cb12..abac62f059 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -70,6 +70,7 @@

{% trans "Part name" %}
+ {% if part.IPN %} diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index d508452e80..e68e9c23dc 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -43,6 +43,12 @@ def part_allocation_count(build, part, *args, **kwargs): 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() def inventree_version(*args, **kwargs): """ Return InvenTree version string """ diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 9ef0762a07..949823b83b 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -73,6 +73,7 @@
+ diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index aad5b2b9e8..7117e54c60 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -36,6 +36,7 @@ {% if location %}

{% trans "Location Details" %}

Part
+ @@ -60,6 +61,7 @@ {% else %}

{% trans "Stock Details" %}

{% trans "Location Path" %}
+ diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index a4c6b68ef4..c4eb5990cc 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -24,10 +24,16 @@ InvenTree | Index {% endblock %} {% block js_ready %} + +console.log("abcde?"); + {{ block.super }} -$("#to-build-table").bootstrapTable(); -$("#to-order-table").bootstrapTable(); -$("#starred-parts-table").bootstrapTable(); +//TODO: These calls to bootstrapTable() are failing, for some reason? +//$("#to-build-table").bootstrapTable(); +//$("#to-order-table").bootstrapTable(); +//$("#starred-parts-table").bootstrapTable(); + +console.log("Got to here..."); {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/about.html b/InvenTree/templates/about.html index 4f8d7e6d4e..1a5533df36 100644 --- a/InvenTree/templates/about.html +++ b/InvenTree/templates/about.html @@ -10,35 +10,41 @@ Inventree Logo +

{% trans "InvenTree Version Information" %}

{% trans "Stock Locations" %}
- + + + + + + + + + - - - + + - - + + +
{% trans "Version" %}{% inventree_version %}{% trans "Instance Name" %}{% inventree_instance_name %}
{% trans "InvenTree Version" %}{% inventree_version %}
{% trans "Commit Hash" %}{% inventree_commit_hash %}
{% trans "Commit Date" %}{% inventree_commit_date %}
{% trans "InvenTree Documentation" %} {% inventree_docs_url %}
{% trans "View Code on GitHub" %}{% inventree_github_url %}
{% trans "Submit Bug Report" %}{% inventree_github_url %}/issues
diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index e3b1837584..d343ea3824 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -28,6 +28,7 @@ + @@ -108,6 +109,7 @@ InvenTree + {% block js_load %} diff --git a/InvenTree/templates/required_part_table.html b/InvenTree/templates/required_part_table.html index 74feb07336..a1e26e2894 100644 --- a/InvenTree/templates/required_part_table.html +++ b/InvenTree/templates/required_part_table.html @@ -1,11 +1,11 @@ - - - - - - + + + + + + {% for part in parts %} diff --git a/InvenTree/templates/stats.html b/InvenTree/templates/stats.html index caa2a44cee..0f8a9e0542 100644 --- a/InvenTree/templates/stats.html +++ b/InvenTree/templates/stats.html @@ -7,22 +7,26 @@ - - - - + + + + + + - - - - + + + + + +
PartDescriptionIn StockOn OrderAlloctedNet StockPartDescriptionIn StockOn OrderAlloctedNet Stock
{% trans "Parts" %}
{% trans "Parts" %}{{ part_count }}
{% trans "Part Categories" %} {{ part_cat_count }}
{% trans "Parts" %}{{ part_count }}
{% trans "Stock Items" %}
{% trans "Stock Items" %}{{ stock_item_count }}
{% trans "Stock Locations" %} {{ stock_loc_count }}
{% trans "Stock Items" %}{{ stock_item_count }}
\ No newline at end of file