From 01e44dede4392f49dbeb6365561365d641a9f37c Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 30 Oct 2014 03:19:40 -0400 Subject: [PATCH] Show required and optional metadata types on upload wizard --- mayan/apps/sources/wizards.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mayan/apps/sources/wizards.py b/mayan/apps/sources/wizards.py index 23541f65b3..87fd3e822a 100644 --- a/mayan/apps/sources/wizards.py +++ b/mayan/apps/sources/wizards.py @@ -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, {})