<configure
  xmlns="http://namespaces.zope.org/zope"
  xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
  i18n_domain="plone">

  <include file="profiles.zcml" />

  <genericsetup:upgradeSteps
    source="2"
    destination="3"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Correct survey workflow"
      description="Fix problems with copying and pasting of published surveys. This step may take a (very) long time."
      handler=".v2.resetSurveyWorkflow"
      />

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="3"
    destination="4"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Correct publish permissions"
      description="Fix problems with country managers not being able to publish surveys."
      handler=".v2.resetPublishPermission"
      />

    <genericsetup:upgradeStep
      title="Migrate company detail data"
      description="Migrate the company data to split out NL-specific and generic company information."
      handler=".v2.migrateCompanyTable"
      />

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="4"
    destination="5"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Update SQL account model"
      description="Add a terms-and-conditions column to the account table."
      handler=".v2.addTermsAndConditionsColumn"
      />

    <genericsetup:upgradeStep
      title="Update survey workflows"
      description="This step will update the workflows and update the permissions of existing content. This may take a very long time."
      handler=".v2.updateSurveyWorkflow"
      />

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="5"
    destination="6"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add regions"
      description="This step will add new countries and regions to the CMS."
      handler=".v2.updateInitialContent"
      />

    <genericsetup:upgradeStep
      title="Add new SQL tables"
      description="This step will adds the account change table for the client, if it is missing."
      handler=".v2.addAccountChangeTable"
      />

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="6"
    destination="7"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Country groupings"
      description="This step will add grouping data to existing countries."
      handler=".v2.addCountryGrouping"
      />

    <genericsetup:upgradeStep
      title="Add regions"
      description="This step will add new countries and regions to the CMS."
      handler=".v2.updateInitialContent"
      />
  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="7"
    destination="8"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Country groupings"
      description="This step will add grouping data to existing CMS and client countries."
      handler=".v2.addCountryGrouping"
      />

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="8"
    destination="9"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Evaluation types"
      description="This step migrate data in preparation for multiple evaluation method support."
      handler=".v3.set_evaluation_method_interfaces"
      />

    <genericsetup:upgradeStep
      title="Standard solutions"
      description="This step converts the solution description to plain text."
      handler=".v3.convert_solution_description_to_text"
      />

    <genericsetup:upgradeStep
      title="New Company column: 'Workers Participated'"
      description="This step adds a new column 'workers_participated' to the company table."
      handler=".v3.add_wp_column_to_company"
      />

    <genericsetup:upgradeStep
      title="Lowercase all client login names"
      description="This is required for the case-insensitive client logins."
      handler=".v3.lowercase_login"/>
  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="9"
    destination="10"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add description-presence column"
      description="This allows skipping modules without a description in the client."
      handler=".v3.add_has_description_column"/>
  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="10"
    destination="11"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add action plan reference client"
      description="Extend action plan data for API clients."
      handler=".v4.add_actionplan_reference"/>

    <genericsetup:upgradeStep
      title="Allow empty client password"
      description="Allow the client API to create passwordless accounts."
      handler=".v4.allow_empty_password"/>

    <genericsetup:upgradeStep
      title="Configure client API authentication."
      description="Configure authentication for client API users."
      handler=".v4.enable_extra_pas_interfaces"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="11"
    destination="12"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Fix solution titles."
      description="Fix solution titles indexed as title_common_solution"
      handler=".v5.reindex_solution_titles"/>

    <genericsetup:upgradeStep
      title="Reindex rich text descriptions."
      description="IRichDescription fields need to be reindexed to properly catalog HTML entities."
      handler=".v5.reindex_richtext_descriptions"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="12"
    destination="13"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Convert optional profile questions"
      description="Convert all optional profile questions to optional modules."
      handler=".v6.convert_optional_profiles"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="13"
    destination="14"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add skip-evaluation column to SQL model."
      description="This flag is necesary for the fixed-priority evaluation method."
      handler=".v6.add_skip_evaluation_to_model"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="14"
    destination="15"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add 2 new questions to the company survey"
      description="This step will create the necessary columns in the SQL backend."
      handler=".v7.add_columns_to_company_survey"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="15"
    destination="16"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Hash all IUser passwords stored in the ZODB."
      description="This step ensures that passwords for Sectors and Country Managers are hashed."
      handler=".v8.hash_passwords"/>

    <genericsetup:upgradeStep
      title="Register custom password policy"
      description="Euphorie now has a custom password policy"
      handler=".v8.register_password_policy"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="16"
    destination="17"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Indicate whether an account is a guest account, converted from one, or neither."
      description="Add a new column to the Account table to store this."
      handler=".v8.add_column_to_account"/>

    <genericsetup:upgradeStep
      title="Add new column to identify custom risks."
      description="Add a new bool column to the Risk table, is_custom_risk"
      handler=".v8.add_column_for_custom_risks"/>

    <genericsetup:upgradeStep
      title="Allow custom risks"
      description="Allow column risk_id of the Risk table to be nullable."
      handler=".v8.make_risk_id_column_nullable"/>

    <genericsetup:upgradeStep
      title="Allow longer tree item paths"
      description="Make the column zodb_path of the SurveyTreeItems 512 chars (up from 40)."
      handler=".v8.enable_longer_zodb_paths"/>

    <genericsetup:upgradeStep
        title="Allow custom risks on modules"
        description="All published tools are updated to allow users to add custom risks in them. This step requires allow_user_defined_risks=True in euphorie.ini."
        handler=".v8.enable_custom_risks_on_all_modules"/>

    <genericsetup:upgradeStep
        title="Drop constraint `no_duplicates` from table `tree`"
        description="Required for supporting custom risks"
        handler=".v8.drop_constraint_no_duplicates_in_tree"/>
  </genericsetup:upgradeSteps>

  <genericsetup:upgradeStep
    source="17"
    destination="18"
    profile="euphorie.deployment:default"
    title="Force French as language for country France"
    handler=".v9.setCountryLanguageFR"/>

  <genericsetup:upgradeSteps
    source="18"
    destination="19"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add new column to Risk for existing measures"
      handler=".v10.add_column_for_existing_measures"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
    source="19"
    destination="20"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Add new column to Risk for training_notes"
      handler=".v20.add_column_for_training_notes"/>

    <genericsetup:upgradeStep
      title="Update registry for navigation types"
      handler=".v20.update_nav_types_registry"/>

    <genericsetup:upgradeStep
      title="Migrate existing measures"
      handler=".v20.migrate_existing_measures"/>

    <genericsetup:upgradeStep
      title="Extend zodb-path field"
      handler=".v20.extend_zodb_path_field"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeDepends
      source="20"
      destination="21"
      profile="euphorie.deployment:default"
      title="Upgrade profile that includes registry record for invalidating the static resources"
      import_profile="euphorie.deployment.upgrade:to_0021"
      />

  <genericsetup:upgradeDepends
      source="21"
      destination="22"
      profile="euphorie.deployment:default"
      title="Add vocabulary for optional tool category"
      import_profile="euphorie.deployment.upgrade:to_0022"
      />


  <genericsetup:upgradeSteps
    source="22"
    destination="23"
    profile="euphorie.deployment:default"
    >

    <genericsetup:upgradeStep
      title="Update texts for custom risks modules"
      handler=".v23.update_custom_risks_module_texts"/>

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
      destination="24"
      profile="euphorie.deployment:default"
      source="23"
      >

    <genericsetup:upgradeStep
        title="Run Alembic migration"
        description="Check the logs! You might want to adapt the migration to your DB"
        handler=".v24.alembic_upgrade"
        />

    <genericsetup:upgradeDepends
        title="Register new image scales for training"
        import_profile="euphorie.deployment.upgrade:to_0024"
        />

  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
      destination="25"
      profile="euphorie.deployment:default"
      source="24"
      >

    <genericsetup:upgradeStep
        title="Run Alembic migration: add creation date to account"
        description="Check the logs! You might want to adapt the migration to your DB"
        handler=".v25.alembic_upgrade"
        />

    </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
      destination="26"
      profile="euphorie.deployment:default"
      source="25"
      >

    <genericsetup:upgradeStep
        title="Run Alembic migration: add completion_percentage to session"
        description="Check the logs! You might want to adapt the migration to your DB"
        handler=".v26.alembic_upgrade"
        />

    </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
      destination="27"
      profile="euphorie.deployment:default"
      source="26"
      >
    <genericsetup:upgradeStep
        title="Run Alembic migration: extend action plan with plan_type column"
        description="Check the logs! You might want to adapt the migration to your DB"
        handler=".v27.alembic_upgrade"
        />
    <genericsetup:upgradeStep
      title="Unify action fields in solutions"
      handler=".v27.unify_action_fields_in_solution"/>
    <genericsetup:upgradeStep
      title="Unify action fields in solutions (in Client)"
      handler=".v27.unify_action_fields_in_solution_client"/>
    <genericsetup:upgradeStep
      title="Migrate action plans"
      handler=".v27.migrate_actgion_plans"/>
    </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
      destination="28"
      profile="euphorie.deployment:default"
      source="27"
      >
    <genericsetup:upgradeStep
        title="Run Alembic migration: add used_in_training to action_plan"
        description="Check the logs! You might want to adapt the migration to your DB"
        handler=".v28.alembic_upgrade"
        />
  </genericsetup:upgradeSteps>

  <genericsetup:upgradeSteps
      destination="29"
      profile="euphorie.deployment:default"
      source="28"
      >
    <genericsetup:upgradeStep
        title="Run Alembic migration: add 'active' flag to group"
        description="Check the logs! You might want to adapt the migration to your DB"
        handler=".v29.alembic_upgrade"
        />
  </genericsetup:upgradeSteps>

</configure>
