mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add INVENTREE_BASE_URL setting
- Also adds callable validator!
This commit is contained in:
parent
247c4bdb4b
commit
6cc0880b4a
@ -18,7 +18,7 @@ from djmoney.contrib.exchange.models import convert_money
|
|||||||
from djmoney.contrib.exchange.exceptions import MissingRate
|
from djmoney.contrib.exchange.exceptions import MissingRate
|
||||||
|
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator, URLValidator
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
import InvenTree.helpers
|
import InvenTree.helpers
|
||||||
@ -64,6 +64,13 @@ class InvenTreeSetting(models.Model):
|
|||||||
'default': 'My company name',
|
'default': 'My company name',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'INVENTREE_BASE_URL': {
|
||||||
|
'name': _('Base URL'),
|
||||||
|
'description': _('Base URL for server instance'),
|
||||||
|
'validator': URLValidator(),
|
||||||
|
'default': '',
|
||||||
|
},
|
||||||
|
|
||||||
'INVENTREE_DEFAULT_CURRENCY': {
|
'INVENTREE_DEFAULT_CURRENCY': {
|
||||||
'name': _('Default Currency'),
|
'name': _('Default Currency'),
|
||||||
'description': _('Default currency'),
|
'description': _('Default currency'),
|
||||||
@ -528,6 +535,11 @@ class InvenTreeSetting(models.Model):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if callable(validator):
|
||||||
|
# We can accept function validators with a single argument
|
||||||
|
print("Running validator function")
|
||||||
|
validator(self.value)
|
||||||
|
|
||||||
# Boolean validator
|
# Boolean validator
|
||||||
if validator == bool:
|
if validator == bool:
|
||||||
# Value must "look like" a boolean value
|
# Value must "look like" a boolean value
|
||||||
|
@ -209,6 +209,7 @@ class ReportTemplateBase(ReportBase):
|
|||||||
|
|
||||||
context = self.get_context_data(request)
|
context = self.get_context_data(request)
|
||||||
|
|
||||||
|
context['base_url'] = common.models.InvenTreeSetting.get_setting('INVENTREE_BASE_URL')
|
||||||
context['date'] = datetime.datetime.now().date()
|
context['date'] = datetime.datetime.now().date()
|
||||||
context['datetime'] = datetime.datetime.now()
|
context['datetime'] = datetime.datetime.now()
|
||||||
context['default_page_size'] = common.models.InvenTreeSetting.get_setting('REPORT_DEFAULT_PAGE_SIZE')
|
context['default_page_size'] = common.models.InvenTreeSetting.get_setting('REPORT_DEFAULT_PAGE_SIZE')
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
{% include "InvenTree/settings/header.html" %}
|
{% include "InvenTree/settings/header.html" %}
|
||||||
<tbody>
|
<tbody>
|
||||||
{% include "InvenTree/settings/setting.html" with key="INVENTREE_INSTANCE" icon="fa-info-circle" %}
|
{% include "InvenTree/settings/setting.html" with key="INVENTREE_INSTANCE" icon="fa-info-circle" %}
|
||||||
|
{% 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_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_DEFAULT_CURRENCY" icon="fa-dollar-sign" %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user