mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 12:13:33 +08:00
Make datasets public when pubishing or link access history
This commit is contained in:
@@ -351,6 +351,21 @@ class HistoryManager(sharable.SharableModelManager, deletable.PurgableManagerMix
|
||||
)
|
||||
).first())
|
||||
|
||||
def make_members_public(self, trans, item):
|
||||
""" Make the non-purged datasets in history public.
|
||||
Performs permissions check.
|
||||
"""
|
||||
for hda in item.activatable_datasets:
|
||||
dataset = hda.dataset
|
||||
if not trans.app.security_agent.dataset_is_public(dataset):
|
||||
if trans.app.security_agent.can_manage_dataset(trans.user.all_roles(), dataset):
|
||||
try:
|
||||
trans.app.security_agent.make_dataset_public(hda.dataset)
|
||||
except Exception:
|
||||
log.warning(f"Unable to make dataset with id: {dataset.id} public")
|
||||
else:
|
||||
log.warning(f"User without permissions tried to make dataset with id: {dataset.id} public")
|
||||
|
||||
|
||||
class HistoryExportView:
|
||||
|
||||
|
||||
@@ -360,6 +360,14 @@ class SharableModelManager(base.ModelManager, secured.OwnableManagerMixin, secur
|
||||
to provide the extra information, otherwise, it will be None by default."""
|
||||
return None
|
||||
|
||||
def make_members_public(self, trans, item):
|
||||
""" Make potential elements of this item public.
|
||||
|
||||
This method must be overridden in managers that need to change permissions of internal elements
|
||||
contained associated with the given item.
|
||||
"""
|
||||
pass
|
||||
|
||||
def update_current_sharing_with_users(self, item, new_users_shared_with: Set[User], flush=True):
|
||||
"""Updates the currently list of users this item is shared with by adding new
|
||||
users and removing missing ones."""
|
||||
@@ -672,7 +680,11 @@ class ShareableService:
|
||||
return self._get_sharing_status(trans, item)
|
||||
|
||||
def enable_link_access(self, trans, id: EncodedDatabaseIdField) -> SharingStatus:
|
||||
"""Makes this item accessible by link.
|
||||
If this item contains other elements they will be publicly accessible too.
|
||||
"""
|
||||
item = self._get_item_by_id(trans, id)
|
||||
self.manager.make_members_public(trans, item)
|
||||
self.manager.make_importable(item)
|
||||
return self._get_sharing_status(trans, item)
|
||||
|
||||
@@ -682,7 +694,11 @@ class ShareableService:
|
||||
return self._get_sharing_status(trans, item)
|
||||
|
||||
def publish(self, trans, id: EncodedDatabaseIdField) -> SharingStatus:
|
||||
"""Makes this item publicly accessible.
|
||||
If this item contains other elements they will be publicly accessible too.
|
||||
"""
|
||||
item = self._get_item_by_id(trans, id)
|
||||
self.manager.make_members_public(trans, item)
|
||||
self.manager.publish(item)
|
||||
return self._get_sharing_status(trans, item)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user