1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6f04f0729dc4/ Changeset: 6f04f0729dc4 User: martenson Date: 2014-03-31 21:36:49 Summary: data libraries, don't allow showing deleted libraries to non-admins; provide information what actions user is allowed to do on library; Affected #: 5 files diff -r f7810af7f40c9215f5a3db77053563bf7db0ebde -r 6f04f0729dc4d097a46dd8c98c586faf265a315f lib/galaxy/webapps/galaxy/api/libraries.py --- a/lib/galaxy/webapps/galaxy/api/libraries.py +++ b/lib/galaxy/webapps/galaxy/api/libraries.py @@ -33,13 +33,16 @@ query = trans.sa_session.query( trans.app.model.Library ) deleted = kwd.get( 'deleted', 'missing' ) try: - deleted = util.asbool( deleted ) + if not trans.user_is_admin(): # non-admins can't see deleted libraries + deleted = False + else: + deleted = util.asbool( deleted ) if deleted: query = query.filter( trans.app.model.Library.table.c.deleted == True ) else: query = query.filter( trans.app.model.Library.table.c.deleted == False ) except ValueError: - # given value wasn't true/false so we don't filter on this parameter at all + # given value wasn't true/false but the user is admin so we don't filter on this parameter at all pass current_user_role_ids = [ role.id for role in trans.get_current_user_roles() ] @@ -57,6 +60,16 @@ item = library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) if trans.app.security_agent.library_is_public( library, contents=False ): item[ 'public' ] = True + current_user_roles = trans.get_current_user_roles() + # can_user_add = trans.app.security_agent.can_add_library_item( current_user_roles, library.root_folder ) + if not trans.user_is_admin(): + item['can_user_add'] = trans.app.security_agent.can_add_library_item( current_user_roles, library ) + item['can_user_modify'] = trans.app.security_agent.can_modify_library_item( current_user_roles, library ) + item['can_user_manage'] = trans.app.security_agent.can_manage_library_item( current_user_roles, library ) + else: + item['can_user_add'] = True + item['can_user_modify'] = True + item['can_user_manage'] = True libraries.append( item ) return libraries diff -r f7810af7f40c9215f5a3db77053563bf7db0ebde -r 6f04f0729dc4d097a46dd8c98c586faf265a315f static/scripts/mvc/library/library-libraryrow-view.js --- a/static/scripts/mvc/library/library-libraryrow-view.js +++ b/static/scripts/mvc/library/library-libraryrow-view.js @@ -22,9 +22,16 @@ this.set_up_visual_features(library); }, - set_up_visual_features: function(library){ + set_up_visual_features: function(library, options){ if (library.get('deleted') === true){ this.$el.addClass('active'); + this.$el.find('.public_lib_ico').hide(); + this.$el.find('.undelete_library_btn').show(); + this.$el.find('.upload_library_btn').hide(); + this.$el.find('.edit_library_btn').hide(); + this.$el.find('.permission_library_btn').hide(); + this.$el.find('.cancel_library_btn').hide(); + this.$el.find('.delete_library_btn').hide(); } this.$el.show(); }, diff -r f7810af7f40c9215f5a3db77053563bf7db0ebde -r 6f04f0729dc4d097a46dd8c98c586faf265a315f static/scripts/mvc/library/library-librarytoolbar-view.js --- a/static/scripts/mvc/library/library-librarytoolbar-view.js +++ b/static/scripts/mvc/library/library-librarytoolbar-view.js @@ -21,6 +21,11 @@ this.render(); }, + render: function(){ + var toolbar_template = this.templateToolBar() + this.$el.html(toolbar_template({admin_user: Galaxy.currUser.isAdmin(), anon_user: Galaxy.currUser.isAnonymous()})) + }, + delegate_modal: function(event){ // probably should refactor to have this functionality in this view, not in the library view libraryListView.show_library_modal(event); @@ -37,11 +42,6 @@ } }, - render: function(){ - var toolbar_template = this.templateToolBar() - this.$el.html(toolbar_template()) - }, - templateToolBar: function(){ tmpl_array = []; @@ -49,10 +49,12 @@ // TOOLBAR tmpl_array.push(' <div id="toolbar_form" margin-top:0.5em; ">'); tmpl_array.push(' <h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>'); + tmpl_array.push(' <% if(admin_user === true) { %>'); tmpl_array.push(' <div id="library_toolbar">'); tmpl_array.push(' <input id="include_deleted_chk" style="margin: 0;" type="checkbox">include deleted</input>'); tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Create New Library" id="create_new_library_btn" class="primary-button" type="button"><span class="fa fa-plus"></span> New Library</button>'); tmpl_array.push(' </div>'); + tmpl_array.push(' <% } %>'); tmpl_array.push(' </div>'); tmpl_array.push(' <div id="libraries_element">'); tmpl_array.push(' </div>'); diff -r f7810af7f40c9215f5a3db77053563bf7db0ebde -r 6f04f0729dc4d097a46dd8c98c586faf265a315f static/scripts/packed/mvc/library/library-libraryrow-view.js --- a/static/scripts/packed/mvc/library/library-libraryrow-view.js +++ b/static/scripts/packed/mvc/library/library-libraryrow-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(b,d,e,c){var a=Backbone.View.extend({initialize:function(f){this.render(f)},render:function(g){var f=this.templateRow();this.setElement(f({library:g}));this.set_up_visual_features(g)},set_up_visual_features:function(f){if(f.get("deleted")===true){this.$el.addClass("active")}this.$el.show()},templateRow:function(){tmpl_array=[];tmpl_array.push(' <tr style="display:none;" data-id="<%- library.get("id") %>">');tmpl_array.push(' <td><a href="#folders/<%- library.get("root_folder_id") %>"><%- library.get("name") %></a></td>');tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>');tmpl_array.push(' <td class="right-center">');tmpl_array.push(' <% if(library.get("deleted") === true) { %>');tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Marked deleted" style="color:grey;" class="fa fa-ban fa-lg deleted_lib_ico"></span>');tmpl_array.push(' <% } else if(library.get("public") === true) { %>');tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Public" style="color:grey;" class="fa fa-globe fa-lg public_lib_ico"></span>');tmpl_array.push(" <% }%>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Upload to library" class="primary-button btn-xs upload_library_btn" type="button"><span class="fa fa-upload"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library" class="primary-button btn-xs edit_library_btn" type="button"><span class="fa fa-pencil"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify permissions" class="primary-button btn-xs permission_library_btn" type="button"><span class="fa fa-group"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Save changes" class="primary-button btn-xs save_library_btn" type="button" style="display:none;"><span class="fa fa-floppy-o"> Save</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Discard changes" class="primary-button btn-xs cancel_library_btn" type="button" style="display:none;"><span class="fa fa-times"> Cancel</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Delete library (can be undeleted later)" class="primary-button btn-xs delete_library_btn" type="button" style="display:none;"><span class="fa fa-trash-o"> Delete</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Undelete library" class="primary-button btn-xs undelete_library_btn" type="button" style="display:none;"><span class="fa fa-unlock"> Undelete</span></button>');tmpl_array.push(" </td>");tmpl_array.push(" </tr>");return _.template(tmpl_array.join(""))}});return{LibraryRowView:a}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(b,d,e,c){var a=Backbone.View.extend({initialize:function(f){this.render(f)},render:function(g){var f=this.templateRow();this.setElement(f({library:g}));this.set_up_visual_features(g)},set_up_visual_features:function(f,g){if(f.get("deleted")===true){this.$el.addClass("active");this.$el.find(".public_lib_ico").hide();this.$el.find(".undelete_library_btn").show();this.$el.find(".upload_library_btn").hide();this.$el.find(".edit_library_btn").hide();this.$el.find(".permission_library_btn").hide();this.$el.find(".cancel_library_btn").hide();this.$el.find(".delete_library_btn").hide()}this.$el.show()},templateRow:function(){tmpl_array=[];tmpl_array.push(' <tr style="display:none;" data-id="<%- library.get("id") %>">');tmpl_array.push(' <td><a href="#folders/<%- library.get("root_folder_id") %>"><%- library.get("name") %></a></td>');tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>');tmpl_array.push(' <td class="right-center">');tmpl_array.push(' <% if(library.get("deleted") === true) { %>');tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Marked deleted" style="color:grey;" class="fa fa-ban fa-lg deleted_lib_ico"></span>');tmpl_array.push(' <% } else if(library.get("public") === true) { %>');tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Public" style="color:grey;" class="fa fa-globe fa-lg public_lib_ico"></span>');tmpl_array.push(" <% }%>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Upload to library" class="primary-button btn-xs upload_library_btn" type="button"><span class="fa fa-upload"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library" class="primary-button btn-xs edit_library_btn" type="button"><span class="fa fa-pencil"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify permissions" class="primary-button btn-xs permission_library_btn" type="button"><span class="fa fa-group"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Save changes" class="primary-button btn-xs save_library_btn" type="button" style="display:none;"><span class="fa fa-floppy-o"> Save</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Discard changes" class="primary-button btn-xs cancel_library_btn" type="button" style="display:none;"><span class="fa fa-times"> Cancel</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Delete library (can be undeleted later)" class="primary-button btn-xs delete_library_btn" type="button" style="display:none;"><span class="fa fa-trash-o"> Delete</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Undelete library" class="primary-button btn-xs undelete_library_btn" type="button" style="display:none;"><span class="fa fa-unlock"> Undelete</span></button>');tmpl_array.push(" </td>");tmpl_array.push(" </tr>");return _.template(tmpl_array.join(""))}});return{LibraryRowView:a}}); \ No newline at end of file diff -r f7810af7f40c9215f5a3db77053563bf7db0ebde -r 6f04f0729dc4d097a46dd8c98c586faf265a315f static/scripts/packed/mvc/library/library-librarytoolbar-view.js --- a/static/scripts/packed/mvc/library/library-librarytoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-librarytoolbar-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(a,d,e,c){var b=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"delegate_modal","click #include_deleted_chk":"check_include_deleted"},initialize:function(){this.render()},delegate_modal:function(f){libraryListView.show_library_modal(f)},check_include_deleted:function(f){if(f.target.checked){libraryListView.preferences.set({with_deleted:true});libraryListView.render()}else{libraryListView.preferences.set({with_deleted:false});libraryListView.render()}},render:function(){var f=this.templateToolBar();this.$el.html(f())},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div id="libraries_container" style="width: 90%; margin: auto; margin-top:2em; overflow: auto !important; ">');tmpl_array.push(' <div id="toolbar_form" margin-top:0.5em; ">');tmpl_array.push(' <h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(' <input id="include_deleted_chk" style="margin: 0;" type="checkbox">include deleted</input>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Create New Library" id="create_new_library_btn" class="primary-button" type="button"><span class="fa fa-plus"></span> New Library</button>');tmpl_array.push(" </div>");tmpl_array.push(" </div>");tmpl_array.push(' <div id="libraries_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))}});return{ToolbarView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(a,d,e,c){var b=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"delegate_modal","click #include_deleted_chk":"check_include_deleted"},initialize:function(){this.render()},render:function(){var f=this.templateToolBar();this.$el.html(f({admin_user:Galaxy.currUser.isAdmin(),anon_user:Galaxy.currUser.isAnonymous()}))},delegate_modal:function(f){libraryListView.show_library_modal(f)},check_include_deleted:function(f){if(f.target.checked){libraryListView.preferences.set({with_deleted:true});libraryListView.render()}else{libraryListView.preferences.set({with_deleted:false});libraryListView.render()}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div id="libraries_container" style="width: 90%; margin: auto; margin-top:2em; overflow: auto !important; ">');tmpl_array.push(' <div id="toolbar_form" margin-top:0.5em; ">');tmpl_array.push(' <h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');tmpl_array.push(" <% if(admin_user === true) { %>");tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(' <input id="include_deleted_chk" style="margin: 0;" type="checkbox">include deleted</input>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Create New Library" id="create_new_library_btn" class="primary-button" type="button"><span class="fa fa-plus"></span> New Library</button>');tmpl_array.push(" </div>");tmpl_array.push(" <% } %>");tmpl_array.push(" </div>");tmpl_array.push(' <div id="libraries_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))}});return{ToolbarView:b}}); \ No newline at end of file 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.