Show required and optional metadata types on upload wizard
This commit is contained in:
@@ -22,7 +22,7 @@ class DocumentCreateWizard(MayanPermissionCheckMixin, SessionWizardView):
|
||||
def _has_metadata_types(wizard):
|
||||
# Skip the 2nd step if document type has no associated metadata
|
||||
try:
|
||||
return wizard.get_cleaned_data_for_step('0')['document_type'].metadata.count()
|
||||
return wizard.get_cleaned_data_for_step('0')['document_type'].metadata_type.all().count()
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
@@ -40,11 +40,18 @@ class DocumentCreateWizard(MayanPermissionCheckMixin, SessionWizardView):
|
||||
if step == '1':
|
||||
initial = []
|
||||
|
||||
for metadata_type in self.get_cleaned_data_for_step('0')['document_type'].metadata.all():
|
||||
for metadata_type in self.get_cleaned_data_for_step('0')['document_type'].metadata_type.filter(required=True):
|
||||
initial.append({
|
||||
'metadata_type': metadata_type,
|
||||
'required': True,
|
||||
})
|
||||
|
||||
for metadata_type in self.get_cleaned_data_for_step('0')['document_type'].metadata_type.filter(required=False):
|
||||
initial.append({
|
||||
'metadata_type': metadata_type,
|
||||
})
|
||||
|
||||
|
||||
return initial
|
||||
return self.initial_dict.get(step, {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user