def update_multisection_file_cdes(registry_code, multisection_code, form_section_items, form_model, existing_nested_data, index_map): updates = [] for item_index, section_item_dict in enumerate(form_section_items): for key, value in section_item_dict.items(): cde_code = get_code(key) if is_file_cde(cde_code): actual_index = index_map[item_index] existing_value = get_mongo_value( registry_code, existing_nested_data, key, multisection_index=actual_index) # antecedent here will never return true and the definition is not correct if is_multiple_file_cde(cde_code): new_val = DynamicDataWrapper.handle_file_uploads( registry_code, key, value, existing_value) else: new_val = DynamicDataWrapper.handle_file_upload( registry_code, key, value, existing_value) updates.append((item_index, key, new_val)) for index, key, value in updates: form_section_items[index][key] = value return form_section_items
def _update_files_in_fs(self, existing_record, registry, new_data, index_map): for key, value in new_data.items(): cde_code = get_code(key) if is_file_cde(cde_code): existing_value = get_mongo_value(registry, existing_record, key) if is_multiple_file_cde(cde_code): new_data[key] = self.handle_file_uploads(registry, key, value, existing_value) else: new_data[key] = self.handle_file_upload(registry, key, value, existing_value) elif (self._is_section_code(key) and self.current_form_model and index_map is not None): new_data[key] = update_multisection_file_cdes(registry, key, value, self.current_form_model, existing_record, index_map)
def should_wrap(section_index, key, value): try: cde_code = get_code(key) except BaseException: # not a delimited mongo key return False if is_file_cde(cde_code): u = is_upload_file(value) fs = is_filestorage_dict(value) im = is_existing_in_mongo(section_index, key, value) sw = u or fs or im return sw return False