mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow for custom url schemes to be specified in the config file
This commit is contained in:
parent
0846daf1f6
commit
ee17d5d3c3
2
.gitignore
vendored
2
.gitignore
vendored
@ -36,6 +36,8 @@ InvenTree/media
|
||||
InvenTree/static
|
||||
media
|
||||
static
|
||||
inventree_media
|
||||
inventree_static
|
||||
|
||||
# Local config file
|
||||
config.yaml
|
||||
|
@ -213,6 +213,14 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
},
|
||||
]
|
||||
|
||||
# Extra (optional) URL validators
|
||||
# See https://docs.djangoproject.com/en/2.2/ref/validators/#django.core.validators.URLValidator
|
||||
|
||||
EXTRA_URL_SCHEMES = CONFIG.get('extra_url_schemes', [])
|
||||
|
||||
if not type(EXTRA_URL_SCHEMES) in [list]:
|
||||
eprint("Warning: extra_url_schemes not correctly formatted")
|
||||
EXTRA_URL_SCHEMES = []
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
||||
|
@ -2,10 +2,29 @@
|
||||
Custom field validators for InvenTree
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def allowable_url_schemes():
|
||||
""" Return the list of allowable URL schemes.
|
||||
In addition to the default schemes allowed by Django,
|
||||
the install configuration file (config.yaml) can specify
|
||||
extra schemas """
|
||||
|
||||
# Default schemes
|
||||
schemes = ['http', 'https', 'ftp', 'ftps']
|
||||
|
||||
extra = settings.EXTRA_URL_SCHEMES
|
||||
|
||||
for e in extra:
|
||||
if e.lower() not in schemes:
|
||||
schemes.append(e.lower())
|
||||
|
||||
return schemes
|
||||
|
||||
|
||||
def validate_part_name(value):
|
||||
""" Prevent some illegal characters in part names.
|
||||
"""
|
||||
|
@ -47,7 +47,16 @@ media_root: '../inventree_media'
|
||||
# By default it is stored in a directory named 'static' local to the InvenTree directory
|
||||
static_root: '../inventree_static'
|
||||
|
||||
# Optional URL schemes to allow in URL fields
|
||||
# By default, only the following schemes are allowed: ['http', 'https', 'ftp', 'ftps']
|
||||
# Uncomment the lines below to allow extra schemes
|
||||
#extra_url_schemes:
|
||||
# - mailto
|
||||
# - git
|
||||
# - ssh
|
||||
|
||||
# Logging options
|
||||
# If debug mode is enabled, set log_queries to True to show aggregate database queries in the debug console
|
||||
log_queries: False
|
||||
|
||||
# Backup options
|
||||
|
Loading…
Reference in New Issue
Block a user