commit/galaxy-central: greg: Add a malicious flag to the tool shed's repository metadata - if true, downloading is restricted to only those users that can write to the repository. Fix a bug in determining if a user can write to a repository, and a bit of miscellaneous cleanup.

1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/2b954f70db10/ changeset: 2b954f70db10 user: greg date: 2011-08-02 20:19:38 summary: Add a malicious flag to the tool shed's repository metadata - if true, downloading is restricted to only those users that can write to the repository. Fix a bug in determining if a user can write to a repository, and a bit of miscellaneous cleanup. affected #: 15 files (9.6 KB) --- a/lib/galaxy/webapps/community/controllers/common.py Tue Aug 02 13:52:02 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Tue Aug 02 14:19:38 2011 -0400 @@ -33,6 +33,9 @@ # States for passing messages SUCCESS, INFO, WARNING, ERROR = "done", "info", "warning", "error" +malicious_error = " This changeset cannot be downloaded because it potentially produces malicious behavior or contains inappropriate content." +malicious_error_can_push = " Correct this changeset as soon as possible, it potentially produces malicious behavior or contains inappropriate content." + class ItemRatings( UsesItemRatings ): """Overrides rate_item method since we also allow for comments""" def rate_item( self, trans, user, item, rating, comment='' ): @@ -263,6 +266,12 @@ if str( ctx ) == change_set_revision: return ctx return None +def change_set_is_malicious( trans, id, change_set_revision, **kwd ): + """Check the malicious flag in repository metadata for a specified change set""" + repository_metadata = get_repository_metadata( trans, id, change_set_revision ) + if repository_metadata: + return repository_metadata.malicious + return False def copy_sample_loc_file( trans, filename ): """Copy xxx.loc.sample to ~/tool-data/xxx.loc""" sample_loc_file = os.path.split( filename )[1] --- a/lib/galaxy/webapps/community/controllers/repository.py Tue Aug 02 13:52:02 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Tue Aug 02 14:19:38 2011 -0400 @@ -427,10 +427,12 @@ current_working_dir = os.getcwd() # Update repository files for browsing. update_for_browsing( trans, repository, current_working_dir, commit_message=commit_message ) + is_malicious = change_set_is_malicious( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/browse_repository.mako', repo=repo, repository=repository, commit_message=commit_message, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -506,10 +508,12 @@ else: message = "Select at least 1 file to delete from the repository before clicking <b>Delete selected files</b>." status = "error" + is_malicious = change_set_is_malicious( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/browse_repository.mako', repo=repo, repository=repository, commit_message=commit_message, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -550,6 +554,13 @@ metadata = repository_metadata.metadata else: metadata = None + is_malicious = change_set_is_malicious( trans, id, repository.tip ) + if is_malicious: + if trans.app.security_agent.can_push( trans.user, repository ): + message += malicious_error_can_push + else: + message += malicious_error + status = 'error' return trans.fill_template( '/webapps/community/repository/view_repository.mako', repo=repo, repository=repository, @@ -558,6 +569,7 @@ display_reviews=display_reviews, num_ratings=num_ratings, alerts_check_box=alerts_check_box, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -669,8 +681,17 @@ repository_metadata = get_repository_metadata( trans, id, repository.tip ) if repository_metadata: metadata = repository_metadata.metadata + is_malicious = repository_metadata.malicious else: metadata = None + is_malicious = False + if is_malicious: + if trans.app.security_agent.can_push( trans.user, repository ): + message += malicious_error_can_push + else: + message += malicious_error + status = 'error' + malicious_check_box = CheckboxField( 'malicious', checked=is_malicious ) categories = get_categories( trans ) selected_categories = [ rca.category_id for rca in repository.categories ] return trans.fill_template( '/webapps/community/repository/manage_repository.mako', @@ -688,6 +709,8 @@ display_reviews=display_reviews, num_ratings=num_ratings, alerts_check_box=alerts_check_box, + malicious_check_box=malicious_check_box, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -713,9 +736,11 @@ 'parent' : ctx.parents()[0] } # Make sure we'll view latest changeset first. changesets.insert( 0, change_dict ) + is_malicious = change_set_is_malicious( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/view_changelog.mako', repository=repository, changesets=changesets, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -740,6 +765,7 @@ diffs = [] for diff in patch.diff( repo, node1=ctx_parent.node(), node2=ctx.node() ): diffs.append( self.to_html_escaped( diff ) ) + is_malicious = change_set_is_malicious( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/view_changeset.mako', repository=repository, ctx=ctx, @@ -752,6 +778,7 @@ ignored=ignored, clean=clean, diffs=diffs, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -781,12 +808,14 @@ avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, repository, webapp_model=trans.model ) display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) rra = self.get_user_item_rating( trans.sa_session, trans.user, repository, webapp_model=trans.model ) + is_malicious = change_set_is_malicious( trans, id, repository.tip ) return trans.fill_template( '/webapps/community/repository/rate_repository.mako', repository=repository, avg_rating=avg_rating, display_reviews=display_reviews, num_ratings=num_ratings, rra=rra, + is_malicious=is_malicious, message=message, status=status ) @web.expose @@ -829,12 +858,27 @@ @web.expose @web.require_login( "set repository metadata" ) def set_metadata( self, trans, id, ctx_str, **kwd ): - message, status = set_repository_metadata( trans, id, ctx_str, **kwd ) - if not message: - message = "Metadata for change set revision '%s' has been reset." % str( ctx_str ) + malicious = kwd.get( 'malicious', '' ) + if kwd.get( 'malicious_button', False ): + repository_metadata = get_repository_metadata( trans, id, ctx_str ) + malicious_checked = CheckboxField.is_checked( malicious ) + repository_metadata.malicious = malicious_checked + trans.sa_session.add( repository_metadata ) + trans.sa_session.flush() + if malicious_checked: + message = "The repository tip has been defined as malicious." + else: + message = "The repository tip has been defined as <b>not</b> malicious." + status = 'done' + else: + # The set_metadata_button was clicked + message, status = set_repository_metadata( trans, id, ctx_str, **kwd ) + if not message: + message = "Metadata for change set revision '%s' has been reset." % str( ctx_str ) return trans.response.send_redirect( web.url_for( controller='repository', action='manage_repository', id=id, + malicious=malicious, message=message, status=status ) ) @web.expose @@ -903,12 +947,14 @@ id=repository_id, message=message, status=status ) ) + is_malicious = change_set_is_malicious( trans, repository_id, repository.tip ) return trans.fill_template( '/webapps/community/repository/add_tool_data_table_entry.mako', name_attr=name_attr, repository=repository, comment_char=comment_char, loc_filename=loc_filename, column_fields=column_fields, + is_malicious=is_malicious, message=message, status=status ) def __get_column_fields( self, **kwd ): @@ -938,10 +984,12 @@ try: tool = load_tool( trans, os.path.abspath( tool_config ) ) tool_state = self.__new_state( trans ) + is_malicious = change_set_is_malicious( trans, repository_id, repository.tip ) return trans.fill_template( "/webapps/community/repository/tool_form.mako", repository=repository, tool=tool, tool_state=tool_state, + is_malicious=is_malicious, message=message, status=status ) except Exception, e: @@ -977,10 +1025,12 @@ metadata = tool_metadata_dict tool = load_tool( trans, os.path.abspath( metadata[ 'tool_config' ] ) ) break + is_malicious = change_set_is_malicious( trans, repository_id, repository.tip ) return trans.fill_template( "/webapps/community/repository/view_tool_metadata.mako", repository=repository, tool=tool, metadata=metadata, + is_malicious=is_malicious, message=message, status=status ) @web.expose --- a/lib/galaxy/webapps/community/model/__init__.py Tue Aug 02 13:52:02 2011 -0400 +++ b/lib/galaxy/webapps/community/model/__init__.py Tue Aug 02 14:19:38 2011 -0400 @@ -153,10 +153,11 @@ fp.close() class RepositoryMetadata( object ): - def __init__( self, repository_id=None, changeset_revision=None, metadata=None ): + def __init__( self, repository_id=None, changeset_revision=None, metadata=None, malicious=False ): self.repository_id = repository_id self.changeset_revision = changeset_revision self.metadata = metadata or dict() + self.malicious = malicious class ItemRatingAssociation( object ): def __init__( self, id=None, user=None, item=None, rating=0, comment='' ): --- a/lib/galaxy/webapps/community/model/mapping.py Tue Aug 02 13:52:02 2011 -0400 +++ b/lib/galaxy/webapps/community/model/mapping.py Tue Aug 02 14:19:38 2011 -0400 @@ -117,7 +117,8 @@ Column( "update_time", DateTime, default=now, onupdate=now ), Column( "repository_id", Integer, ForeignKey( "repository.id" ), index=True ), Column( "changeset_revision", TrimmedString( 255 ), index=True ), - Column( "metadata", JSONType, nullable=True ) ) + Column( "metadata", JSONType, nullable=True ), + Column( "malicious", Boolean, default=False ) ) RepositoryRatingAssociation.table = Table( "repository_rating_association", metadata, Column( "id", Integer, primary_key=True ), --- a/lib/galaxy/webapps/community/security/__init__.py Tue Aug 02 13:52:02 2011 -0400 +++ b/lib/galaxy/webapps/community/security/__init__.py Tue Aug 02 14:19:38 2011 -0400 @@ -6,6 +6,7 @@ from galaxy.util.bunch import Bunch from galaxy.util import listify from galaxy.model.orm import * +from mercurial import hg, ui log = logging.getLogger(__name__) @@ -155,17 +156,8 @@ for group in groups: self.associate_components( user=user, group=group ) def can_push( self, user, repository ): - # TODO: handle this via the mercurial api. - if not user: - return False - # Read the repository's hgrc file - hgrc_file = os.path.abspath( os.path.join( repository.repo_path, ".hg", "hgrc" ) ) - config = ConfigParser.ConfigParser() - config.read( hgrc_file ) - for option in config.options( "web" ): - if option == 'allow_push': - allowed = config.get( "web", option ) - return user.username in allowed + if user: + return user.username in listify( repository.allow_push ) return False def get_permitted_actions( filter=None ): --- a/templates/webapps/community/repository/add_tool_data_table_entry.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/add_tool_data_table_entry.mako Tue Aug 02 14:19:38 2011 -0400 @@ -6,6 +6,7 @@ is_new = repository.is_new can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_set_metadata = not is_new can_rate = not is_new and trans.user and repository.user != trans.user @@ -43,6 +44,8 @@ %endif %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> + %endif + %if can_download: <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a><a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a><a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> --- a/templates/webapps/community/repository/browse_repository.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/browse_repository.mako Tue Aug 02 14:19:38 2011 -0400 @@ -9,6 +9,7 @@ is_new = repository.is_new can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_rate = trans.user and repository.user != trans.user can_manage = is_admin or repository.user == trans.user @@ -80,9 +81,11 @@ %if can_rate: <a class="action-button" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ) )}">Rate repository</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %endif </div> %endif </ul> @@ -94,6 +97,12 @@ %if can_browse_contents: <div class="toolForm"><div class="toolFormTitle">Browse ${repository.name}</div> + %if can_download: + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div> + %endif %if can_push: <form name="select_files_to_delete" id="select_files_to_delete" action="${h.url_for( controller='repository', action='select_files_to_delete', id=trans.security.encode_id( repository.id ))}" method="post" ><div class="form-row" > --- a/templates/webapps/community/repository/manage_repository.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/manage_repository.mako Tue Aug 02 14:19:38 2011 -0400 @@ -8,6 +8,7 @@ is_new = repository.is_new can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_set_metadata = not is_new can_rate = not is_new and trans.user and repository.user != trans.user @@ -80,6 +81,8 @@ %endif %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> + %endif + %if can_download: <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a><a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a><a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> @@ -96,10 +99,12 @@ <div class="toolFormTitle">${repository.name}</div><div class="toolFormBody"><form name="edit_repository" id="edit_repository" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" > - <div class="form-row"> - <label>Clone this repository:</label> - ${render_clone_str( repository )} - </div> + %if can_download: + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div> + %endif <div class="form-row"><label>Name:</label><input name="repo_name" type="textfield" value="${repo_name}" size="40"/> @@ -304,7 +309,7 @@ %endif <p/><div class="toolForm"> - <div class="toolFormTitle">User access</div> + <div class="toolFormTitle">Grant authority to upload or push changes</div><div class="toolFormBody"><table class="grid"><tr> @@ -394,3 +399,24 @@ </div> %endif <p/> +%if not is_new and trans.user_is_admin(): + <p/> + <div class="toolForm"> + <div class="toolFormTitle">Malicious repository tip</div> + <div class="toolFormBody"> + <form name="malicious" id="malicious" action="${h.url_for( controller='repository', action='set_metadata', id=trans.security.encode_id( repository.id ), ctx_str=repository.tip )}" method="post"> + <div class="form-row"> + <label>Define repository tip as malicious:</label> + ${malicious_check_box.get_html()} + <div class="toolParamHelp" style="clear: both;"> + Check the box and click <b>Save</b> to define this repository's tip as malicious, restricting it from being download-able. + </div> + </div> + <div class="form-row"> + <input type="submit" name="malicious_button" value="Save"/> + </div> + </form> + </div> + </div> +%endif +<p/> --- a/templates/webapps/community/repository/rate_repository.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/rate_repository.mako Tue Aug 02 14:19:38 2011 -0400 @@ -1,5 +1,6 @@ <%namespace file="/message.mako" import="render_msg" /><%namespace file="/webapps/community/common/common.mako" import="*" /> +<%namespace file="/webapps/community/repository/common.mako" import="*" /><% from galaxy.web.framework.helpers import time_ago @@ -8,6 +9,7 @@ is_new = repository.is_new can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_rate = repository.user != trans.user can_manage = is_admin or repository.user == trans.user @@ -86,9 +88,11 @@ %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %endif </div> %endif </ul> @@ -96,6 +100,12 @@ %if repository.user != trans.user: <div class="toolForm"><div class="toolFormTitle">${repository.name}</div> + %if can_download: + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div> + %endif <div class="toolFormBody"><div class="form-row"><label>Description:</label> --- a/templates/webapps/community/repository/tool_form.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/tool_form.mako Tue Aug 02 14:19:38 2011 -0400 @@ -11,6 +11,7 @@ is_new = repository.is_new can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_rate = trans.user and repository.user != trans.user can_manage = is_admin or repository.user == trans.user @@ -130,9 +131,11 @@ %if can_rate: <a class="action-button" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ) )}">Rate repository</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %endif </div> %endif </ul> --- a/templates/webapps/community/repository/view_changelog.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/view_changelog.mako Tue Aug 02 14:19:38 2011 -0400 @@ -12,6 +12,7 @@ can_push = trans.app.security_agent.can_push( trans.user, repository ) can_rate = trans.user and repository.user != trans.user can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) if can_push: browse_label = 'Browse or delete repository files' else: @@ -55,9 +56,11 @@ %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %endif </div></ul> @@ -65,18 +68,26 @@ ${render_msg( message, status )} %endif -<div class="toolForm"> - <div class="toolFormTitle">${repository.name}</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Clone this repository:</label> - ${render_clone_str( repository )} +%if can_download: + <div class="toolForm"> + <div class="toolFormTitle">${repository.name}</div> + <div class="toolFormBody"> + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div></div></div> -</div> -<p/> + <p/> +%endif <div class="toolForm"> - <div class="toolFormTitle">Changesets</div> + <% + if can_download: + title_str = 'Changesets' + else: + title_str = '%s changesets' % repository.name + %> + <div class="toolFormTitle">${title_str}</div><% test_date = None %><div class="toolFormBody"><table class="grid"> --- a/templates/webapps/community/repository/view_changeset.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/view_changeset.mako Tue Aug 02 14:19:38 2011 -0400 @@ -13,6 +13,7 @@ can_push = trans.app.security_agent.can_push( trans.user, repository ) can_view_change_log = not is_new can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) if can_push: browse_label = 'Browse or delete repository files' else: @@ -59,9 +60,11 @@ %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %endif </div></ul> @@ -69,18 +72,26 @@ ${render_msg( message, status )} %endif -<div class="toolForm"> - <div class="toolFormTitle">${repository.name}</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Clone this repository:</label> - ${render_clone_str( repository )} +%if can_download: + <div class="toolForm"> + <div class="toolFormTitle">${repository.name}</div> + <div class="toolFormBody"> + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div></div></div> -</div> -<p/> + <p/> +%endif <div class="toolForm"> - <div class="toolFormTitle">Changeset ${ctx}</div> + <% + if can_download: + title_str = 'Changeset %s' % ctx + else: + title_str = '%s changeset %s' % ( repository.name, ctx ) + %> + <div class="toolFormTitle">${title_str}</div><div class="toolFormBody"><table class="grid"> %if modified: @@ -155,14 +166,19 @@ %endif %for diff in diffs: <% - # Read the first line of diff - line = diff.split( '\n' )[0] + # Read at most the first 10 lines of diff to determine the anchor + ctr = 0 + lines = diff.split( '\n' ) diff = diff.replace( '\n', '<br/>' ) anchor_str = '' - for anchor in anchors: - if line.find( anchor ) >= 0: - anchor_str = '<a name="%s">%s</a>' % ( anchor, anchor ) + for line in lines: + if ctr > 9: break + for anchor in anchors: + if line.find( anchor ) >= 0: + anchor_str = '<a name="%s">%s</a>' % ( anchor, anchor ) + break + ctr += 1 %><tr><td bgcolor="#E0E0E0">${anchor_str}</td></tr><tr><td>${diff}</td></tr> --- a/templates/webapps/community/repository/view_repository.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/view_repository.mako Tue Aug 02 14:19:38 2011 -0400 @@ -9,6 +9,7 @@ can_push = trans.app.security_agent.can_push( trans.user, repository ) can_rate = not is_new and trans.user and repository.user != trans.user can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_view_change_log = not is_new if can_push: @@ -79,6 +80,8 @@ %endif %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> + %endif + %if can_download: <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a><a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a><a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> @@ -94,10 +97,12 @@ <div class="toolForm"><div class="toolFormTitle">${repository.name}</div><div class="toolFormBody"> - <div class="form-row"> - <label>Clone this repository:</label> - ${render_clone_str( repository )} - </div> + %if can_download: + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div> + %endif <div class="form-row"><label>Name:</label> %if can_browse_contents: --- a/templates/webapps/community/repository/view_tool_metadata.mako Tue Aug 02 13:52:02 2011 -0400 +++ b/templates/webapps/community/repository/view_tool_metadata.mako Tue Aug 02 14:19:38 2011 -0400 @@ -10,6 +10,7 @@ is_new = repository.is_new can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push + can_download = not is_new and ( not is_malicious or can_push ) can_browse_contents = not is_new can_rate = repository.user != trans.user can_manage = is_admin or repository.user == trans.user @@ -50,9 +51,11 @@ %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> + %endif </div> %endif </ul> @@ -61,25 +64,21 @@ ${render_msg( message, status )} %endif -<div class="toolForm"> - <div class="toolFormTitle">${repository.name}</div> - <div class="toolFormBody"> - <div class="form-row"> - <label>Clone this repository:</label> - ${render_clone_str( repository )} +%if can_download: + <div class="toolForm"> + <div class="toolFormTitle">${repository.name}</div> + <div class="toolFormBody"> + <div class="form-row"> + <label>Clone this repository:</label> + ${render_clone_str( repository )} + </div></div></div> -</div> +%else: + <b>Repository name:</b><br/> + ${repository.name} +%endif %if metadata: -## "{"tools": -## [{"description": "data on any column using simple expressions", -## "id": "Filter1", -## "name": "Filter", -## "requirements": [], -## "tests": [{ -## "inputs": [["input", "1.bed", {"children": [], "value": "1.bed"}], ["cond", "c1=='chr22'", {"children": [], "value": "c1=='chr22'"}]], "name": "Test-1", -## "outputs": [["out_file1", "filter1_test1.bed", {"compare": "diff", "delta": 10000, "extra_files": [], "lines_diff": 0, "sort": false}]], -## "required_files": [["1.bed", {"children": [], "value": "1.bed"}]]}, {"inputs": [["input", "7.bed", {"children": [], "value": "7.bed"}], ["cond", "c1=='chr1' and c3-c2>=2000 and c6=='+'", {"children": [], "value": "c1=='chr1' and c3-c2>=2000 and c6=='+'"}]], "name": "Test-2", "outputs": [["out_file1", "filter1_test2.bed", {"compare": "diff", "delta": 10000, "extra_files": [], "lines_diff": 0, "sort": false}]], "required_files": [["7.bed", {"children": [], "value": "7.bed"}]]}], "tool_config": "database/community_files/000/repo_1/filtering.xml", "version": "1.0.1", "version_string_cmd": null}], "workflows": [{"a_galaxy_workflow": "true", "annotation": "", "format-version": "0.1", "name": "Workflow constructed from history 'Unnamed history'", "steps": {"0": {"annotation": "", "id": 0, "input_connections": {}, "inputs": [{"description": "", "name": "Input Dataset"}], "name": "Input dataset", "outputs": [], "position": {"left": 10, "top": 10}, "tool_errors": null, "tool_id": null, "tool_state": "{\\"name\\": \\"Input Dataset\\"}", "tool_version": null, "type": "data_input", "user_outputs": []}, "1": {"annotation": "", "id": 1, "input_connections": {"input": {"id": 0, "output_name": "output"}}, "inputs": [], "name": "Filter", "outputs": [{"name": "out_file1", "type": "input"}], "position": {"left": 230, "top": 10}, "post_job_actions": {}, "tool_errors": null, "tool_id": "Filter1", "tool_state": "{\\"__page__\\": 0, \\"cond\\": \\"\\\\\\"c1=='chr1'\\\\\\"\\", \\"chromInfo\\": \\"\\\\\\"/Users/gvk/workspaces_2008/central_051111/tool-data/shared/ucsc/chrom/?.len\\\\\\"\\", \\"input\\": \\"null\\"}", "tool_version": null, "type": "tool", "user_outputs": []}, "2": {"annotation": "", "id": 2, "input_connections": {"input1": {"id": 0, "output_name": "output"}, "input2": {"id": 1, "output_name": "out_file1"}}, "inputs": [], "name": "Subtract Whole Dataset", "outputs": [{"name": "output", "type": "input"}], "position": {"left": 450, "top": 10}, "post_job_actions": {}, "tool_errors": null, "tool_id": "subtract_query1", "tool_state": "{\\"input2\\": \\"null\\", \\"__page__\\": 0, \\"end_col\\": \\"{\\\\\\"__class__\\\\\\": \\\\\\"UnvalidatedValue\\\\\\", \\\\\\"value\\\\\\": \\\\\\"None\\\\\\"}\\", \\"begin_col\\": \\"{\\\\\\"__class__\\\\\\": \\\\\\"UnvalidatedValue\\\\\\", \\\\\\"value\\\\\\": \\\\\\"None\\\\\\"}\\", \\"input1\\": \\"null\\", \\"chromInfo\\": \\"\\\\\\"/Users/gvk/workspaces_2008/central_051111/tool-data/shared/ucsc/chrom/?.len\\\\\\"\\"}", "tool_version": null, "type": "tool", "user_outputs": []}}}]}" <p/><div class="toolForm"><div class="toolFormTitle">${metadata[ 'name' ]} tool metadata</div> @@ -89,26 +88,34 @@ <a href="${h.url_for( controller='repository', action='display_tool', repository_id=trans.security.encode_id( repository.id ), tool_config=metadata[ 'tool_config' ] )}">${metadata[ 'name' ]}</a><div style="clear: both"></div></div> - <div class="form-row"> - <label>Description:</label> - ${metadata[ 'description' ]} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Id:</label> - ${metadata[ 'id' ]} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version:</label> - ${metadata[ 'version' ]} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Version command string:</label> - ${metadata[ 'version_string_cmd' ]} - <div style="clear: both"></div> - </div> + %if 'description' in metadata: + <div class="form-row"> + <label>Description:</label> + ${metadata[ 'description' ]} + <div style="clear: both"></div> + </div> + %endif + %if 'id' in metadata: + <div class="form-row"> + <label>Id:</label> + ${metadata[ 'id' ]} + <div style="clear: both"></div> + </div> + %endif + %if 'version' in metadata: + <div class="form-row"> + <label>Version:</label> + ${metadata[ 'version' ]} + <div style="clear: both"></div> + </div> + %endif + %if 'version_string_cmd' in metadata: + <div class="form-row"> + <label>Version command string:</label> + ${metadata[ 'version_string_cmd' ]} + <div style="clear: both"></div> + </div> + %endif <div class="form-row"><label>Command:</label><pre>${tool.command}</pre> 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)
-
Bitbucket