def _is_proposal_creation_finished(proposal_version): proposal_item = find_interface(proposal_version, IProposal) versions_with_data = [ x for x in proposal_item.values() if IProposalVersion.providedBy(x) and has_annotation_sheet_data(x) ] return len(versions_with_data) == 1
def _is_bplan_and_has_no_version_with_sheet_data(self, meta: ResourceMetadata, context: IPool) -> bool: is_bplan_version = meta.iresource.isOrExtends(IProposalVersion) if not is_bplan_version: return False versions_with_data = [x for x in context.values() if IProposalVersion.providedBy(x) and has_annotation_sheet_data(x)] return versions_with_data == []
def _is_bplan_and_has_no_version_with_sheet_data(self, meta: ResourceMetadata, context: IPool) -> bool: is_bplan_version = meta.iresource.isOrExtends(IProposalVersion) if not is_bplan_version: return False versions_with_data = [ x for x in context.values() if IProposalVersion.providedBy(x) and has_annotation_sheet_data(x) ] return versions_with_data == []
def remove_empty_first_versions(root, registry): # pragma: no cover """Remove empty first versions.""" catalogs = find_service(root, 'catalogs') items = _search_for_interfaces(catalogs, IItem) count = len(items) for index, item in enumerate(items): logger.info('Migrating resource {0} of {1}'.format(index + 1, count)) if 'VERSION_0000000' not in item: continue first_version = item['VERSION_0000000'] has_sheet_data = has_annotation_sheet_data(first_version)\ or hasattr(first_version, 'rate') has_follower = _has_follower(first_version, registry) if not has_sheet_data and has_follower: logger.info('Delete empty version {0}.'.format(first_version)) del item['VERSION_0000000']
def remove_empty_first_versions(root): # pragma: no cover """Remove empty first versions.""" registry = get_current_registry(root) catalogs = find_service(root, "catalogs") items = _search_for_interfaces(catalogs, IItem) count = len(items) for index, item in enumerate(items): logger.info("Migrating resource {0} of {1}".format(index + 1, count)) if "VERSION_0000000" not in item: continue first_version = item["VERSION_0000000"] has_sheet_data = has_annotation_sheet_data(first_version) or hasattr(first_version, "rate") has_follower = _has_follower(first_version, registry) if not has_sheet_data and has_follower: logger.info("Delete empty version {0}.".format(first_version)) del item["VERSION_0000000"]
def _is_proposal_creation_finished(proposal_version): proposal_item = find_interface(proposal_version, IProposal) versions_with_data = [x for x in proposal_item.values() if IProposalVersion.providedBy(x) and has_annotation_sheet_data(x)] return len(versions_with_data) == 1