Skip to content

Commit

Permalink
Add history import
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Nov 11, 2017
1 parent 6879507 commit f776229
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
21 changes: 21 additions & 0 deletions lib/galaxy/webapps/galaxy/api/histories.py
Expand Up @@ -434,6 +434,27 @@ def update(self, trans, id, payload, **kwd):
return self.history_serializer.serialize_to_view(history,
user=trans.user, trans=trans, **self._parse_serialization_params(kwd, 'detailed'))

@expose_api
def archive_import(self, trans, **kwds):
"""
archive_import(self, trans, **kwds):
* POST /api/histories/archive_import:
import a history from file
"""
archive_file = kwds.get('archive_file')
archive_url = kwds.get('archive_url')
archive_source = None
if hasattr(archive_file, 'file'):
archive_source = archive_file.file.name
archive_type = 'file'
elif archive_url:
archive_source = archive_url
archive_type = 'url'
else:
raise exceptions.MessageException("Specify the archive file or url.")
self.queue_history_import(trans, archive_type=archive_type, archive_source=archive_source)
return "Importing history from '%s'. This history will be visible when the import is complete." % archive_source

@expose_api
def archive_export(self, trans, id, **kwds):
"""
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/webapps/galaxy/buildapp.py
Expand Up @@ -237,6 +237,7 @@ def populate_api_routes(webapp, app):
path_prefix='/api/histories/{history_id}/contents/{history_content_id}')
webapp.mapper.connect('/api/histories/published', action='published', controller="histories", conditions=dict(method=["GET"]))
webapp.mapper.connect('/api/histories/shared_with_me', action='shared_with_me', controller="histories")
webapp.mapper.connect('/api/histories/archive_import', action='archive_import', controller="histories", conditions=dict(method=["POST"]))
_add_item_tags_controller(webapp,
name_prefix="history_",
path_prefix='/api/histories/{history_id}')
Expand Down
27 changes: 0 additions & 27 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Expand Up @@ -1193,33 +1193,6 @@ def rate_async(self, trans, id, rating):
return self.get_ave_item_rating_data(trans.sa_session, history)
# TODO: used in display_base.mako

@web.expose
# TODO: Remove require_login when users are warned that, if they are not
# logged in, this will remove their current history.
@web.require_login("use Galaxy histories")
def import_archive(self, trans, **kwargs):
""" Import a history from a file archive. """
# Set archive source and type.
archive_file = kwargs.get('archive_file', None)
archive_url = kwargs.get('archive_url', None)
archive_source = None
if hasattr(archive_file, 'file'):
archive_source = archive_file.file.name
archive_type = 'file'
elif archive_url:
archive_source = archive_url
archive_type = 'url'
# If no source to create archive from, show form to upload archive or specify URL.
if not archive_source:
form = web.FormBuilder(web.url_for(controller='history', action='import_archive'), "Import a History from an Archive", submit_text="Submit")
form.add_input("text", "Archived History URL", "archive_url", value="", error=None)
form.add_input("file", "Archived History File", "archive_file", value="", error=None)
return trans.show_form(form)
self.queue_history_import(trans, archive_type=archive_type, archive_source=archive_source)
return trans.show_message("Importing history from '%s'. \
This history will be visible when the import is complete" % archive_source)
# TODO: used in this file and index.mako

@web.expose
def export_archive(self, trans, id=None, gzip=True, include_hidden=False, include_deleted=False, preview=False):
""" Export a history to an archive. """
Expand Down
2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

0 comments on commit f776229

Please sign in to comment.