[hg] galaxy 3314: merge
details: http://www.bx.psu.edu/hg/galaxy/rev/050b4ced619f changeset: 3314:050b4ced619f user: jeremy goecks <jeremy.goecks@emory.edu> date: Mon Feb 01 16:30:33 2010 -0500 description: merge diffstat: lib/galaxy/util/hash_util.py | 43 ++++++++++++++----------- lib/galaxy/web/controllers/library_common.py | 5 +-- lib/galaxy/web/framework/helpers/__init__.py | 4 +- templates/library/common/browse_library.mako | 4 +- templates/library/common/common.mako | 2 +- templates/library/common/ldda_info.mako | 26 +++++++++------ test/functional/test_security_and_libraries.py | 5 ++- 7 files changed, 49 insertions(+), 40 deletions(-) diffs (212 lines): diff -r 068d572a2bf8 -r 050b4ced619f lib/galaxy/util/hash_util.py --- a/lib/galaxy/util/hash_util.py Mon Feb 01 16:30:18 2010 -0500 +++ b/lib/galaxy/util/hash_util.py Mon Feb 01 16:30:33 2010 -0500 @@ -1,28 +1,33 @@ +""" +Utility functions for bi-directional Python version compatibility. Python 2.5 +introduced hashlib which replaced sha in Python 2.4 and previous versions. +""" + import sys, logging -using_24 = sys.version_info[:2] < ( 2, 5 ) -if using_24: - import sha -else: + +# Use hashlib module if for Python 2.5+, fall back on old sha and md5 modules +try: import hashlib + sha1 = hashlib.sha1 + md5 = hashlib.md5 +except ImportError, e: + import sha, md5 + sha1 = sha.new + md5 = md5.new + import hmac log = logging.getLogger( __name__ ) -""" -Utility functions for bi-directional Python version compatibility. Python 2.5 -introduced hashlib which replaced sha in Python 2.4 and previous versions. -""" def new_secure_hash( text_type=None ): - if using_24: - if text_type: - return sha.new( text_type ).hexdigest() - return sha.new() + """ + Returns either a sha1 hash object (if called with no arguments), or a + hexdigest of the sha1 hash of the argument `text_type`. + """ + if text_type: + return sha1( text_type ).hexdigest() else: - if text_type: - return hashlib.sha1( text_type ).hexdigest() - return hashlib.sha1() + return sha1() + def hmac_new( key, value ): - if using_24: - return hmac.new( key, value, sha ).hexdigest() - else: - return hmac.new( key, value, hashlib.sha1 ).hexdigest() + return hmac.new( key, value, sha1 ).hexdigest() diff -r 068d572a2bf8 -r 050b4ced619f lib/galaxy/web/controllers/library_common.py --- a/lib/galaxy/web/controllers/library_common.py Mon Feb 01 16:30:18 2010 -0500 +++ b/lib/galaxy/web/controllers/library_common.py Mon Feb 01 16:30:33 2010 -0500 @@ -491,7 +491,6 @@ show_deleted=show_deleted, widgets=widgets, current_user_roles=current_user_roles, - show_deleted=show_deleted, msg=msg, messagetype=messagetype ) @web.expose @@ -1288,8 +1287,7 @@ filter=dict( deleted=False ), form_type=trans.app.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE ) if not forms: - msg = "There are no forms on which to base the template, so create a form and " - msg += "try again to add the information template to the %s." % library_item_desc + msg = "There are no forms on which to base the template, so create a form and try to add the template again." trans.response.send_redirect( web.url_for( controller='forms', action='new', msg=msg, @@ -1342,7 +1340,6 @@ cntrller=cntrller, library_item_name=item.name, library_item_desc=library_item_desc, - library_id=library_id, item_type=item_type, library_id=library_id, folder_id=folder_id, diff -r 068d572a2bf8 -r 050b4ced619f lib/galaxy/web/framework/helpers/__init__.py --- a/lib/galaxy/web/framework/helpers/__init__.py Mon Feb 01 16:30:18 2010 -0500 +++ b/lib/galaxy/web/framework/helpers/__init__.py Mon Feb 01 16:30:33 2010 -0500 @@ -4,8 +4,8 @@ from webhelpers import * from galaxy.util.json import to_json_string +from galaxy.util import hash_util from datetime import datetime, timedelta -import hashlib # If the date is more than one week ago, then display the actual date instead of in words def time_ago( x ): @@ -50,6 +50,6 @@ """ Return hex encoded md5 hash of string s """ - m = hashlib.md5() + m = hash_util.md5() m.update( s ) return m.hexdigest() \ No newline at end of file diff -r 068d572a2bf8 -r 050b4ced619f templates/library/common/browse_library.mako --- a/templates/library/common/browse_library.mako Mon Feb 01 16:30:18 2010 -0500 +++ b/templates/library/common/browse_library.mako Mon Feb 01 16:30:33 2010 -0500 @@ -196,7 +196,7 @@ <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_display_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">View this dataset's information</a> %endif %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and ( ( cntrller in [ 'library_admin', 'requests_admin' ] or can_add ) and not info_association ): - <a class="action-button" href="${h.url_for( controller='library_common', action='add_info_template', cntrller=cntrller, item_type='ldda', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), ldda_id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Add template to this dataset</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='add_info_template', cntrller=cntrller, item_type='ldda', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), ldda_id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Add a template to this dataset</a> %endif %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and cntrller == 'library_admin' and info_association: <a class="action-button" href="${h.url_for( controller='library_common', action='delete_info_template', cntrller=cntrller, item_type='ldda', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), ldda_id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Delete this dataset's template</a> @@ -294,7 +294,7 @@ <a class="action-button" href="${h.url_for( controller='library_common', action='folder_info', cntrller=cntrller, id=trans.security.encode_id( folder.id ), library_id=library_id, show_deleted=show_deleted )}">Edit this folder's information</a> %endif %if not branch_deleted( folder ) and ( ( cntrller in [ 'library_admin', 'requests_admin' ] or can_add ) and not info_association ): - <a class="action-button" href="${h.url_for( controller='library_common', action='add_info_template', cntrller=cntrller, item_type='folder', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), show_deleted=show_deleted )}">Add template to this folder</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='add_info_template', cntrller=cntrller, item_type='folder', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), show_deleted=show_deleted )}">Add a template to this folder</a> %endif %if not branch_deleted( folder ) and cntrller == 'library_admin' and info_association: <a class="action-button" href="${h.url_for( controller='library_common', action='delete_info_template', cntrller=cntrller, item_type='folder', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), show_deleted=show_deleted )}">Delete this folder's template</a> diff -r 068d572a2bf8 -r 050b4ced619f templates/library/common/common.mako --- a/templates/library/common/common.mako Mon Feb 01 16:30:18 2010 -0500 +++ b/templates/library/common/common.mako Mon Feb 01 16:30:33 2010 -0500 @@ -265,7 +265,7 @@ ${field[ 'widget' ].get_html()} </div> <div class="toolParamHelp" style="clear: both;"> - ${field[ 'helptext' ]} + ${field[ 'helptext' ]}, leave blank to add a different template to this dataset after upload. </div> <div style="clear: both"></div> </div> diff -r 068d572a2bf8 -r 050b4ced619f templates/library/common/ldda_info.mako --- a/templates/library/common/ldda_info.mako Mon Feb 01 16:30:18 2010 -0500 +++ b/templates/library/common/ldda_info.mako Mon Feb 01 16:30:33 2010 -0500 @@ -1,13 +1,19 @@ <%inherit file="/base.mako"/> <%namespace file="/message.mako" import="render_msg" /> <%namespace file="/library/common/common.mako" import="render_template_info" /> -<% from galaxy import util %> +<% + from galaxy import util + from galaxy.web.controllers.library_common import branch_deleted -<% if ldda == ldda.library_dataset.library_dataset_dataset_association: current_version = True else: current_version = False + if ldda.user: + uploaded_by = ldda.user.email + else: + uploaded_by = 'anonymous' + info_association, inherited = ldda.get_info_association( restrict=True ) %> %if current_version: @@ -27,24 +33,22 @@ ${render_msg( msg, messagetype )} %endif -<% - if ldda.user: - uploaded_by = ldda.user.email - else: - uploaded_by = 'anonymous' -%> - <div class="toolForm"> <div class="toolFormTitle"> Information about ${ldda.name} - %if not library.deleted and not ldda.library_dataset.folder.deleted and not ldda.deleted: + %if not library.deleted and not branch_deleted( ldda.library_dataset.folder ) and not ldda.library_dataset.deleted: <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a> <div popupmenu="dataset-${ldda.id}-popup"> %if cntrller=='library_admin' or trans.app.security_agent.can_modify_library_item( current_user_roles, ldda.library_dataset ): <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_edit_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Edit this dataset's information</a> + %if not info_association: + <a class="action-button" href="${h.url_for( controller='library_common', action='add_info_template', cntrller=cntrller, item_type='ldda', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Add a template to this dataset</a> + %else: + <a class="action-button" href="${h.url_for( controller='library_common', action='delete_info_template', cntrller=cntrller, item_type='ldda', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Delete this dataset's template</a> + %endif %endif %if cntrller=='library_admin' or trans.app.security_agent.can_manage_dataset( current_user_roles, ldda.dataset ) and trans.app.security_agent.can_manage_library_item( current_user_roles, ldda.library_dataset ): - <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_permissions', library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Edit this dataset's permissions</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_permissions', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), id=trans.security.encode_id( ldda.id ), show_deleted=show_deleted )}">Edit this dataset's permissions</a> %endif %if current_version and ( cntrller=='library_admin' or trans.app.security_agent.can_modify_library_item( current_user_roles, ldda.library_dataset ) ): <a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), replace_id=trans.security.encode_id( ldda.library_dataset.id ), show_deleted=show_deleted )}">Upload a new version of this dataset</a> diff -r 068d572a2bf8 -r 050b4ced619f test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Mon Feb 01 16:30:18 2010 -0500 +++ b/test/functional/test_security_and_libraries.py Mon Feb 01 16:30:33 2010 -0500 @@ -118,7 +118,10 @@ dp = sa_session.query( galaxy.model.DatasetPermissions ) \ .filter( galaxy.model.DatasetPermissions.table.c.dataset_id==latest_dataset.id ) \ .first() - if not dp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action: + if not dp.action: + raise AssertionError( 'The Dataset id %d has no associated DatasetPermissions when is should have "manage permissions".' \ + % latest_dataset.id ) + elif not dp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action: raise AssertionError( 'The DatasetPermissions.action for dataset id %d is "%s", but it should be "manage permissions"' \ % ( latest_dataset.id, dp.action ) ) # Change DefaultHistoryPermissions for regular_user1
participants (1)
-
Greg Von Kuster