'Updating an installed tool shed repository where new tool dependencies but no new repository
dependencies are included in the updated revision.'

@web.expose
@web.require_admin
def install_tool_dependencies_with_update(self, trans, **kwd):

    updating_repository_id = kwd.get('updating_repository_id', None)
    repository = repository_util.get_installed_tool_shed_repository(trans.app, updating_repository_id)
    encoded_tool_dependencies_dict = kwd.get('encoded_tool_dependencies_dict', None)
    if (encoded_tool_dependencies_dict is not None):
        tool_dependencies_dict = encoding_util.tool_shed_decode(encoded_tool_dependencies_dict)
    else:
        tool_dependencies_dict = {}
    encoded_relative_install_dir = kwd.get('encoded_relative_install_dir', None)
    if (encoded_relative_install_dir is not None):
        relative_install_dir = encoding_util.tool_shed_decode(encoded_relative_install_dir)
    else:
        relative_install_dir = ''
    updating_to_changeset_revision = kwd.get('updating_to_changeset_revision', None)
    updating_to_ctx_rev = kwd.get('updating_to_ctx_rev', None)
    encoded_updated_metadata = kwd.get('encoded_updated_metadata', None)
    message = escape(kwd.get('message', ''))
    status = kwd.get('status', 'done')
    if ('install_tool_dependencies_with_update_button' in kwd):
        if encoded_updated_metadata:
            updated_metadata = encoding_util.tool_shed_decode(encoded_updated_metadata)
        else:
            updated_metadata = None
        repository = trans.app.update_repository_manager.update_repository_record(repository=repository, updated_metadata_dict=updated_metadata, updated_changeset_revision=updating_to_changeset_revision, updated_ctx_rev=updating_to_ctx_rev)
        if tool_dependencies_dict:
            tool_dependencies = tool_dependency_util.create_tool_dependency_objects(trans.app, repository, relative_install_dir, set_status=False)
            message = ("The    installed    repository    named    '%s'    has    been    updated    to    change    set    revision    '%s'.        " % (escape(str(repository.name)), updating_to_changeset_revision))
            self.initiate_tool_dependency_installation(trans, tool_dependencies, message=message, status=status)
    if (trans.app.config.tool_dependency_dir is None):
        if tool_dependencies_dict:
            message = 'Tool    dependencies    defined    in    this    repository    can    be    automatically    installed    if    you    set    the    value    of    your    <b>tool_dependency_dir</b>    setting    in    your    Galaxy    config    file    (galaxy.ini)    and    restart    your    Galaxy    server.'
            status = 'warning'
        install_tool_dependencies_check_box_checked = False
    else:
        install_tool_dependencies_check_box_checked = True
    install_tool_dependencies_check_box = CheckboxField('install_tool_dependencies', checked=install_tool_dependencies_check_box_checked)
    view = views.DependencyResolversView(self.app)
    if view.installable_resolvers:
        install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', checked=True)
    else:
        install_resolver_dependencies_check_box = None
    return trans.fill_template('/admin/tool_shed_repository/install_tool_dependencies_with_update.mako', repository=repository, updating_repository_id=updating_repository_id, updating_to_ctx_rev=updating_to_ctx_rev, updating_to_changeset_revision=updating_to_changeset_revision, encoded_updated_metadata=encoded_updated_metadata, encoded_relative_install_dir=encoded_relative_install_dir, encoded_tool_dependencies_dict=encoded_tool_dependencies_dict, install_resolver_dependencies_check_box=install_resolver_dependencies_check_box, install_tool_dependencies_check_box=install_tool_dependencies_check_box, tool_dependencies_dict=tool_dependencies_dict, message=message, status=status)
