Skip to content

Commit

Permalink
UI, Histories: use /history/view with current to replace /history, mo…
Browse files Browse the repository at this point in the history
…ve history_as_xml to /history/as_xml
  • Loading branch information
carlfeberhard committed Jul 30, 2015
1 parent bf8d74d commit d20add4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 109 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/buildapp.py
Expand Up @@ -73,8 +73,8 @@ def paste_app_factory( global_conf, **kwargs ):
# Create the universe WSGI application
webapp = GalaxyWebApplication( app, session_cookie='galaxysession', name='galaxy' )
webapp.add_ui_controllers( 'galaxy.webapps.galaxy.controllers', app )
# Force /history to go to /root/history -- needed since the tests assume this
webapp.add_route( '/history', controller='root', action='history' )
# Force /history to go to view of current
webapp.add_route( '/history', controller='history', action='view' )
# Force /activate to go to the controller
webapp.add_route( '/activate', controller='user', action='activate' )
# These two routes handle our simple needs at the moment
Expand Down
41 changes: 33 additions & 8 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Expand Up @@ -481,6 +481,27 @@ def citations( self, trans ):
history_id = trans.security.encode_id( history.id )
return trans.fill_template( "history/citations.mako", history=history, history_id=history_id )

@web.expose
def as_xml( self, trans, id=None, show_deleted=None, show_hidden=None ):
"""
Return a history in xml format.
"""
if trans.app.config.require_login and not trans.user:
return trans.fill_template( '/no_access.mako', message='Please log in to access Galaxy histories.' )

if id:
history = self.history_manager.get_accessible( self.decode_id( id ), trans.user,
current_history=trans.history )
else:
history = trans.get_history( create=True )

trans.response.set_content_type( 'text/xml' )
return trans.fill_template_mako(
"history/as_xml.mako",
history=history,
show_deleted=galaxy.util.string_as_bool( show_deleted ),
show_hidden=galaxy.util.string_as_bool( show_hidden ) )

@web.expose
def display_structured( self, trans, id=None ):
"""
Expand Down Expand Up @@ -590,10 +611,6 @@ def view( self, trans, id=None, show_deleted=False, show_hidden=False, use_panel
"""
View a history. If a history is importable, then it is viewable by any user.
"""
# Get history to view.
if not id:
return trans.show_error_message( "You must specify a history you want to view." )

show_deleted = galaxy.util.string_as_bool( show_deleted )
show_hidden = galaxy.util.string_as_bool( show_hidden )
use_panels = galaxy.util.string_as_bool( use_panels )
Expand All @@ -602,8 +619,15 @@ def view( self, trans, id=None, show_deleted=False, show_hidden=False, use_panel
hda_dictionaries = []
user_is_owner = False
try:
history_to_view = self.history_manager.get_accessible( self.decode_id( id ), trans.user, current_history=trans.history )
user_is_owner = history_to_view.user == trans.user
if id:
history_to_view = self.history_manager.get_accessible( self.decode_id( id ), trans.user,
current_history=trans.history )
user_is_owner = history_to_view.user == trans.user
history_is_current = history_to_view == trans.history
else:
history_to_view = trans.history
user_is_owner = True
history_is_current = True

# include all datasets: hidden, deleted, and purged
history_data = self.history_manager._get_history_data( trans, history_to_view )
Expand All @@ -621,8 +645,9 @@ def view( self, trans, id=None, show_deleted=False, show_hidden=False, use_panel
return trans.show_error_message( error_msg, use_panels=use_panels )

return trans.fill_template_mako( "history/view.mako",
history=history_dictionary, hdas=hda_dictionaries, user_is_owner=user_is_owner,
show_deleted=show_deleted, show_hidden=show_hidden, use_panels=use_panels )
history=history_dictionary, hdas=hda_dictionaries,
user_is_owner=user_is_owner, history_is_current=history_is_current,
show_deleted=show_deleted, show_hidden=show_hidden, use_panels=use_panels )

@web.expose
def view_multiple( self, trans, include_deleted_histories=False, order='update' ):
Expand Down
45 changes: 0 additions & 45 deletions lib/galaxy/webapps/galaxy/controllers/root.py
Expand Up @@ -93,51 +93,6 @@ def tool_help( self, trans, id ):
yield "No additional help available for tool '%s'" % tool.name
yield "</body></html>"

# ---- Root history display ---------------------------------------------
def history_as_xml( self, trans, show_deleted=None, show_hidden=None ):
if trans.app.config.require_login and not trans.user:
return trans.fill_template( '/no_access.mako', message='Please log in to access Galaxy histories.' )

history = trans.get_history( create=True )
trans.response.set_content_type('text/xml')
return trans.fill_template_mako(
"root/history_as_xml.mako",
history=history,
show_deleted=string_as_bool( show_deleted ),
show_hidden=string_as_bool( show_hidden ) )

@web.expose
def history( self, trans, as_xml=False, show_deleted=None, show_hidden=None, **kwd ):
"""
Display the current history in its own page or as xml.
"""
if as_xml:
return self.history_as_xml( trans,
show_deleted=string_as_bool( show_deleted ), show_hidden=string_as_bool( show_hidden ) )

if trans.app.config.require_login and not trans.user:
return trans.fill_template( '/no_access.mako', message='Please log in to access Galaxy histories.' )

# get all datasets server-side, client-side will get flags and render appropriately
show_deleted = string_as_bool_or_none( show_deleted )

history_dictionary = {}
hda_dictionaries = []
try:
history_data = self.history_manager._get_history_data( trans, trans.get_history( create=True ) )
history_dictionary = history_data[ 'history' ]
hda_dictionaries = history_data[ 'contents' ]

except Exception, exc:
user_id = str( trans.user.id ) if trans.user else '(anonymous)'
log.exception( 'Error bootstrapping history for user %s: %s', user_id, str( exc ) )
history_dictionary[ 'error' ] = ( 'An error occurred getting the history data from the server. ' +
'Please contact a Galaxy administrator if the problem persists.' )

return trans.fill_template_mako( "root/history.mako",
history=history_dictionary, hdas=hda_dictionaries,
show_deleted=show_deleted, show_hidden=show_hidden )

# ---- Dataset display / editing ----------------------------------------
@web.expose
def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", encoded_id=None, **kwd ):
Expand Down
15 changes: 8 additions & 7 deletions templates/webapps/galaxy/history/view.mako
Expand Up @@ -90,10 +90,10 @@ a.btn {
<div id="history-view-controls">
<div class="pull-left">
%if not history[ 'purged' ]:
%if user_is_owner:
<button id="switch" class="btn btn-default">${ _( 'Switch to this history' ) }</button>
%else:
%if not user_is_owner:
<button id="import" class="btn btn-default"></button>
%elif not history_is_current:
<button id="switch" class="btn btn-default">${ _( 'Switch to this history' ) }</button>
%endif
<a id="structure" href="${ structure_url }" class="btn btn-default">${ _( 'Show structure' ) }</a>
%endif
Expand Down Expand Up @@ -166,6 +166,7 @@ a.btn {
// w/o it renders to the body, w/ it renders to #center - we need to adjust a few things for scrolling to work
var hasMasthead = ${ 'true' if use_panels else 'false' },
userIsOwner = ${ 'true' if user_is_owner else 'false' },
isCurrent = ${ 'true' if history_is_current else 'false' },
historyJSON = ${ h.dumps( history ) },
hdaJSON = ${ h.dumps( hdas ) },
panelToUse = ( userIsOwner )?
Expand All @@ -190,19 +191,19 @@ a.btn {
if( hasMasthead ){
$( '#center' ).css( 'overflow', 'auto' );
}
var panelClass = panelMod[ panelToUse.className ],
// history module is already in the dpn chain from the panel. We can re-scope it here.
historyModel = require( 'mvc/history/history-model' ),
history = new historyModel.History( historyJSON, hdaJSON );
HISTORY = require( 'mvc/history/history-model' ),
historyModel = new HISTORY.History( historyJSON, hdaJSON );
window.historyPanel = new panelClass({
show_deleted : ${show_deleted_json},
show_hidden : ${show_hidden_json},
purgeAllowed : Galaxy.config.allow_user_dataset_purge,
el : $( "#history-" + historyJSON.id ),
$scrollContainer: hasMasthead? function(){ return this.$el.parent(); } : undefined,
model : history
model : historyModel
}).render();
$( '#toggle-deleted' ).on( 'click', function(){
Expand Down
47 changes: 0 additions & 47 deletions templates/webapps/galaxy/root/history.mako

This file was deleted.

0 comments on commit d20add4

Please sign in to comment.