Skip to content

Commit

Permalink
Merge pull request #18200 from davelopez/24.0_fix_make_private_immutable
Browse files Browse the repository at this point in the history
[24.0] Fix `make all histories private` with immutable histories
  • Loading branch information
mvdbeek authored May 22, 2024
2 parents 7ba9471 + ec2bd51 commit eef864a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/components/User/UserPreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export default {
_l(
"WARNING: This will make all datasets (excluding library datasets) for which you have " +
"'management' permissions, in all of your histories " +
"private, and will set permissions such that all " +
"private (including archived and purged), and will set permissions such that all " +
"of your new data in these histories is created as private. Any " +
"datasets within that are currently shared will need " +
"to be re-shared or published. Are you sure you " +
Expand Down
15 changes: 6 additions & 9 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ def display_by_username_and_slug(self, trans, username, slug, **kwargs):
)
)

@web.legacy_expose_api
@web.expose_api
@web.require_login("changing default permissions")
def permissions(self, trans, payload=None, **kwd):
"""
Sets the permissions on a history.
"""
history_id = kwd.get("id")
if not history_id:
return self.message_exception(trans, f"Invalid history id ({str(history_id)}) received")
raise exceptions.RequestParameterMissingException("No history id received")
history = self.history_manager.get_owned(self.decode_id(history_id), trans.user, current_history=trans.history)
if trans.request.method == "GET":
inputs = []
Expand Down Expand Up @@ -166,7 +166,7 @@ def permissions(self, trans, payload=None, **kwd):
trans.app.security_agent.history_set_default_permissions(history, permissions)
return {"message": "Default history '%s' dataset permissions have been changed." % history.name}

@web.legacy_expose_api
@web.expose_api
@web.require_login("make datasets private")
def make_private(self, trans, history_id=None, all_histories=False, **kwd):
"""
Expand All @@ -184,15 +184,14 @@ def make_private(self, trans, history_id=None, all_histories=False, **kwd):
if history:
histories.append(history)
if not histories:
return self.message_exception(trans, "Invalid history or histories specified.")
raise exceptions.RequestParameterMissingException("No history or histories specified.")
private_role = trans.app.security_agent.get_private_user_role(trans.user)
user_roles = trans.user.all_roles()
private_permissions = {
trans.app.security_agent.permitted_actions.DATASET_MANAGE_PERMISSIONS: [private_role],
trans.app.security_agent.permitted_actions.DATASET_ACCESS: [private_role],
}
for history in histories:
self.history_manager.error_unless_mutable(history)
# Set default role for history to private
trans.app.security_agent.history_set_default_permissions(history, private_permissions)
# Set private role for all datasets
Expand All @@ -204,8 +203,6 @@ def make_private(self, trans, history_id=None, all_histories=False, **kwd):
):
# If it's not private to me, and I can manage it, set fixed private permissions.
trans.app.security_agent.set_all_dataset_permissions(hda.dataset, private_permissions)
if not trans.app.security_agent.dataset_is_private_to_user(trans, hda.dataset):
raise exceptions.InternalServerError("An error occurred and the dataset is NOT private.")
return {
"message": f"Success, requested permissions have been changed in {'all histories' if all_histories else history.name}."
}
Expand Down Expand Up @@ -256,12 +253,12 @@ def resume_paused_jobs(self, trans, current=False, ids=None, **kwargs):
return trans.show_ok_message("Your jobs have been resumed.", refresh_frames=refresh_frames)
# TODO: used in index.mako

@web.legacy_expose_api
@web.expose_api
@web.require_login("rename histories")
def rename(self, trans, payload=None, **kwd):
id = kwd.get("id")
if not id:
return self.message_exception(trans, "No history id received for renaming.")
raise exceptions.RequestParameterMissingException("No history id received for renaming.")
user = trans.get_user()
id = listify(id)
histories = []
Expand Down

0 comments on commit eef864a

Please sign in to comment.