2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b76dd608c500/ Changeset: b76dd608c500 User: guerler Date: 2014-01-16 20:10:32 Summary: Charts: Add configuration model, link all view functions to model events Affected #: 8 files diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/app.js --- a/config/plugins/visualizations/charts/static/app.js +++ b/config/plugins/visualizations/charts/static/app.js @@ -1,10 +1,10 @@ // dependencies define(['library/portlet', 'library/ui', 'library/utils', 'views/charts', 'views/viewport', 'views/chart', 'views/group', - 'models/datasets', 'models/chart', 'models/charts', 'models/types'], + 'models/config', 'models/datasets', 'models/chart', 'models/charts', 'models/group', 'models/types'], function( Portlet, Ui, Utils, ChartsView, ViewportView, ChartView, GroupView, - Datasets, Chart, Charts, Types + Config, Datasets, Chart, Charts, Group, Types ) { // widget @@ -19,10 +19,14 @@ // link galaxy this.modal = parent.Galaxy.modal; + // create configuration model + this.config = new Config(); + // create chart models this.types = new Types(); this.chart = new Chart(); this.charts = new Charts(); + this.group = new Group(); // create dataset handler this.datasets = new Datasets(this); diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/models/chart.js --- a/config/plugins/visualizations/charts/static/models/chart.js +++ b/config/plugins/visualizations/charts/static/models/chart.js @@ -22,8 +22,9 @@ // reset reset: function() { - this.clear().set(this.defaults); + this.clear({silent: true}).set(this.defaults); this.groups.reset(); + this.trigger('reset', this); }, // copy diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/models/config.js --- /dev/null +++ b/config/plugins/visualizations/charts/static/models/config.js @@ -0,0 +1,16 @@ +// dependencies +define([], function() { + + +// model +return Backbone.Model.extend( +{ + // options + defaults : { + query_limit : 20, + query_pace : 1000, + query_max : 5 + } +}); + +}); \ No newline at end of file diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/models/group.js --- a/config/plugins/visualizations/charts/static/models/group.js +++ b/config/plugins/visualizations/charts/static/models/group.js @@ -1,23 +1,14 @@ // dependencies -define(['library/utils'], function(Utils) { - +define([], function() { // model return Backbone.Model.extend( { - // defaults - defaults : { - }, - - // initialize - initialize: function(options) - { - }, - // reset reset: function() { - this.clear().set(this.defaults); + this.clear({silent: true}).set(this.defaults); + this.trigger('reset', this); } }); diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/views/chart.js --- a/config/plugins/visualizations/charts/static/views/chart.js +++ b/config/plugins/visualizations/charts/static/views/chart.js @@ -125,6 +125,9 @@ this.chart.on('change:type', function(chart) { self.table.value(chart.get('type')); }); + this.chart.on('reset', function(chart) { + self._resetChart(); + }); // collection events this.app.charts.on('add', function(chart) { @@ -140,23 +143,17 @@ }); // reset - this.reset(); + this._resetChart(); }, // reset - reset: function() { - this.chart.reset(); + _resetChart: function() { this.chart.set('id', Utils.uuid()); this.chart.set('dataset_id', this.app.options.dataset.id); this.chart.set('type', 'bardiagram'); this.chart.set('title', 'Chart title'); }, - // set chart - setChart: function(new_chart) { - this.chart.copy(new_chart); - }, - // create chart _saveChart: function() { // update chart data diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/views/charts.js --- a/config/plugins/visualizations/charts/static/views/charts.js +++ b/config/plugins/visualizations/charts/static/views/charts.js @@ -16,12 +16,12 @@ ondblclick : function(chart_id) { // get chart var chart = self.app.charts.get(chart_id); - + self.app.chart.copy(chart); + // show edit self.$el.hide(); // update model and show create - self.app.chart_view.setChart(chart); self.app.chart_view.$el.show(); }, onchange : function(chart_id) { @@ -41,7 +41,7 @@ tooltip: 'Create', onclick: function() { self.$el.hide(); - self.app.chart_view.reset(); + self.app.chart.reset(); self.app.chart_view.$el.show(); } }), @@ -57,11 +57,11 @@ // get chart var chart = self.app.charts.get(chart_id); + self.app.chart.copy(chart); // show edit self.$el.hide(); self.app.chart_view.$el.show(); - self.app.chart_view.setChart(chart); } }), 'delete' : new Ui.ButtonIcon({ diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/views/group.js --- a/config/plugins/visualizations/charts/static/views/group.js +++ b/config/plugins/visualizations/charts/static/views/group.js @@ -1,13 +1,10 @@ // dependencies -define(['library/portlet', 'library/table', 'library/ui', 'library/utils', 'models/group'], - function(Portlet, Table, Ui, Utils, Group) { +define(['library/portlet', 'library/table', 'library/ui', 'library/utils'], + function(Portlet, Table, Ui, Utils) { // chart config return Backbone.View.extend( { - // model - group: new Group(), - // columns columns: [], @@ -18,6 +15,7 @@ // get current chart object this.chart = this.app.chart; + this.group = this.app.group; // ui elements this.message = new Ui.Message(); @@ -69,6 +67,9 @@ this.group.on('change', function() { self._refreshGroup(); }); + this.group.on('reset', function() { + self._resetGroup(); + }); }, // show @@ -77,8 +78,7 @@ }, // reset - reset: function() { - this.group.reset(); + _resetGroup: function() { this.group.set('id', Utils.uuid()); this.group.set('label', 'Group label'); }, diff -r ee176b881f3784ab658254ff4d471bcd113f05ce -r b76dd608c500d8421d0ec51f6b638b7324ecead6 config/plugins/visualizations/charts/static/views/groups.js --- a/config/plugins/visualizations/charts/static/views/groups.js +++ b/config/plugins/visualizations/charts/static/views/groups.js @@ -37,9 +37,9 @@ icon : 'fa-plus', tooltip: 'Create', onclick: function() { + self.app.group.reset(); self.app.chart_view.$el.hide(); self.app.group_view.show(); - self.app.group_view.reset(); } }), 'edit' : new Ui.ButtonIcon({ https://bitbucket.org/galaxy/galaxy-central/commits/dec86d2bd3b1/ Changeset: dec86d2bd3b1 User: guerler Date: 2014-01-16 20:10:56 Summary: Merge Affected #: 8 files diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/config.py --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -602,7 +602,11 @@ if check_migrate_tools: # Alert the Galaxy admin to tools that have been moved from the distribution to the tool shed. from tool_shed.galaxy_install.migrate.check import verify_tools - verify_tools( self, install_db_url, config_file, self.config.database_engine_options ) + if combined_install_database: + install_database_options = self.config.database_engine_options + else: + install_database_options = self.config.install_database_engine_options + verify_tools( self, install_db_url, config_file, install_database_options ) from galaxy.model import mapping self.model = mapping.init( self.config.file_path, diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -734,8 +734,7 @@ self.tags = [] def _next_hid( self ): - # TODO: override this with something in the database that ensures - # better integrity + # this is overriden in mapping.py db_next_hid() method if len( self.datasets ) == 0: return 1 else: @@ -3446,4 +3445,7 @@ self.context = context class APIKeys( object ): - pass + def __init__( self, id=None, user_id=None, key=None): + self.id = id + self.user_id = user_id + self.key = key diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/webapps/galaxy/api/authenticate.py --- /dev/null +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -0,0 +1,77 @@ +""" +API key retrieval through BaseAuth +""" + +from galaxy import util, web +from pprint import pprint +from galaxy.web.base.controller import BaseAPIController +from base64 import b64decode, b64encode +from urllib import quote, unquote +from galaxy.exceptions import ObjectNotFound +from paste.httpexceptions import HTTPBadRequest + +import logging +log = logging.getLogger( __name__ ) + +class AuthenticationController( BaseAPIController ): + + @web.expose_api_anonymous + def get_api_key( self, trans, **kwd ): + """ + def get_api_key( self, trans, **kwd ) + * GET /api/authenticate/baseauth + returns an API key for authenticated user based on BaseAuth headers + """ + email, password = self._decode_baseauth( trans.environ.get( 'HTTP_AUTHORIZATION' ) ) + + user = trans.sa_session.query( trans.app.model.User ).filter( trans.app.model.User.table.c.email == email ).all() + + if (len(user) is not 1): + # DB is inconsistent and we have more users with same email + raise ObjectNotFound + else: + user = user[0] + is_valid_user = user.check_password( password ) + + if (is_valid_user): + user_id = user.id + api_key_row = trans.sa_session.query( trans.app.model.APIKeys ).filter( trans.app.model.APIKeys.table.c.user_id == user_id ).first() + else: + trans.response.status = 500 + return "invalid password" + + return dict( api_key= api_key_row.key ) + + def _decode_baseauth( self, encoded_str ): + """Decode an encrypted HTTP basic authentication string. Returns a tuple of + the form (email, password), and raises a HTTPBadRequest exception if + nothing could be decoded. + """ + split = encoded_str.strip().split(' ') + + # If split is only one element, try to decode the email and password + # directly. + if len(split) == 1: + try: + email, password = b64decode(split[0]).split(':') + except: + raise HTTPBadRequest + + # If there are only two elements, check the first and ensure it says + # 'basic' so that we know we're about to decode the right thing. If not, + # bail out. + elif len(split) == 2: + if split[0].strip().lower() == 'basic': + try: + email, password = b64decode(split[1]).split(':') + except: + raise HTTPBadRequest + else: + raise HTTPBadRequest + + # If there are more than 2 elements, something crazy must be happening. + # Bail. + else: + raise HTTPBadRequest + + return unquote(email), unquote(password) diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/webapps/galaxy/api/lda_datasets.py --- a/lib/galaxy/webapps/galaxy/api/lda_datasets.py +++ b/lib/galaxy/webapps/galaxy/api/lda_datasets.py @@ -2,7 +2,6 @@ API operations on the datasets from library. """ import glob -import logging import operator import os import os.path diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -169,6 +169,16 @@ webapp.mapper.connect( 'workflow_dict', '/api/workflows/download/{workflow_id}', controller='workflows', action='workflow_dict', conditions=dict( method=['GET'] ) ) webapp.mapper.connect( 'import_shared_workflow', '/api/workflows/import', controller='workflows', action='import_shared_worflow', conditions=dict( method=['POST'] ) ) + # ============================ + # ===== AUTHENTICATE API ===== + # ============================ + + webapp.mapper.connect( 'api_key_retrieval', + '/api/authenticate/baseauth/', + controller='authenticate', + action='get_api_key', + conditions=dict( method=[ "GET" ] ) ) + # ======================= # ===== LIBRARY API ===== # ======================= diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -129,7 +129,7 @@ repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, encoded_repository_id, changeset_revision ) - if not repository_metadata: + if repository_metadata is None: # The changeset_revision column in the repository_metadata table has been updated with a new # value value, so find the changeset_revision to which we need to update. repo_dir = repository.repo_path( trans.app ) @@ -139,7 +139,7 @@ encoded_repository_id, new_changeset_revision ) changeset_revision = new_changeset_revision - if repository_metadata: + if repository_metadata is not None: encoded_repository_metadata_id = trans.security.encode_id( repository_metadata.id ) repository_metadata_dict = repository_metadata.to_dict( view='collection', value_mapper=self.__get_value_mapper( trans ) ) @@ -168,7 +168,8 @@ def __get_value_mapper( self, trans ): value_mapper = { 'id' : trans.security.encode_id, - 'repository_id' : trans.security.encode_id } + 'repository_id' : trans.security.encode_id, + 'user_id' : trans.security.encode_id } return value_mapper @web.expose_api diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/galaxy/webapps/tool_shed/api/repository_revisions.py --- a/lib/galaxy/webapps/tool_shed/api/repository_revisions.py +++ b/lib/galaxy/webapps/tool_shed/api/repository_revisions.py @@ -68,7 +68,8 @@ def __get_value_mapper( self, trans ): value_mapper = { 'id' : trans.security.encode_id, - 'repository_id' : trans.security.encode_id } + 'repository_id' : trans.security.encode_id, + 'user_id' : trans.security.encode_id } return value_mapper @web.expose_api_anonymous @@ -159,15 +160,33 @@ repository_dependency_repository_metadata = \ suc.get_repository_metadata_by_changeset_revision( trans, repository_dependency_id, changeset_revision ) if repository_dependency_repository_metadata is None: - log.debug( 'Cannot locate repository_metadata with id %s for repository dependency %s owned by %s.' % \ - ( str( repository_dependency_id ), str( name ), str( owner ) ) ) - continue + # The changeset_revision column in the repository_metadata table has been updated with a new + # value value, so find the changeset_revision to which we need to update. + repo_dir = repository_dependency.repo_path( trans.app ) + repo = hg.repository( suc.get_configured_ui(), repo_dir ) + new_changeset_revision = suc.get_next_downloadable_changeset_revision( repository_dependency, + repo, + changeset_revision ) + repository_dependency_repository_metadata = \ + suc.get_repository_metadata_by_changeset_revision( trans, + repository_dependency_id, + new_changeset_revision ) + if repository_dependency_repository_metadata is None: + decoded_repository_dependency_id = trans.security.decode_id( repository_dependency_id ) + debug_msg = 'Cannot locate repository_metadata with id %d for repository dependency %s owned by %s ' % \ + ( decoded_repository_dependency_id, str( name ), str( owner ) ) + debug_msg += 'using either of these changeset_revisions: %s, %s.' % \ + ( str( changeset_revision ), str( new_changeset_revision ) ) + log.debug( debug_msg ) + continue + else: + changeset_revision = new_changeset_revision repository_dependency_repository_metadata_id = trans.security.encode_id( repository_dependency_repository_metadata.id ) repository_dependency_dict = repository_dependency.to_dict( view='element', value_mapper=self.__get_value_mapper( trans ) ) # We have to add the changeset_revision of of the repository dependency. repository_dependency_dict[ 'changeset_revision' ] = changeset_revision - repository_dependency_dict[ 'url' ] = web.url_for( controller='repositories', + repository_dependency_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', id=repository_dependency_repository_metadata_id ) repository_dependencies_dicts.append( repository_dependency_dict ) diff -r b76dd608c500d8421d0ec51f6b638b7324ecead6 -r dec86d2bd3b10c16c91ec2847840c62b5e2bfe59 lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -724,8 +724,8 @@ def get_next_downloadable_changeset_revision( repository, repo, after_changeset_revision ): """ - Return the installable changeset_revision in the repository changelog after the changeset to which after_changeset_revision refers. If there - isn't one, return None. + Return the installable changeset_revision in the repository changelog after the changeset to which + after_changeset_revision refers. If there isn't one, return None. """ changeset_revisions = get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True ) if len( changeset_revisions ) == 1: Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.