diff --git a/templates/library/common/browse_library.mako b/templates/library/common/browse_library.mako
index 1d87c09f19e..9bc3037177b 100644
--- a/templates/library/common/browse_library.mako
+++ b/templates/library/common/browse_library.mako
@@ -48,7 +48,6 @@
<%def name="javascripts()">
${parent.javascripts()}
- ${h.js("libs/json2")}
${h.js("libs/jquery/jstorage")}
${common_javascripts()}
${self.grid_javascripts()}
@@ -207,7 +206,7 @@
%def>
-<%def name="render_dataset( cntrller, ldda, library_dataset, can_modify, can_manage, selected, library, folder, pad, parent, row_counter, tracked_datasets, show_deleted=False, simple=False )">
+<%def name="render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, parent, row_counter, tracked_datasets, show_deleted=False, simple=False )">
<%
## The received ldda must always be a LibraryDatasetDatasetAssociation object. The object id passed to methods
## from the drop down menu should be the ldda id to prevent id collision ( which could happen when displaying
@@ -215,14 +214,22 @@
## library_dataset, so we display the attributes from the ldda.
from galaxy.webapps.galaxy.controllers.library_common import branch_deleted
-
+
is_admin = trans.user_is_admin() and cntrller == 'library_admin'
- current_version = ( ldda == library_dataset.library_dataset_dataset_association )
+
+ if ldda == library_dataset.library_dataset_dataset_association:
+ current_version = True
+ if is_admin:
+ can_modify = can_manage = True
+ elif cntrller in [ 'library', 'requests' ]:
+ can_modify = trans.app.security_agent.can_modify_library_item( current_user_roles, library_dataset )
+ can_manage = trans.app.security_agent.can_manage_library_item( current_user_roles, library_dataset )
+ else:
+ can_modify = can_manage = False
+ else:
+ current_version = False
if current_version and ldda.state not in ( 'ok', 'error', 'empty', 'deleted', 'discarded' ):
tracked_datasets[ldda.id] = ldda.state
- # SM: This causes a query to be emitted, but it quickly goes down a
- # rabbit hole of many possible inheritable cases. It may not be
- # possible to easily eliminate the extra query from this call.
info_association, inherited = ldda.get_info_association( restrict=True )
form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
%>
@@ -303,21 +310,9 @@
%endif
%def>
-<%def name="format_delta( tdelta )">
- <%
- from datetime import datetime
- return "%d.%.6d" % ( tdelta.seconds, tdelta.microseconds )
- %>
-%def>
-
<%def name="render_folder( cntrller, folder, folder_pad, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=False, parent=None, row_counter=None, root_folder=False, simple=False )">
<%
- from galaxy.webapps.galaxy.controllers.library_common import active_folders, active_folders_and_library_datasets, activatable_folders_and_library_datasets, map_library_datasets_to_lddas, branch_deleted, datasets_for_lddas
-
- # SM: DELETEME
- from datetime import datetime, timedelta
- import logging
- log = logging.getLogger( __name__ )
+ from galaxy.webapps.galaxy.controllers.library_common import active_folders, active_folders_and_library_datasets, activatable_folders_and_library_datasets, branch_deleted
is_admin = trans.user_is_admin() and cntrller == 'library_admin'
has_accessible_library_datasets = trans.app.security_agent.has_accessible_library_datasets( trans, folder, trans.user, current_user_roles, search_downward=False )
@@ -330,9 +325,6 @@
pad = folder_pad + 20
expander = h.url_for("/static/images/silk/resultset_next.png")
folder_img = h.url_for("/static/images/silk/folder.png")
- # SM: If this is a comma-delimited list of LDDAs, then split them up
- # into a list. For anything else, turn created_ldda_ids into a single
- # item list.
if created_ldda_ids:
created_ldda_ids = util.listify( created_ldda_ids )
if str( folder.id ) in hidden_folder_ids:
@@ -434,39 +426,47 @@
%>
%endif
<%
- # TODO: If show_deleted is set to True, then nothing is displayed. Why? This wasn't the case
- # in the past.
if show_deleted:
sub_folders, library_datasets = activatable_folders_and_library_datasets( trans, folder )
else:
sub_folders, library_datasets = active_folders_and_library_datasets( trans, folder )
- # Render all the subfolders:
- # TODO: Check permissions first.
- for sub_folder in sub_folders:
- render_folder( cntrller, sub_folder, pad, created_ldda_ids, library, [], tracked_datasets, show_deleted=show_deleted, parent=my_row, row_counter=row_counter, root_folder=False )
-
- # Map LibraryDatasets to LDDAs, then map LDDAs to Datasets.
- # Then determine which Datasets are accessible and which are not.
- # For every LibraryDataset, if there's an LDDA for it and it's
- # accessible then display it.
- if ( len( library_datasets ) > 0 ):
- lib_dataset_ldda_map = map_library_datasets_to_lddas( trans, library_datasets )
- dataset_list = datasets_for_lddas( trans, lib_dataset_ldda_map.values() )
- #can_access_datasets = trans.app.security_agent.dataset_access_mapping( trans, current_user_roles, dataset_list )
- can_access_datasets = trans.app.security_agent.dataset_permission_map_for_access( trans, current_user_roles, dataset_list )
- can_modify_datasets = trans.app.security_agent.item_permission_map_for_modify( trans, current_user_roles, dataset_list )
- can_manage_datasets = trans.app.security_agent.item_permission_map_for_manage( trans, current_user_roles, dataset_list )
- for library_dataset in library_datasets:
- ldda = lib_dataset_ldda_map[ library_dataset.id ]
- if ldda:
- # SMTODO: Fix awkard modify/manage permission checks.
- can_access = is_admin or can_access_datasets[ ldda.dataset_id ]
- can_modify = is_admin or ( cntrller in ['library', 'requests'] and can_modify_datasets[ ldda.dataset_id ])
- can_manage = is_admin or ( cntrller in ['library', 'requests'] and can_manage_datasets[ ldda.dataset_id ])
- selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids
- if can_access:
- render_dataset( cntrller, ldda, library_dataset, can_modify, can_manage, selected, library, folder, pad, my_row, row_counter, tracked_datasets, show_deleted=show_deleted )
%>
+ %if is_admin:
+ %for sub_folder in sub_folders:
+ ${render_folder( cntrller, sub_folder, pad, created_ldda_ids, library, [], tracked_datasets, show_deleted=show_deleted, parent=my_row, row_counter=row_counter, root_folder=False )}
+ %endfor
+ %for library_dataset in library_datasets:
+ <%
+ ldda = library_dataset.library_dataset_dataset_association
+ if ldda:
+ # There should always be an ldda, but some users running their own instances have reported that
+ # some of their LibraryDatasets have no associated lddas
+ selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids
+ %>
+ %if ldda:
+ ${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter, tracked_datasets, show_deleted=show_deleted )}
+ %endif
+ %endfor
+ %else:
+ %for sub_folder in sub_folders:
+ ${render_folder( cntrller, sub_folder, pad, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=show_deleted, parent=my_row, row_counter=row_counter, root_folder=False, simple=simple )}
+ %endfor
+ %for library_dataset in library_datasets:
+ <%
+ ldda = library_dataset.library_dataset_dataset_association
+ if ldda:
+ # There should always be an ldda, but some users running their own instances have reported that
+ # some of their LibraryDatasets have no associated lddas
+ can_access = trans.app.security_agent.can_access_dataset( current_user_roles, ldda.dataset )
+ selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids
+ else:
+ can_access = False
+ %>
+ %if can_access:
+ ${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter, tracked_datasets, show_deleted=show_deleted, simple=simple )}
+ %endif
+ %endfor
+ %endif
%def>
<%def name="render_content(simple=False)">
@@ -474,8 +474,6 @@
from galaxy import util
from galaxy.webapps.galaxy.controllers.library_common import branch_deleted
from time import strftime
- import logging
- log = logging.getLogger( __name__ )
is_admin = trans.user_is_admin() and cntrller == 'library_admin'
@@ -491,8 +489,6 @@
info_association, inherited = library.get_info_association()
form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
- # SM: These are mostly display-specific; ignore them for now.
- # The has_accessible_folders determines if anything can be shown - use it.
self.has_accessible_datasets = trans.app.security_agent.has_accessible_library_datasets( trans, library.root_folder, trans.user, current_user_roles )
root_folder_has_accessible_library_datasets = trans.app.security_agent.has_accessible_library_datasets( trans, library.root_folder, trans.user, current_user_roles, search_downward=False )
has_accessible_folders = is_admin or trans.app.security_agent.has_accessible_folders( trans, library.root_folder, trans.user, current_user_roles )
@@ -585,16 +581,13 @@
<% row_counter = RowCounter() %>
- ## SM: Here is where we render the libraries based on admin/non-admin privileges:
%if cntrller in [ 'library', 'requests' ]:
${self.render_folder( 'library', library.root_folder, 0, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=show_deleted, parent=None, row_counter=row_counter, root_folder=True, simple=simple )}
- ## SM: TODO: WTF?
%if not library.deleted and self.has_accessible_datasets and not simple:
${render_actions_on_multiple_items()}
%endif
%elif ( trans.user_is_admin() and cntrller in [ 'library_admin', 'requests_admin' ] ):
${self.render_folder( 'library_admin', library.root_folder, 0, created_ldda_ids, library, [], tracked_datasets, show_deleted=show_deleted, parent=None, row_counter=row_counter, root_folder=True )}
- ## SM: TODO: WTF?
%if not library.deleted and not show_deleted and self.has_accessible_datasets:
${render_actions_on_multiple_items()}
%endif
diff --git a/templates/library/common/browse_library_opt.mako b/templates/library/common/browse_library_opt.mako
new file mode 100644
index 00000000000..1d87c09f19e
--- /dev/null
+++ b/templates/library/common/browse_library_opt.mako
@@ -0,0 +1,622 @@
+<%namespace file="/message.mako" import="render_msg" />
+<%namespace file="/library/common/library_item_info.mako" import="render_library_item_info" />
+<%namespace file="/library/common/common.mako" import="render_actions_on_multiple_items" />
+<%namespace file="/library/common/common.mako" import="render_compression_types_help" />
+<%namespace file="/library/common/common.mako" import="common_javascripts" />
+
+<%!
+ def inherit(context):
+ if context.get('use_panels'):
+ return '/webapps/galaxy/base_panels.mako'
+ else:
+ return '/base.mako'
+%>
+<%inherit file="${inherit(context)}"/>
+
+<%def name="init()">
+<%
+ self.has_left_panel=False
+ self.has_right_panel=False
+ self.message_box_visible=False
+ self.active_view="user"
+ self.overlay_visible=False
+ self.has_accessible_datasets = False
+%>
+%def>
+
+##
+## Override methods from base.mako and base_panels.mako
+##
+<%def name="center_panel()">
+
+
+ ${render_content()}
+
+
+%def>
+
+## Render the grid's basic elements. Each of these elements can be subclassed.
+<%def name="body()">
+ ${render_content()}
+%def>
+
+<%def name="title()">Browse data library%def>
+<%def name="stylesheets()">
+ ${parent.stylesheets()}
+ ${h.css( "library" )}
+%def>
+
+<%def name="javascripts()">
+ ${parent.javascripts()}
+ ${h.js("libs/json2")}
+ ${h.js("libs/jquery/jstorage")}
+ ${common_javascripts()}
+ ${self.grid_javascripts()}
+%def>
+
+<%def name="grid_javascripts()">
+
+%def>
+
+<%def name="render_dataset( cntrller, ldda, library_dataset, can_modify, can_manage, selected, library, folder, pad, parent, row_counter, tracked_datasets, show_deleted=False, simple=False )">
+ <%
+ ## The received ldda must always be a LibraryDatasetDatasetAssociation object. The object id passed to methods
+ ## from the drop down menu should be the ldda id to prevent id collision ( which could happen when displaying
+ ## children, which are always lddas ). We also need to make sure we're displaying the latest version of this
+ ## library_dataset, so we display the attributes from the ldda.
+
+ from galaxy.webapps.galaxy.controllers.library_common import branch_deleted
+
+ is_admin = trans.user_is_admin() and cntrller == 'library_admin'
+ current_version = ( ldda == library_dataset.library_dataset_dataset_association )
+ if current_version and ldda.state not in ( 'ok', 'error', 'empty', 'deleted', 'discarded' ):
+ tracked_datasets[ldda.id] = ldda.state
+ # SM: This causes a query to be emitted, but it quickly goes down a
+ # rabbit hole of many possible inheritable cases. It may not be
+ # possible to easily eliminate the extra query from this call.
+ info_association, inherited = ldda.get_info_association( restrict=True )
+ form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
+ %>
+ %if current_version and ( not ldda.library_dataset.deleted or show_deleted ):
+
+ %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and can_modify:
+ Edit information
+ Move this dataset
+ %else:
+ View information
+ %endif
+ %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and can_modify and not info_association:
+ Use template
+ %endif
+ %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and can_modify and info_association:
+ Edit template
+ Unuse template
+ %endif
+ %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and can_manage:
+ %if not trans.app.security_agent.dataset_is_public( ldda.dataset ):
+ Make public
+ %endif
+ Edit permissions
+ %endif
+ %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and can_modify:
+ Upload a new version of this dataset
+ %endif
+ %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and ldda.has_data:
+ Import this dataset into selected histories
+ Download this dataset
+ %endif
+ %if can_modify:
+ %if not library.deleted and not branch_deleted( folder ) and not ldda.library_dataset.deleted:
+ Delete this dataset
+ %elif not library.deleted and not branch_deleted( folder ) and not ldda.library_dataset.purged and ldda.library_dataset.deleted:
+ Undelete this dataset
+ %endif
+ %endif
+
+ %endif
+ %endif
+
+ % if not simple:
+
${render_library_item_info( ldda )}
+
${ldda.extension}
+ % endif
+
${ldda.create_time.strftime( "%Y-%m-%d" )}
+
${ldda.get_size( nice_size=True )}
+
+ <%
+ my_row = row_counter.count
+ row_counter.increment()
+ %>
+ %endif
+%def>
+
+<%def name="format_delta( tdelta )">
+ <%
+ from datetime import datetime
+ return "%d.%.6d" % ( tdelta.seconds, tdelta.microseconds )
+ %>
+%def>
+
+<%def name="render_folder( cntrller, folder, folder_pad, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=False, parent=None, row_counter=None, root_folder=False, simple=False )">
+ <%
+ from galaxy.webapps.galaxy.controllers.library_common import active_folders, active_folders_and_library_datasets, activatable_folders_and_library_datasets, map_library_datasets_to_lddas, branch_deleted, datasets_for_lddas
+
+ # SM: DELETEME
+ from datetime import datetime, timedelta
+ import logging
+ log = logging.getLogger( __name__ )
+
+ is_admin = trans.user_is_admin() and cntrller == 'library_admin'
+ has_accessible_library_datasets = trans.app.security_agent.has_accessible_library_datasets( trans, folder, trans.user, current_user_roles, search_downward=False )
+
+ if root_folder:
+ pad = folder_pad
+ expander = h.url_for("/static/images/silk/resultset_bottom.png")
+ folder_img = h.url_for("/static/images/silk/folder_page.png")
+ else:
+ pad = folder_pad + 20
+ expander = h.url_for("/static/images/silk/resultset_next.png")
+ folder_img = h.url_for("/static/images/silk/folder.png")
+ # SM: If this is a comma-delimited list of LDDAs, then split them up
+ # into a list. For anything else, turn created_ldda_ids into a single
+ # item list.
+ if created_ldda_ids:
+ created_ldda_ids = util.listify( created_ldda_ids )
+ if str( folder.id ) in hidden_folder_ids:
+ return ""
+ my_row = None
+ if is_admin:
+ can_add = can_modify = can_manage = True
+ elif cntrller in [ 'library' ]:
+ can_access, folder_ids = trans.app.security_agent.check_folder_contents( trans.user, current_user_roles, folder )
+ if not can_access:
+ can_show, folder_ids = \
+ trans.app.security_agent.show_library_item( trans.user,
+ current_user_roles,
+ folder,
+ [ trans.app.security_agent.permitted_actions.LIBRARY_ADD,
+ trans.app.security_agent.permitted_actions.LIBRARY_MODIFY,
+ trans.app.security_agent.permitted_actions.LIBRARY_MANAGE ] )
+ if not can_show:
+ return ""
+ can_add = trans.app.security_agent.can_add_library_item( current_user_roles, folder )
+ can_modify = trans.app.security_agent.can_modify_library_item( current_user_roles, folder )
+ can_manage = trans.app.security_agent.can_manage_library_item( current_user_roles, folder )
+ else:
+ can_add = can_modify = can_manage = False
+
+ form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
+ info_association, inherited = folder.get_info_association( restrict=True )
+ %>
+ %if not root_folder and ( not folder.deleted or show_deleted ):
+ <% encoded_id = trans.security.encode_id( folder.id ) %>
+
+
+ %if message:
+ ${render_msg( message, status )}
+ %endif
+
+ %if library.synopsis not in [ '', 'None', None ]:
+
+ ${library.synopsis}
+
+ %endif
+
+ %if self.has_accessible_datasets:
+
+ %endif
+
+ %if tracked_datasets:
+
+
+ %endif
+
+ %if self.has_accessible_datasets and not simple:
+ ${render_compression_types_help( comptypes )}
+ %endif
+ %if not has_accessible_folders:
+ The data library '${library.name}' does not contain any datasets that you can access.
+ %endif
+%def>