def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # The assignment of the whole Calculation object in a metadata column # was causing a "TypeError: Can't pickle objects in acquisition wrappers". # getCalculation was only used in analyses listing and can be safely # replaced by getCalculationUID, cause is only used to determine if a # calculation is required to compute the result value # https://github.com/senaite/bika.lims/issues/322 ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getCalculation') ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getCalculationUID') ut.refreshCatalogs() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Remove QC reports and gpw dependency # https://github.com/senaite/senaite.core/pull/1058 remove_qc_reports(portal) # Remove updates notification viewlet # https://github.com/senaite/senaite.core/pull/1059 setup.runImportStepFromProfile(profile, 'viewlets') # Remove old portlets except the navigation portlet # https://github.com/senaite/senaite.core/pull/1060 purge_portlets(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- fix_workflow_transitions(portal) # Migration to senaite.core setup = portal.portal_setup setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') setup.runImportStepFromProfile('profile-bika.lims:default', 'propertiestool') rename_bika_setup() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- # Issue #574: Client batch listings are dumb. This requires Batches to # be reindexed, as thy now provide an accessor for getClientUID. reindex_batch_getClientUID(portal) # The catalog where worksheets are stored (bika_catalog_worksheet_listing) # had a FieldIndex "WorksheetTemplate" which was causing a TypeError (can't # pickle acquisition wrappers) when reindexing worksheets with an associated # Worksheet Template. fix_worksheet_template_index(portal, ut) # Adds an entry to the registry to store the roles that can see Samples # section from Dashboard add_sample_section_in_dashboard(portal) # Ability to choose the sticker templates based on sample types (#607) set_sample_type_default_stickers(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- # Issue #574: Client batch listings are dumb. This requires Batches to # be reindexed, as thy now provide an accessor for getClientUID. reindex_batch_getClientUID(portal) # The catalog where worksheets are stored (bika_catalog_worksheet_listing) # had a FieldIndex "WorksheetTemplate" which was causing a TypeError (can't # pickle acquisition wrappers) when reindexing worksheets with an associated # Worksheet Template. fix_worksheet_template_index(portal, ut) # Adds an entry to the registry to store the roles that can see Samples # section from Dashboard add_sample_section_in_dashboard(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Do not display clients folder to Clients. There is no need to do an # update-role-mappings of clients, cause the permissions at client level # have not changed, except that now they are acquire=1 for "active" status setup.runImportStepFromProfile(profile, "workflow") wf_tool = api.get_tool("portal_workflow") workflow = wf_tool.getWorkflowById("senaite_clients_workflow") workflow.updateRoleMappingsFor(portal.clients) portal.clients.reindexObject() # New link to My Organization setup.runImportStepFromProfile(profile, "actions") logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # The assignment of the whole Calculation object in a metadata column # was causing a "TypeError: Can't pickle objects in acquisition wrappers". # getCalculation was only used in analyses listing and can be safely # replaced by getCalculationUID, cause is only used to determine if a # calculation is required to compute the result value # https://github.com/senaite/bika.lims/issues/322 ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getCalculation') ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getCalculationUID') ut.refreshCatalogs() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- # Ensure health's skins have always priority over core's setup = portal.portal_setup setup.runImportStepFromProfile(profile, "skins") setup.runImportStepFromProfile(profile, 'workflow') setup.runImportStepFromProfile(profile, "typeinfo") # Allow clients to list, add and edit doctors apply_doctor_permissions_for_clients(portal, ut) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- ut.delIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatient') ut.delIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctor') ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientID') ut.addIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientTitle', 'FieldIndex') # In case if upgrade was already run after PR #72 got accepted ut.delColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientURL') ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientURL') ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getClientPatientID') ut.addIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctorTitle', 'FieldIndex') # In case if upgrade was already run after PR #72 got accepted ut.delColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctorURL') ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctorURL') ut.addIndex(CATALOG_PATIENTS, 'listing_searchable_text', 'TextIndexNG3') ut.refreshCatalogs() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Allow to detach a partition from its primary sample (#1420) setup.runImportStepFromProfile(profile, "rolemap") # Mixed permissions for transitions in client workflow (#1419) # Allow to detach a partition from its primary sample (#1420) setup.runImportStepFromProfile(profile, "workflow") # Allow to detach a partition from its primary sample (#1420) update_partitions_role_mappings(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PRODUCT_NAME) if ut.isOlderVersion(PRODUCT_NAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PRODUCT_NAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PRODUCT_NAME, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Compatibility with "Fix error when creating a partition as analyst user", # that reimports the worklflow tool and do an updateRoleMappings for Samples # that are in "received" status. Since senaite.storage "overrides" the # definition the sample_workflow, there is the need to setup workflow again # https://github.com/senaite/senaite.core/pull/1525 setup_workflows(portal) update_wf_received_samples(portal) logger.info("{0} upgraded to version {1}".format(PRODUCT_NAME, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Required because of a mismatch between the view and workflow states # selector in Analysis Services view. See @93109be setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') # Remove indexes no longer used as per @daf57e3 and PR#307 ut.delIndexAndColumn('bika_setup_catalog', 'getSortKey') ut.delIndexAndColumn('bika_setup_catalog', 'sortKey') # Add sortable_title index in analyses catalog, so analyses get sorted # automatically based on the same rules as Analysis Services do (PR#307): # sortkey + title ascending ut.addIndex(CATALOG_ANALYSIS_LISTING, 'sortable_title', 'FieldIndex') ut.refreshCatalogs() # Do nothing, we just only want the profile version to be 1.0.0 logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PRODUCT_NAME) if ut.isOlderVersion(PRODUCT_NAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PRODUCT_NAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PRODUCT_NAME, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # https://github.com/senaite/senaite.queue/pull/3 setup.runImportStepFromProfile(PROFILE_ID, "plone.app.registry") setup.runImportStepFromProfile(PROFILE_ID, "actions") # Remove queue dispatcher utility, that is no longer used setup.runImportStepFromProfile(PROFILE_ID, "componentregistry") remove_queue_dispatcher_utility(portal) logger.info("{0} upgraded to version {1}".format(PRODUCT_NAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- # Unbound the worksheetanalysis_workflow from Analysis Requests and add a # FieldIndex 'assigned_state' in AR's catalog (for its use on searches) fix_assign_analysis_requests(portal, ut) # The number of QC Analyses is not refreshed when a Duplicate or Reference # Sample in a Worksheet. See #673. Thus, worksheets that are not yet in # to_be_verified state needs to be reindexed fix_worksheet_qc_number_analyses_inconsistences(portal, ut) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Required because of a mismatch between the view and workflow states # selector in Analysis Services view. See @93109be setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') # Remove indexes no longer used as per @daf57e3 and PR#307 ut.delIndexAndColumn('bika_setup_catalog', 'getSortKey') ut.delIndexAndColumn('bika_setup_catalog', 'sortKey') # Add sortable_title index in analyses catalog, so analyses get sorted # automatically based on the same rules as Analysis Services do (PR#307): # sortkey + title ascending ut.addIndex(CATALOG_ANALYSIS_LISTING, 'sortable_title', 'FieldIndex') ut.refreshCatalogs() # Do nothing, we just only want the profile version to be 1.0.0 logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) setup = portal.portal_setup if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- setup.runImportStepFromProfile(profile, 'catalog') setup.runImportStepFromProfile(profile, 'workflow') # Revert upgrade actions performed due to #893 (reverted) revert_client_permissions_for_batches(portal) # re-apply the permission for the view tabs on clients setup.runImportStepFromProfile(profile, 'typeinfo') # re-apply the permissions from the client workflow + reindex fix_client_permissions(portal) fix_items_stuck_in_sample_prep_states(portal, ut) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Allow to detach a partition from its primary sample (#1420) setup.runImportStepFromProfile(profile, "rolemap") # Mixed permissions for transitions in client workflow (#1419) # Allow to detach a partition from its primary sample (#1420) setup.runImportStepFromProfile(profile, "workflow") # Allow to detach a partition from its primary sample (#1420) update_partitions_role_mappings(portal) # Unindex stale catalog brains from the auditlog_catalog # https://github.com/senaite/senaite.core/issues/1438 unindex_orphaned_brains_in_auditlog_catalog(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PRODUCT_NAME) if ut.isOlderVersion(PRODUCT_NAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PRODUCT_NAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PRODUCT_NAME, ver_from, version)) # Re-import the registry profile to add new settings in control panel setup.runImportStepFromProfile(PROFILE_ID, "plone.app.registry") # Reset control panel settings to defaults reset_settings(portal) # Port old storage mechanism remove_legacy_storage(portal) # Install the PAS Plugin to allow authenticating tasks as their creators setup_pas_plugin(portal) # Create and store the key to use for auth reset_auth_key(portal) logger.info("{0} upgraded to version {1}".format(PRODUCT_NAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- # Ensure health's skins have always priority over core's setup = portal.portal_setup setup.runImportStepFromProfile(profile, "skins") setup.runImportStepFromProfile(profile, 'workflow') setup.runImportStepFromProfile(profile, "typeinfo") # Allow clients to list, add and edit doctors apply_doctor_permissions_for_clients(portal, ut) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- setup.runImportStepFromProfile(profile, "actions") setup.runImportStepFromProfile(profile, "rolemap") setup.runImportStepFromProfile(profile, "workflow") setup.runImportStepFromProfile(profile, "typeinfo") setup.runImportStepFromProfile(profile, "toolset") setup.runImportStepFromProfile(profile, "content") setup.runImportStepFromProfile(profile, "controlpanel") # Remove alls Samples and Partition # https://github.com/senaite/senaite.core/pull/1359 remove_samples_and_partitions(portal) # Convert inline images # https://github.com/senaite/senaite.core/issues/1333 convert_inline_images_to_attachments(portal) # https://github.com/senaite/senaite.core/pull/1324 # initialize auditlogging setup_auditlog_catalog(portal) init_auditlog(portal) remove_log_action(portal) # Mark objects based on the transitions performed to them # https://github.com/senaite/senaite.core/pull/1330 mark_transitions_performed(portal) # Reindex sortable_title to make sorting case-insenstive # https://github.com/senaite/senaite.core/pull/1337 reindex_sortable_title(portal) # Remove unnecessary indexes/metadata from worksheet catalog # https://github.com/senaite/senaite.core/pull/1362 cleanup_worksheet_catalog(portal) # Apply permissions for Manage Worksheets # https://github.com/senaite/senaite.core/issues/1387 update_worksheet_manage_permissions(api.get_setup()) # Add getInternalUse metadata # https://github.com/senaite/senaite.core/pull/1391 catalog = api.get_tool(CATALOG_ANALYSIS_REQUEST_LISTING) catalog.addColumn("getInternalUse") logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PROJECTNAME) if ut.isOlderVersion(PROJECTNAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PROJECTNAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PROJECTNAME, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Added action "batches" for Doctor type setup.runImportStepFromProfile(profile, "typeinfo") # Added InternalClient role setup.runImportStepFromProfile(DEFAULT_PROFILE_ID, "rolemap") # Added new state "shared" in patient_workflow, doctor_workflow setup.runImportStepFromProfile(DEFAULT_PROFILE_ID, "workflow") # Setup custom workflows (Batch) setup_workflows(portal) # Setup internal clients top-level folder setup_internal_clients(portal) # Sort navigation bar sort_nav_bar(portal) # Reindex the top level folder in the portal and setup to fix missing icons reindex_content_structure(portal) # Hide Doctor items from navigation bar hide_doctors_from_navbar(portal) # Add batches action in Doctor context sort_doctor_actions(portal) # Setup groups (new group "InternalClient") setup_user_groups(portal) # Allow Patients and Doctors inside Clients allow_patients_inside_clients(portal) allow_doctors_inside_clients(portal) # Move doctors to clients move_doctors_to_clients(portal) # Update workflows for shareable objects (Patient, Doctor, Batch) update_rolemappings_for_shareable(portal) logger.info("{0} upgraded to version {1}".format(PROJECTNAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- # Display supplier view instead of reference samples per default # https://github.com/senaite/senaite.core/pull/1037 setup.runImportStepFromProfile(profile, 'typeinfo') # Delete orphaned Attachments # https://github.com/senaite/senaite.core/issues/1025 delete_orphaned_attachments(portal) # Migrate report option from attach (a) -> ignore (i) # https://github.com/senaite/senaite.core/pull/992 migrate_attachment_report_options(portal) # Reindex object security for client contents # https://github.com/senaite/senaite.core/pull/991 reindex_client_local_owner_permissions(portal) # Rename "retract_ar" transition to "invalidate" # https://github.com/senaite/senaite.core/pull/1027 rename_retract_ar_transition(portal) # Rebind ARs that were generated because of the invalidation of other ARs # https://github.com/senaite/senaite.core/pull/1027 rebind_invalidated_ars(portal) # Reindex Turnaround time and due date related fields # https://github.com/senaite/senaite.core/pull/1032 recatalog_analyses_due_date(portal) # Update workflow states and permissions for AR/Sample rejection # https://github.com/senaite/senaite.core/pull/1041 update_rejection_permissions(portal) # Remove getLate and add getDueDate metadata in ar_catalog # https://github.com/senaite/senaite.core/pull/1051 update_analaysisrequests_due_date(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PROJECTNAME) if ut.isOlderVersion(PROJECTNAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PROJECTNAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PROJECTNAME, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- setup.runImportStepFromProfile(profile, "browserlayer") setup.runImportStepFromProfile(profile, "typeinfo") setup.runImportStepFromProfile(profile, "skins") # Setup catalogs setup_catalogs(CATALOGS_BY_TYPE, INDEXES, COLUMNS) # Remove indexes and metadata columns remove_indexes_and_metadata() # Setup permissions setup_roles_permissions(portal) # Setup ID Formatting setup_id_formatting(portal) # Add "Patients" and "Doctors" action views in Client type setup_content_actions(portal) # Remove "Samples" action views from Doctors and Patients remove_sample_actions(portal) # Setup "Owner" roles for patients to client contacts setup_patients_ownership(portal) # Setup "Owner" roles for batches to client contacts setup_batches_ownership(portal) # Update workflows update_workflows(portal) # remove stale CSS remove_stale_css(portal) logger.info("{0} upgraded to version {1}".format(PROJECTNAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PROJECTNAME) if ut.isOlderVersion(PROJECTNAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PROJECTNAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PROJECTNAME, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- setup.runImportStepFromProfile(profile, "browserlayer") setup.runImportStepFromProfile(profile, "typeinfo") setup.runImportStepFromProfile(profile, "skins") # Setup catalogs setup_catalogs(CATALOGS_BY_TYPE, INDEXES, COLUMNS) # Remove indexes and metadata columns remove_indexes_and_metadata() # Setup permissions setup_roles_permissions(portal) # Setup ID Formatting setup_id_formatting(portal) # Add "Patients" and "Doctors" action views in Client type setup_content_actions(portal) # Remove "Samples" action views from Doctors and Patients remove_sample_actions(portal) # Setup "Owner" roles for patients to client contacts setup_patients_ownership(portal) # Setup "Owner" roles for batches to client contacts setup_batches_ownership(portal) # Update workflows update_workflows(portal) # remove stale CSS remove_stale_css(portal) logger.info("{0} upgraded to version {1}".format(PROJECTNAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- # Do not display clients folder to Clients. There is no need to do an # update-role-mappings of clients, cause the permissions at client level # have not changed, except that now they are acquire=1 for "active" status setup.runImportStepFromProfile(profile, "workflow") wf_tool = api.get_tool("portal_workflow") workflow = wf_tool.getWorkflowById("senaite_clients_workflow") workflow.updateRoleMappingsFor(portal.clients) portal.clients.reindexObject() # New link to My Organization setup.runImportStepFromProfile(profile, "actions") # Remove getObjectWorkflowStates metadata # https://github.com/senaite/senaite.core/pull/1579 remove_object_workflow_states_metadata(portal) # Added "senaite.core: Transition: Retest" permission for analyses # Added transition "retest" in analysis workflow # https://github.com/senaite/senaite.core/pull/1580 setup.runImportStepFromProfile(profile, "rolemap") setup.runImportStepFromProfile(profile, "workflow") update_workflow_mappings_for_to_be_verified(portal) # Unset/set specifications with dynamic results ranges assigned # https://github.com/senaite/senaite.core/pull/1588 update_dynamic_analysisspecs(portal) # Users with Publisher role cannot publish samples update_workflow_mappings_contacts(portal) update_workflow_mappings_labcontacts(portal) update_workflow_mappings_samples(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Required to make filtering by department in worksheets work ut.addIndex(CATALOG_WORKSHEET_LISTING, 'getDepartmentUIDs', 'KeywordIndex') # Required by https://github.com/senaite/senaite.core/issues/683 ut.addIndexAndColumn('bika_catalog', 'getBatchUIDs', 'KeywordIndex') # Required by https://github.com/senaite/senaite.core/pulls/752 ut.delIndex(CATALOG_ANALYSIS_LISTING, 'getDateAnalysisPublished') ut.refreshCatalogs() # % Error subfield is meaningless in result ranges. Also, the system was # calculating the %Error based on the result (not based on the range), so # the shoulder from the left was always smaller than the shoulder from the # right. One could argue that this could be fixed easily by using the length # of the valid range to compute the shoulders by using the %error. Again, # this is a weak solution, cause in some cases the scale of the range might # be exponential, logaritmic (e.g. pH). Also, the sensitivity of the test # may differ when the result falls in one end or another. Thus, is for the # best interest of the labmanger to be able to set the shoulders (and # therefore, when the warnings must show up) manually. # See PR#694 remove_error_subfield_from_analysis_specs(portal, ut) # Reindex ReferenceAnalysis because of Calculation and Interims fields have # been added to Controls and Blanks. Until now, only routine analyses allowed # Calculations and Interim fields # Required by https://github.com/senaite/senaite.core/issues/735 reindex_reference_analysis(portal, ut) # reload type profiles so that the fix for # https://github.com/senaite/senaite.core/issues/590 # becomes effective setup = portal.portal_setup setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PROJECTNAME) if ut.isOlderVersion(PROJECTNAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PROJECTNAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PROJECTNAME, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- setup.runImportStepFromProfile(DEFAULT_PROFILE_ID, "skins") setup.runImportStepFromProfile(DEFAULT_PROFILE_ID, "jsregistry") # Install senaite.panic add-on if not yet installed install_senaite_panic(portal) # Setup template text for panic level alert emails # https://github.com/senaite/senaite.health/pull/161 setup_panic_alerts(portal) # Update Sample's PanicEmailAlertSent field # https://github.com/senaite/senaite.health/pull/161 update_sample_panic_alert_field(portal) # Allow Patient content type inside Client # Note: this should always be run if core's typestool is reimported allow_patients_inside_clients(portal) # Remove stale javascripts remove_stale_javascripts(portal) # Remove stale css remove_stale_css(portal) # Fix email addresses # https://github.com/senaite/senaite.health/pulls/172 fix_health_email_addresses(portal) # Remove stale catalog columns remove_stale_metadata(portal) logger.info("{0} upgraded to version {1}".format(PROJECTNAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(PRODUCT_NAME) if ut.isOlderVersion(PRODUCT_NAME, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( PRODUCT_NAME, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(PRODUCT_NAME, ver_from, version)) logger.info("{0} upgraded to version {1}".format(PRODUCT_NAME, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Do nothing, we just only want the profile version to be 1.1.0 logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) ut.addIndex(CATALOG_PATIENTS, 'getClientPatientID', 'FieldIndex') ut.refreshCatalogs() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) ut.addIndex(CATALOG_PATIENTS, 'getClientPatientID', 'FieldIndex') ut.refreshCatalogs() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- ut.cleanAndRebuildCatalog(CATALOG_ANALYSIS_REQUEST_LISTING) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Convert ReferenceField's values into UIDReferenceFields. UpgradeReferenceFields() # Calculations not triggered in manage results view # https://github.com/senaite/bika.lims/issues/355 # Since we've already migrated the ReferenceField DependentServices from # Calculation (with relation name 'CalculationAnalysisService' above, this # wouldn't be strictly necessary, but who knows... maybe we've lost the # at_references too, so just do it. fix_broken_calculations() # Backward compatibility with < 1.0.0 RemoveARPriorities(portal) RemoveVersionableTypes() handle_AS_wo_category(portal) migrateFileFields(portal) # Indexes and colums were changed as per # https://github.com/senaite/bika.lims/pull/353 ut.delIndex(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestUID') ut.addIndex(CATALOG_ANALYSIS_LISTING, 'getRequestUID', 'FieldIndex') ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestURL') ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestTitle') ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestURL') ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestTitle') ut.reindexIndex(CATALOG_ANALYSIS_LISTING, 'getPrioritySortkey') ut.refreshCatalogs() return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Convert ReferenceField's values into UIDReferenceFields. UpgradeReferenceFields() # Calculations not triggered in manage results view # https://github.com/senaite/bika.lims/issues/355 # Since we've already migrated the ReferenceField DependentServices from # Calculation (with relation name 'CalculationAnalysisService' above, this # wouldn't be strictly necessary, but who knows... maybe we've lost the # at_references too, so just do it. fix_broken_calculations() # Backward compatibility with < 1.0.0 RemoveARPriorities(portal) RemoveVersionableTypes() handle_AS_wo_category(portal) migrateFileFields(portal) # Indexes and colums were changed as per # https://github.com/senaite/bika.lims/pull/353 ut.delIndex(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestUID') ut.addIndex(CATALOG_ANALYSIS_LISTING, 'getRequestUID', 'FieldIndex') ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestURL') ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestTitle') ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestURL') ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestTitle') ut.reindexIndex(CATALOG_ANALYSIS_LISTING, 'getPrioritySortkey') ut.refreshCatalogs() return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF BELOW -------- setup.runImportStepFromProfile(profile, 'browserlayer') logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) setup = portal.portal_setup if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- setup.runImportStepFromProfile(profile, 'workflow') update_permissions_rejected_analysis_requests() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) # Since this upgrade is precisely meant to establish a version regardless # of the version numbering at bikalims/bika.health, we don't want this check # to be performed. # if ut.isOlderVersion(product, version): # logger.info("Skipping upgrade of {0}: {1} > {2}".format( # product, ufrom, version)) # # The currently installed version is more recent than the target # # version of this upgradestep # return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Do nothing, we just only want the profile version to be 1.0.0 logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Sync the empty number generator with existing content prepare_number_generator(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- set_guards_to_inactive_workflow() fix_service_status_inconsistences() fix_service_profile_template_inconsistences() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- setup = portal.portal_setup setup.runImportStepFromProfile('profile-bika.lims:default', 'plone.app.registry') upgrade_indexes() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Add inactive_state workflow for Reflex Rules setup.runImportStepFromProfile(profile, 'workflow') update_reflexrules_workflow_state(portal) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Attachments must be present in a catalog, otherwise the idserver # will fall apart. https://github.com/senaite/bika.lims/issues/323 at = getToolByName(portal, 'archetype_tool') at.setCatalogsByType('Attachment', ['portal_catalog']) logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = aq_parent(aq_inner(tool)) setup = portal.portal_setup ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) # The currently installed version is more recent than the target # version of this upgradestep return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # Reindex getPrioritySortkey index. The priority sort key from analyses # takes also into account analyses have to be sorted by their sortkey, so # two analyses with same priority, same AR, but different sort key values # don't get mixed. ut.reindexIndex(CATALOG_ANALYSIS_LISTING, 'getPrioritySortkey') ut.refreshCatalogs() logger.info("{0} upgraded to version {1}".format(product, version)) return True
def upgrade(tool): portal = tool.aq_inner.aq_parent ut = UpgradeUtils(portal) ver_from = ut.getInstalledVersion(product) if ut.isOlderVersion(product, version): logger.info("Skipping upgrade of {0}: {1} > {2}".format( product, ver_from, version)) return True logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) # -------- ADD YOUR STUFF HERE -------- fix_workflow_transitions(portal) # Migration to senaite.core setup = portal.portal_setup setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo') setup.runImportStepFromProfile('profile-bika.lims:default', 'propertiestool') rename_bika_setup() logger.info("{0} upgraded to version {1}".format(product, version)) return True