2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +00:00

form overrides

This commit is contained in:
2021-05-18 10:17:19 +02:00
parent 92f8bd36f1
commit cb0ef30eff
2 changed files with 29 additions and 3 deletions

View File

@ -191,10 +191,27 @@ class FileManagementFormView(MultiStepFormView):
def __init__(self, *args, **kwargs):
""" initialize the FormView """
# perform all checks and inits from MultiStepFormView
# check if form_list should be overriden
if hasattr(self, 'form_list_override'):
# check for list
if not isinstance(self.form_list_override, list):
raise ValueError('form_list_override must be a list')
# loop through and override /add form_list enrties
for entry in self.form_list_override:
# fetch postition
pos = [self.form_list.index(i) for i in self.form_list if i[0] == 'items']
# replace if exists
if pos:
self.form_list[pos[0]] = entry
# or append
else:
self.form_list.append(entry)
# perform all checks and inits for MultiStepFormView
super().__init__(*args, **kwargs)
# Check
# Check for file manager class
if not(hasattr(self, 'file_manager_class') and issubclass(self.file_manager_class, FileManager)):
raise NotImplementedError('A subclass of a file manager class needs to be set!')