mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
improve regex for part name format validation
proper import of validation
This commit is contained in:
parent
ee9e01fc22
commit
5a6bea3452
@ -166,7 +166,7 @@ def validate_part_name_format(self):
|
||||
"""
|
||||
|
||||
jinja_template_regex = re.compile('{{.*?}}')
|
||||
field_name_regex = re.compile('(?<=part\\.)[A-z]*')
|
||||
field_name_regex = re.compile('(?<=part\\.)[A-z]+')
|
||||
for jinja_template in jinja_template_regex.findall(str(self)):
|
||||
# make sure at least one and only one field is present inside the parser
|
||||
field_names = field_name_regex.findall(jinja_template)
|
||||
|
@ -25,6 +25,7 @@ from django.core.exceptions import ValidationError
|
||||
|
||||
import InvenTree.helpers
|
||||
import InvenTree.fields
|
||||
import InvenTree.validators
|
||||
|
||||
import logging
|
||||
|
||||
@ -707,7 +708,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
||||
'description': _('Format to display the part name'),
|
||||
'default': "{{ part.IPN if part.IPN }}{{ ' | ' if part.IPN }}{{ part.name }}{{ ' | ' if part.revision }}"
|
||||
"{{ part.revision if part.revision }}",
|
||||
'validator': InvenTree.fields.validate_part_name_format
|
||||
'validator': InvenTree.validators.validate_part_name_format
|
||||
},
|
||||
|
||||
'REPORT_DEBUG_MODE': {
|
||||
|
Loading…
Reference in New Issue
Block a user