diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 06c06bde05..73acb5113d 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -78,6 +78,13 @@ class InvenTreeSetting(models.Model): 'choices': djmoney.settings.CURRENCY_CHOICES, }, + 'INVENTREE_DOWNLOAD_FROM_URL': { + 'name': _('Download from URL'), + 'description': _('Allow download of remote images and files from external URL'), + 'validator': bool, + 'default': False, + }, + 'BARCODE_ENABLE': { 'name': _('Barcode Support'), 'description': _('Enable barcode scanner support'), diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 58922e377c..6031ec69f8 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -296,11 +296,15 @@ } {% if roles.part.change %} + + {% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %} + {% if allow_download %} $("#part-image-url").click(function() { launchModalForm( '{% url "part-image-download" part.id %}', ); }); + {% endif %} $("#part-image-select").click(function() { launchModalForm("{% url 'part-image-select' part.id %}", diff --git a/InvenTree/part/templates/part/part_thumb.html b/InvenTree/part/templates/part/part_thumb.html index 5cef673bd7..9e1de6fc26 100644 --- a/InvenTree/part/templates/part/part_thumb.html +++ b/InvenTree/part/templates/part/part_thumb.html @@ -1,5 +1,8 @@ {% load static %} {% load i18n %} +{% load inventree_extras %} + +{% settings_value "INVENTREE_DOWNLOAD_FROM_URL" as allow_download %}
@@ -15,8 +18,10 @@
- + {% if allow_download %} + + {% endif %}
{% endif %} diff --git a/InvenTree/templates/InvenTree/settings/global.html b/InvenTree/templates/InvenTree/settings/global.html index d63593d866..c234bd1379 100644 --- a/InvenTree/templates/InvenTree/settings/global.html +++ b/InvenTree/templates/InvenTree/settings/global.html @@ -19,6 +19,7 @@ {% include "InvenTree/settings/setting.html" with key="INVENTREE_BASE_URL" icon="fa-globe" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_COMPANY_NAME" icon="fa-building" %} {% include "InvenTree/settings/setting.html" with key="INVENTREE_DEFAULT_CURRENCY" icon="fa-dollar-sign" %} + {% include "InvenTree/settings/setting.html" with key="INVENTREE_DOWNLOAD_FROM_URL" icon="fa-cloud-download-alt" %}