From b1084df4424472be2fab4dcd63a6a1a4dcff489a Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 5 Oct 2021 11:40:37 +0200 Subject: [PATCH 1/2] Disable text input for unselected inputs This means they won't be included in the submitted form. Since we just pick the index of a selected dataset name in `extract_steps` this would lead to the wrong inptu dataset label in the workflow editor. Fixes the first issue in https://github.com/galaxyproject/galaxy/issues/12590 --- .../webapps/galaxy/workflow/build_from_current_history.mako | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/webapps/galaxy/workflow/build_from_current_history.mako b/templates/webapps/galaxy/workflow/build_from_current_history.mako index 208c2715a3f..03d1731d4c8 100644 --- a/templates/webapps/galaxy/workflow/build_from_current_history.mako +++ b/templates/webapps/galaxy/workflow/build_from_current_history.mako @@ -33,10 +33,12 @@ $(function() { $("#checkall").click( function() { $("input[type=checkbox]").attr( 'checked', true ); + $(".as-named-input").prop( 'disabled', false ); return false; }).show(); $("#uncheckall").click( function() { $("input[type=checkbox]").attr( 'checked', false ); + $(".as-named-input").prop( 'disabled', true ); return false; }).show(); }); @@ -62,7 +64,8 @@ %if disabled: + name="${data.history_content_type}_ids" value="${data.hid}" checked="true" + onclick="document.getElementById('as-named-input-${ encoded_id }').disabled = !document.getElementById('as-input-${ encoded_id }').checked" /> From 0aaef9c93e5d71b4276f8b3972e20710d7564fdd Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 15 Oct 2021 18:25:39 +0200 Subject: [PATCH 2/2] Continue deleting dataset collection if member HDA has no history These can be cleaned up with pgcleanup. --- lib/galaxy/managers/collections.py | 6 +++++- lib/galaxy/managers/hdas.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/managers/collections.py b/lib/galaxy/managers/collections.py index d6bedec1e4f..58b17f0188b 100644 --- a/lib/galaxy/managers/collections.py +++ b/lib/galaxy/managers/collections.py @@ -255,7 +255,11 @@ class DatasetCollectionManager(object): if recursive: for dataset in dataset_collection_instance.collection.dataset_instances: - self.hda_manager.error_unless_owner(dataset, user=trans.get_user(), current_history=trans.history) + try: + self.hda_manager.error_unless_owner(dataset, user=trans.get_user(), current_history=trans.history) + except hdas.HistoryDatasetAssociationNoHistoryException: + log.info("Cannot delete HistoryDatasetAssociation {}, HistoryDatasetAssociation has no associated History, cannot verify owner".format(dataset.id)) + continue if not dataset.deleted: dataset.deleted = True diff --git a/lib/galaxy/managers/hdas.py b/lib/galaxy/managers/hdas.py index 2673ef53059..7603ba3837a 100644 --- a/lib/galaxy/managers/hdas.py +++ b/lib/galaxy/managers/hdas.py @@ -24,6 +24,10 @@ from galaxy.managers import ( log = logging.getLogger(__name__) +class HistoryDatasetAssociationNoHistoryException(Exception): + pass + + class HDAManager(datasets.DatasetAssociationManager, secured.OwnableManagerMixin, taggable.TaggableManagerMixin, @@ -69,9 +73,11 @@ class HDAManager(datasets.DatasetAssociationManager, """ Use history to see if current user owns HDA. """ - history = hda.history if self.user_manager.is_admin(user, trans=kwargs.get("trans", None)): return True + history = hda.history + if history is None: + raise HistoryDatasetAssociationNoHistoryException # allow anonymous user to access current history # TODO: some dup here with historyManager.is_owner but prevents circ import # TODO: awkward kwarg (which is my new band name); this may not belong here - move to controller?