commit/galaxy-central: 3 new changesets
3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0b15f8124467/ Changeset: 0b15f8124467 User: dannon Date: 2015-02-05 23:35:43+00:00 Summary: Add reference to the webapp to galaxy.app Affected #: 2 files diff -r 494418e72cf0007e909c7f4b9134cd2b82df49e2 -r 0b15f8124467ff74da92f74f5f5977147ee6fc4c lib/galaxy/app.py --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -23,7 +23,7 @@ import logging log = logging.getLogger( __name__ ) - +app = None class UniverseApplication( object, config.ConfiguresGalaxyMixin ): """Encapsulates the state of a Universe application""" diff -r 494418e72cf0007e909c7f4b9134cd2b82df49e2 -r 0b15f8124467ff74da92f74f5f5977147ee6fc4c lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -10,6 +10,7 @@ from paste import httpexceptions import pkg_resources +import galaxy.app import galaxy.model import galaxy.model.mapping import galaxy.datatypes.registry @@ -39,8 +40,8 @@ app = kwargs.pop( 'app' ) else: try: - from galaxy.app import UniverseApplication - app = UniverseApplication( global_conf=global_conf, **kwargs ) + app = galaxy.app.UniverseApplication( global_conf=global_conf, **kwargs ) + galaxy.app.app = app except: import traceback traceback.print_exc() https://bitbucket.org/galaxy/galaxy-central/commits/65870b9e3c18/ Changeset: 65870b9e3c18 User: dannon Date: 2015-02-05 23:55:15+00:00 Summary: Fix lunr availability for tool form. Turns out javascript define needs a target. Oops. Affected #: 3 files diff -r 0b15f8124467ff74da92f74f5f5977147ee6fc4c -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 client/galaxy/scripts/mvc/tools.js --- a/client/galaxy/scripts/mvc/tools.js +++ b/client/galaxy/scripts/mvc/tools.js @@ -3,7 +3,7 @@ */ define( ["libs/underscore", "viz/trackster/util", "mvc/data", "libs/lunr" ], - function(_, util, data) { + function(_, util, data, lunr) { /** * Mixin for tracking model visibility. diff -r 0b15f8124467ff74da92f74f5f5977147ee6fc4c -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 static/scripts/mvc/tools.js --- a/static/scripts/mvc/tools.js +++ b/static/scripts/mvc/tools.js @@ -3,7 +3,7 @@ */ define( ["libs/underscore", "viz/trackster/util", "mvc/data", "libs/lunr" ], - function(_, util, data) { + function(_, util, data, lunr) { /** * Mixin for tracking model visibility. diff -r 0b15f8124467ff74da92f74f5f5977147ee6fc4c -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 static/scripts/packed/mvc/tools.js --- a/static/scripts/packed/mvc/tools.js +++ b/static/scripts/packed/mvc/tools.js @@ -1,1 +1,1 @@ -define(["libs/underscore","viz/trackster/util","mvc/data","libs/lunr"],function(x,a,y){var g={hidden:false,show:function(){this.set("hidden",false)},hide:function(){this.set("hidden",true)},toggle:function(){this.set("hidden",!this.get("hidden"))},is_visible:function(){return !this.attributes.hidden}};var e=Backbone.Model.extend({defaults:{name:null,label:null,type:null,value:null,html:null,num_samples:5},initialize:function(z){this.attributes.html=unescape(this.attributes.html)},copy:function(){return new e(this.toJSON())},set_value:function(z){this.set("value",z||"")}});var i=Backbone.Collection.extend({model:e});var k=e.extend({});var d=e.extend({set_value:function(z){this.set("value",parseInt(z,10))},get_samples:function(){return d3.scale.linear().domain([this.get("min"),this.get("max")]).ticks(this.get("num_samples"))}});var f=d.extend({set_value:function(z){this.set("value",parseFloat(z))}});var t=e.extend({get_samples:function(){return x.map(this.get("options"),function(z){return z[0]})}});e.subModelTypes={integer:d,"float":f,data:k,select:t};var j=Backbone.Model.extend({defaults:{id:null,name:null,description:null,target:null,inputs:[],outputs:[]},urlRoot:galaxy_config.root+"api/tools",initialize:function(z){this.set("inputs",new i(x.map(z.inputs,function(A){var B=e.subModelTypes[A.type]||e;return new B(A)})))},toJSON:function(){var z=Backbone.Model.prototype.toJSON.call(this);z.inputs=this.get("inputs").map(function(A){return A.toJSON()});return z},remove_inputs:function(A){var z=this,B=z.get("inputs").filter(function(C){return(A.indexOf(C.get("type"))!==-1)});z.get("inputs").remove(B)},copy:function(A){var B=new j(this.toJSON());if(A){var z=new Backbone.Collection();B.get("inputs").each(function(C){if(C.get_samples()){z.push(C)}});B.set("inputs",z)}return B},apply_search_results:function(z){(x.indexOf(z,this.attributes.id)!==-1?this.show():this.hide());return this.is_visible()},set_input_value:function(z,A){this.get("inputs").find(function(B){return B.get("name")===z}).set("value",A)},set_input_values:function(A){var z=this;x.each(x.keys(A),function(B){z.set_input_value(B,A[B])})},run:function(){return this._run()},rerun:function(A,z){return this._run({action:"rerun",target_dataset_id:A.id,regions:z})},get_inputs_dict:function(){var z={};this.get("inputs").each(function(A){z[A.get("name")]=A.get("value")});return z},_run:function(B){var C=x.extend({tool_id:this.id,inputs:this.get_inputs_dict()},B);var A=$.Deferred(),z=new a.ServerStateDeferred({ajax_settings:{url:this.urlRoot,data:JSON.stringify(C),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(D){return D!=="pending"}});$.when(z.go()).then(function(D){A.resolve(new y.DatasetCollection().reset(D))});return A}});x.extend(j.prototype,g);var q=Backbone.View.extend({});var n=Backbone.Collection.extend({model:j});var v=Backbone.Model.extend(g);var l=Backbone.Model.extend({defaults:{elems:[],open:false},clear_search_results:function(){x.each(this.attributes.elems,function(z){z.show()});this.show();this.set("open",false)},apply_search_results:function(A){var B=true,z;x.each(this.attributes.elems,function(C){if(C instanceof v){z=C;z.hide()}else{if(C instanceof j){if(C.apply_search_results(A)){B=false;if(z){z.show()}}}}});if(B){this.hide()}else{this.show();this.set("open",true)}}});x.extend(l.prototype,g);var c=Backbone.Model.extend({defaults:{search_hint_string:"search tools",min_chars_for_search:3,spinner_url:"",clear_btn_url:"",search_url:"",visible:true,query:"",results:null,clear_key:27},initialize:function(){this.on("change:query",this.do_search)},do_search:function(){var B=this.attributes.query;if(B.length<this.attributes.min_chars_for_search){this.set("results",null);return}var A=B+"*";if(this.timer){clearTimeout(this.timer)}$("#search-clear-btn").hide();$("#search-spinner").show();var z=this;this.timer=setTimeout(function(){$.get(z.attributes.search_url,{query:A},function(C){z.set("results",C);$("#search-spinner").hide();$("#search-clear-btn").show()},"json")},200)},clear_search:function(){this.set("query","");this.set("results",null)}});x.extend(c.prototype,g);var o=Backbone.Model.extend({initialize:function(z){this.attributes.tool_search=z.tool_search;this.attributes.tool_search.on("change:results",this.apply_search_results,this);this.attributes.tools=z.tools;this.attributes.layout=new Backbone.Collection(this.parse(z.layout))},parse:function(A){var z=this,B=function(E){var D=E.model_class;if(D.indexOf("Tool")===D.length-4){return z.attributes.tools.get(E.id)}else{if(D==="ToolSection"){var C=x.map(E.elems,B);E.elems=C;return new l(E)}else{if(D==="ToolSectionLabel"){return new v(E)}}}};return x.map(A,B)},clear_search_results:function(){this.get("layout").each(function(z){if(z instanceof l){z.clear_search_results()}else{z.show()}})},apply_search_results:function(){var A=this.get("tool_search").get("results");if(A===null){this.clear_search_results();return}var z=null;this.get("layout").each(function(B){if(B instanceof v){z=B;z.hide()}else{if(B instanceof j){if(B.apply_search_results(A)){if(z){z.show()}}}else{z=null;B.apply_search_results(A)}}})}});var s=Backbone.View.extend({initialize:function(){this.model.on("change:hidden",this.update_visible,this);this.update_visible()},update_visible:function(){(this.model.attributes.hidden?this.$el.hide():this.$el.show())}});var m=s.extend({tagName:"div",render:function(){var z=$("<div/>");z.append(Handlebars.templates.tool_link(this.model.toJSON()));if(this.model.id==="upload1"){z.find("a").on("click",function(A){A.preventDefault();Galaxy.upload.show()})}this.$el.append(z);return this}});var b=s.extend({tagName:"div",className:"toolPanelLabel",render:function(){this.$el.append($("<span/>").text(this.model.attributes.text));return this}});var r=s.extend({tagName:"div",className:"toolSectionWrapper",initialize:function(){s.prototype.initialize.call(this);this.model.on("change:open",this.update_open,this)},render:function(){this.$el.append(Handlebars.templates.panel_section(this.model.toJSON()));var z=this.$el.find(".toolSectionBody");x.each(this.model.attributes.elems,function(A){if(A instanceof j){var B=new m({model:A,className:"toolTitle"});B.render();z.append(B.$el)}else{if(A instanceof v){var C=new b({model:A});C.render();z.append(C.$el)}else{}}});return this},events:{"click .toolSectionTitle > a":"toggle"},toggle:function(){this.model.set("open",!this.model.attributes.open)},update_open:function(){(this.model.attributes.open?this.$el.children(".toolSectionBody").slideDown("fast"):this.$el.children(".toolSectionBody").slideUp("fast"))}});var p=Backbone.View.extend({tagName:"div",id:"tool-search",className:"bar",events:{click:"focus_and_select","keyup :input":"query_changed","click #search-clear-btn":"clear"},render:function(){this.$el.append(Handlebars.templates.tool_search(this.model.toJSON()));if(!this.model.is_visible()){this.$el.hide()}this.$el.find("[title]").tooltip();return this},focus_and_select:function(){this.$el.find(":input").focus().select()},clear:function(){this.model.clear_search();this.$el.find(":input").val(this.model.attributes.search_hint_string);this.focus_and_select();return false},query_changed:function(z){if((this.model.attributes.clear_key)&&(this.model.attributes.clear_key===z.which)){this.clear();return false}this.model.set("query",this.$el.find(":input").val())}});var w=Backbone.View.extend({tagName:"div",className:"toolMenu",initialize:function(){this.model.get("tool_search").on("change:results",this.handle_search_results,this)},render:function(){var z=this;var A=new p({model:this.model.get("tool_search")});A.render();z.$el.append(A.$el);this.model.get("layout").each(function(C){if(C instanceof l){var B=new r({model:C});B.render();z.$el.append(B.$el)}else{if(C instanceof j){var D=new m({model:C,className:"toolTitleNoSection"});D.render();z.$el.append(D.$el)}else{if(C instanceof v){var E=new b({model:C});E.render();z.$el.append(E.$el)}}}});z.$el.find("a.tool-link").click(function(D){var C=$(this).attr("class").split(/\s+/)[0],B=z.model.get("tools").get(C);z.trigger("tool_link_click",D,B)});return this},handle_search_results:function(){var z=this.model.get("tool_search").get("results");if(z&&z.length===0){$("#search-no-results").show()}else{$("#search-no-results").hide()}}});var u=Backbone.View.extend({className:"toolForm",render:function(){this.$el.children().remove();this.$el.append(Handlebars.templates.tool_form(this.model.toJSON()))}});var h=Backbone.View.extend({className:"toolMenuAndView",initialize:function(){this.tool_panel_view=new w({collection:this.collection});this.tool_form_view=new u()},render:function(){this.tool_panel_view.render();this.tool_panel_view.$el.css("float","left");this.$el.append(this.tool_panel_view.$el);this.tool_form_view.$el.hide();this.$el.append(this.tool_form_view.$el);var z=this;this.tool_panel_view.on("tool_link_click",function(B,A){B.preventDefault();z.show_tool(A)})},show_tool:function(A){var z=this;A.fetch().done(function(){z.tool_form_view.model=A;z.tool_form_view.render();z.tool_form_view.$el.show();$("#left").width("650px")})}});return{ToolParameter:e,IntegerToolParameter:d,SelectToolParameter:t,Tool:j,ToolCollection:n,ToolSearch:c,ToolPanel:o,ToolPanelView:w,ToolFormView:u}}); \ No newline at end of file +define(["libs/underscore","viz/trackster/util","mvc/data","libs/lunr"],function(y,a,z,s){var g={hidden:false,show:function(){this.set("hidden",false)},hide:function(){this.set("hidden",true)},toggle:function(){this.set("hidden",!this.get("hidden"))},is_visible:function(){return !this.attributes.hidden}};var e=Backbone.Model.extend({defaults:{name:null,label:null,type:null,value:null,html:null,num_samples:5},initialize:function(A){this.attributes.html=unescape(this.attributes.html)},copy:function(){return new e(this.toJSON())},set_value:function(A){this.set("value",A||"")}});var i=Backbone.Collection.extend({model:e});var k=e.extend({});var d=e.extend({set_value:function(A){this.set("value",parseInt(A,10))},get_samples:function(){return d3.scale.linear().domain([this.get("min"),this.get("max")]).ticks(this.get("num_samples"))}});var f=d.extend({set_value:function(A){this.set("value",parseFloat(A))}});var u=e.extend({get_samples:function(){return y.map(this.get("options"),function(A){return A[0]})}});e.subModelTypes={integer:d,"float":f,data:k,select:u};var j=Backbone.Model.extend({defaults:{id:null,name:null,description:null,target:null,inputs:[],outputs:[]},urlRoot:galaxy_config.root+"api/tools",initialize:function(A){this.set("inputs",new i(y.map(A.inputs,function(B){var C=e.subModelTypes[B.type]||e;return new C(B)})))},toJSON:function(){var A=Backbone.Model.prototype.toJSON.call(this);A.inputs=this.get("inputs").map(function(B){return B.toJSON()});return A},remove_inputs:function(B){var A=this,C=A.get("inputs").filter(function(D){return(B.indexOf(D.get("type"))!==-1)});A.get("inputs").remove(C)},copy:function(B){var C=new j(this.toJSON());if(B){var A=new Backbone.Collection();C.get("inputs").each(function(D){if(D.get_samples()){A.push(D)}});C.set("inputs",A)}return C},apply_search_results:function(A){(y.indexOf(A,this.attributes.id)!==-1?this.show():this.hide());return this.is_visible()},set_input_value:function(A,B){this.get("inputs").find(function(C){return C.get("name")===A}).set("value",B)},set_input_values:function(B){var A=this;y.each(y.keys(B),function(C){A.set_input_value(C,B[C])})},run:function(){return this._run()},rerun:function(B,A){return this._run({action:"rerun",target_dataset_id:B.id,regions:A})},get_inputs_dict:function(){var A={};this.get("inputs").each(function(B){A[B.get("name")]=B.get("value")});return A},_run:function(C){var D=y.extend({tool_id:this.id,inputs:this.get_inputs_dict()},C);var B=$.Deferred(),A=new a.ServerStateDeferred({ajax_settings:{url:this.urlRoot,data:JSON.stringify(D),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(E){return E!=="pending"}});$.when(A.go()).then(function(E){B.resolve(new z.DatasetCollection().reset(E))});return B}});y.extend(j.prototype,g);var q=Backbone.View.extend({});var n=Backbone.Collection.extend({model:j});var w=Backbone.Model.extend(g);var l=Backbone.Model.extend({defaults:{elems:[],open:false},clear_search_results:function(){y.each(this.attributes.elems,function(A){A.show()});this.show();this.set("open",false)},apply_search_results:function(B){var C=true,A;y.each(this.attributes.elems,function(D){if(D instanceof w){A=D;A.hide()}else{if(D instanceof j){if(D.apply_search_results(B)){C=false;if(A){A.show()}}}}});if(C){this.hide()}else{this.show();this.set("open",true)}}});y.extend(l.prototype,g);var c=Backbone.Model.extend({defaults:{search_hint_string:"search tools",min_chars_for_search:3,spinner_url:"",clear_btn_url:"",search_url:"",visible:true,query:"",results:null,clear_key:27},initialize:function(){this.on("change:query",this.do_search)},do_search:function(){var C=this.attributes.query;if(C.length<this.attributes.min_chars_for_search){this.set("results",null);return}var B=C+"*";if(this.timer){clearTimeout(this.timer)}$("#search-clear-btn").hide();$("#search-spinner").show();var A=this;this.timer=setTimeout(function(){$.get(A.attributes.search_url,{query:B},function(D){A.set("results",D);$("#search-spinner").hide();$("#search-clear-btn").show()},"json")},200)},clear_search:function(){this.set("query","");this.set("results",null)}});y.extend(c.prototype,g);var o=Backbone.Model.extend({initialize:function(A){this.attributes.tool_search=A.tool_search;this.attributes.tool_search.on("change:results",this.apply_search_results,this);this.attributes.tools=A.tools;this.attributes.layout=new Backbone.Collection(this.parse(A.layout))},parse:function(B){var A=this,C=function(F){var E=F.model_class;if(E.indexOf("Tool")===E.length-4){return A.attributes.tools.get(F.id)}else{if(E==="ToolSection"){var D=y.map(F.elems,C);F.elems=D;return new l(F)}else{if(E==="ToolSectionLabel"){return new w(F)}}}};return y.map(B,C)},clear_search_results:function(){this.get("layout").each(function(A){if(A instanceof l){A.clear_search_results()}else{A.show()}})},apply_search_results:function(){var B=this.get("tool_search").get("results");if(B===null){this.clear_search_results();return}var A=null;this.get("layout").each(function(C){if(C instanceof w){A=C;A.hide()}else{if(C instanceof j){if(C.apply_search_results(B)){if(A){A.show()}}}else{A=null;C.apply_search_results(B)}}})}});var t=Backbone.View.extend({initialize:function(){this.model.on("change:hidden",this.update_visible,this);this.update_visible()},update_visible:function(){(this.model.attributes.hidden?this.$el.hide():this.$el.show())}});var m=t.extend({tagName:"div",render:function(){var A=$("<div/>");A.append(Handlebars.templates.tool_link(this.model.toJSON()));if(this.model.id==="upload1"){A.find("a").on("click",function(B){B.preventDefault();Galaxy.upload.show()})}this.$el.append(A);return this}});var b=t.extend({tagName:"div",className:"toolPanelLabel",render:function(){this.$el.append($("<span/>").text(this.model.attributes.text));return this}});var r=t.extend({tagName:"div",className:"toolSectionWrapper",initialize:function(){t.prototype.initialize.call(this);this.model.on("change:open",this.update_open,this)},render:function(){this.$el.append(Handlebars.templates.panel_section(this.model.toJSON()));var A=this.$el.find(".toolSectionBody");y.each(this.model.attributes.elems,function(B){if(B instanceof j){var C=new m({model:B,className:"toolTitle"});C.render();A.append(C.$el)}else{if(B instanceof w){var D=new b({model:B});D.render();A.append(D.$el)}else{}}});return this},events:{"click .toolSectionTitle > a":"toggle"},toggle:function(){this.model.set("open",!this.model.attributes.open)},update_open:function(){(this.model.attributes.open?this.$el.children(".toolSectionBody").slideDown("fast"):this.$el.children(".toolSectionBody").slideUp("fast"))}});var p=Backbone.View.extend({tagName:"div",id:"tool-search",className:"bar",events:{click:"focus_and_select","keyup :input":"query_changed","click #search-clear-btn":"clear"},render:function(){this.$el.append(Handlebars.templates.tool_search(this.model.toJSON()));if(!this.model.is_visible()){this.$el.hide()}this.$el.find("[title]").tooltip();return this},focus_and_select:function(){this.$el.find(":input").focus().select()},clear:function(){this.model.clear_search();this.$el.find(":input").val(this.model.attributes.search_hint_string);this.focus_and_select();return false},query_changed:function(A){if((this.model.attributes.clear_key)&&(this.model.attributes.clear_key===A.which)){this.clear();return false}this.model.set("query",this.$el.find(":input").val())}});var x=Backbone.View.extend({tagName:"div",className:"toolMenu",initialize:function(){this.model.get("tool_search").on("change:results",this.handle_search_results,this)},render:function(){var A=this;var B=new p({model:this.model.get("tool_search")});B.render();A.$el.append(B.$el);this.model.get("layout").each(function(D){if(D instanceof l){var C=new r({model:D});C.render();A.$el.append(C.$el)}else{if(D instanceof j){var E=new m({model:D,className:"toolTitleNoSection"});E.render();A.$el.append(E.$el)}else{if(D instanceof w){var F=new b({model:D});F.render();A.$el.append(F.$el)}}}});A.$el.find("a.tool-link").click(function(E){var D=$(this).attr("class").split(/\s+/)[0],C=A.model.get("tools").get(D);A.trigger("tool_link_click",E,C)});return this},handle_search_results:function(){var A=this.model.get("tool_search").get("results");if(A&&A.length===0){$("#search-no-results").show()}else{$("#search-no-results").hide()}}});var v=Backbone.View.extend({className:"toolForm",render:function(){this.$el.children().remove();this.$el.append(Handlebars.templates.tool_form(this.model.toJSON()))}});var h=Backbone.View.extend({className:"toolMenuAndView",initialize:function(){this.tool_panel_view=new x({collection:this.collection});this.tool_form_view=new v()},render:function(){this.tool_panel_view.render();this.tool_panel_view.$el.css("float","left");this.$el.append(this.tool_panel_view.$el);this.tool_form_view.$el.hide();this.$el.append(this.tool_form_view.$el);var A=this;this.tool_panel_view.on("tool_link_click",function(C,B){C.preventDefault();A.show_tool(B)})},show_tool:function(B){var A=this;B.fetch().done(function(){A.tool_form_view.model=B;A.tool_form_view.render();A.tool_form_view.$el.show();$("#left").width("650px")})}});return{ToolParameter:e,IntegerToolParameter:d,SelectToolParameter:u,Tool:j,ToolCollection:n,ToolSearch:c,ToolPanel:o,ToolPanelView:x,ToolFormView:v}}); \ No newline at end of file https://bitbucket.org/galaxy/galaxy-central/commits/8f1d5b7b30c6/ Changeset: 8f1d5b7b30c6 User: dannon Date: 2015-02-05 23:55:20+00:00 Summary: Merge. Affected #: 4 files diff -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 -r 8f1d5b7b30c62231bfa4fa8f39fc6338726020ee lib/galaxy/managers/datasets.py --- a/lib/galaxy/managers/datasets.py +++ b/lib/galaxy/managers/datasets.py @@ -274,3 +274,15 @@ def add_deserializers( self ): super( DatasetAssociationDeserializer, self ).add_deserializers() deletable.PurgableDeserializerMixin.add_deserializers( self ) + +class DatasetAssociationFilters( base.ModelFilterParser, deletable.PurgableFiltersMixin ): + + def _add_parsers( self ): + super( DatasetAssociationFilters, self )._add_parsers() + deletable.PurgableFiltersMixin._add_parsers( self ) + + self.orm_filter_parsers.update({ + 'name' : { 'op': ( 'eq', 'contains', 'like' ) }, + 'state' : { 'op': ( 'eq', 'in' ) }, + }) + #self.fn_filter_parsers.update({}) diff -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 -r 8f1d5b7b30c62231bfa4fa8f39fc6338726020ee lib/galaxy/managers/hdas.py --- a/lib/galaxy/managers/hdas.py +++ b/lib/galaxy/managers/hdas.py @@ -592,3 +592,25 @@ }) self.deserializable_keyset.update( self.deserializers.keys() ) + + +class HDAFilters( datasets.DatasetAssociationFilters ): + model_class = model.HistoryDatasetAssociation + + def _add_parsers( self ): + super( HDAFilters, self )._add_parsers() + + self.fn_filter_parsers.update({ + #TODO: filter_string_attr_contains, filter_string_attr_eq + #'dbkey' : { 'op': { 'has' : self.filter_annotation_contains, } }, + + #TODO: add this in annotatable mixin + 'annotation' : { 'op': { 'has' : self.filter_annotation_contains, } }, + #TODO: add this in taggable mixin + 'tag' : { + 'op': { + 'eq' : self.filter_has_tag, + 'has': self.filter_has_partial_tag, + } + } + }) diff -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 -r 8f1d5b7b30c62231bfa4fa8f39fc6338726020ee lib/galaxy/managers/histories.py --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -310,7 +310,7 @@ 'contents' : self.serialize_contents }) - def serialize_contents( self, trans, history, key ): + def serialize_contents( self, trans, history, *args ): contents_dictionaries = [] for content in history.contents_iter( types=[ 'dataset', 'dataset_collection' ] ): contents_dict = {} diff -r 65870b9e3c1801e6e6ae9667f46baaec4ddba4b1 -r 8f1d5b7b30c62231bfa4fa8f39fc6338726020ee lib/galaxy/managers/users.py --- a/lib/galaxy/managers/users.py +++ b/lib/galaxy/managers/users.py @@ -8,15 +8,17 @@ from galaxy import model from galaxy import exceptions +from galaxy import util from galaxy.managers import base +from galaxy.managers import deletable from galaxy.managers import api_keys import logging log = logging.getLogger( __name__ ) -class UserManager( base.ModelManager ): +class UserManager( base.ModelManager, deletable.PurgableManagerMixin ): model_class = model.User foreign_key_name = 'user' @@ -107,7 +109,7 @@ """ Return a list of admin email addresses from the config file. """ - return [ x.strip() for x in self.app.config.get( "admin_users", "" ).split( "," ) ] + return [ email.strip() for email in self.app.config.get( "admin_users", "" ).split( "," ) ] def admins( self, trans, filters=None, **kwargs ): """ @@ -193,14 +195,19 @@ #TODO: not sure we need to go through sec agent... it's just the first role of type private return self.app.security_agent.get_private_user_role( user ) + def quota( self, trans, user ): + #TODO: use quota manager + return self.app.quota_agent.get_percent( user=user ) -class UserSerializer( base.ModelSerializer ): - def __init__( self ): +class UserSerializer( base.ModelSerializer, deletable.PurgableSerializerMixin ): + + def __init__( self, app ): """ Convert a User and associated data to a dictionary representation. """ - super( UserSerializer, self ).__init__() + super( UserSerializer, self ).__init__( app ) + self.user_manager = UserManager( app ) self.default_view = 'summary' self.add_view( 'summary', [ @@ -209,23 +216,80 @@ self.add_view( 'detailed', [ 'update_time', 'create_time', + + 'deleted', + 'purged', + 'active', + 'total_disk_usage', 'nice_total_disk_usage', - 'deleted', - 'purged', - 'active' - ], include_keys_from='summary' ) - #self.add_view( 'summary', [ + 'quota_percent' # 'preferences', # # all tags # 'tags', # # all annotations # 'annotations' - #], include_keys_from='detailed' ) + ], include_keys_from='summary' ) def add_serializers( self ): + super( UserSerializer, self ).add_serializers() + deletable.PurgableSerializerMixin.add_serializers( self ) + self.serializers.update({ 'id' : self.serialize_id, 'create_time' : self.serialize_date, 'update_time' : self.serialize_date, + 'is_admin' : lambda t, i, k: self.user_manager.is_admin( t, i ), + 'quota_percent' : lambda t, i, k: self.user_manager.quota( t, i ) }) + + def serialize_current_anonymous_user( self, trans, user, keys ): + # use the current history if any to get usage stats for trans' anonymous user + #TODO: might be better as sep. Serializer class + history = trans.history + if not history: + raise exceptions.AuthenticationRequired( 'No history for anonymous user usage stats' ); + + usage = trans.app.quota_agent.get_usage( trans, history=trans.history ) + percent = trans.app.quota_agent.get_percent( trans=trans, usage=usage ) + + # a very small subset of keys available + values = { + 'id' : None, + 'total_disk_usage' : int( usage ), + 'nice_total_disk_usage' : util.nice_size( usage ), + 'quota_percent' : percent, + } + serialized = {} + for key in keys: + if key in values: + serialized[ key ] = values[ key ] + return serialized + + def serialize( self, trans, user, keys ): + """ + Override to return at least some usage info if user is anonymous. + """ + if self.user_manager.is_anonymous( user ): + return self.serialize_current_anonymous_user( trans, user, keys ) + return super( UserSerializer, self ).serialize( trans, user, keys ) + + +class AdminUserFilters( base.ModelFilterParser, deletable.PurgableFiltersMixin ): + model_class = model.User + + def _add_parsers( self ): + super( AdminUserFilters, self )._add_parsers() + deletable.PurgableFiltersMixin._add_parsers( self ) + + #PRECONDITION: user making the query has been verified as an admin + self.orm_filter_parsers.update({ + 'name' : { 'op': ( 'eq', 'contains', 'like' ) }, + 'email' : { 'op': ( 'eq', 'contains', 'like' ) }, + 'username' : { 'op': ( 'eq', 'contains', 'like' ) }, + 'active' : { 'op': ( 'eq' ) }, + 'disk_usage' : { 'op': ( 'le', 'ge' ) } + }) + + self.fn_filter_parsers.update({ + }) 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.
participants (1)
-
commits-noreply@bitbucket.org