mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 03:25:42 +00:00
Add INVENTREE_BASE_URL setting
- Also adds callable validator!
This commit is contained in:
@ -18,7 +18,7 @@ from djmoney.contrib.exchange.models import convert_money
|
||||
from djmoney.contrib.exchange.exceptions import MissingRate
|
||||
|
||||
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
|
||||
|
||||
import InvenTree.helpers
|
||||
@ -64,6 +64,13 @@ class InvenTreeSetting(models.Model):
|
||||
'default': 'My company name',
|
||||
},
|
||||
|
||||
'INVENTREE_BASE_URL': {
|
||||
'name': _('Base URL'),
|
||||
'description': _('Base URL for server instance'),
|
||||
'validator': URLValidator(),
|
||||
'default': '',
|
||||
},
|
||||
|
||||
'INVENTREE_DEFAULT_CURRENCY': {
|
||||
'name': _('Default Currency'),
|
||||
'description': _('Default currency'),
|
||||
@ -528,6 +535,11 @@ class InvenTreeSetting(models.Model):
|
||||
|
||||
return
|
||||
|
||||
if callable(validator):
|
||||
# We can accept function validators with a single argument
|
||||
print("Running validator function")
|
||||
validator(self.value)
|
||||
|
||||
# Boolean validator
|
||||
if validator == bool:
|
||||
# Value must "look like" a boolean value
|
||||
|
Reference in New Issue
Block a user