commit/galaxy-central: greg: Add white space to the tool shed's admin and repository_review controllers per new Galaxy dev team standards and factor out grid utility methods.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d1f875d0f213/ changeset: d1f875d0f213 user: greg date: 2013-03-05 15:27:50 summary: Add white space to the tool shed's admin and repository_review controllers per new Galaxy dev team standards and factor out grid utility methods. affected #: 5 files diff -r 19d8ba6eddf37211ca69282f350bb67daa42958c -r d1f875d0f213c0ba5d858b34ac76d314803a6efb lib/galaxy/webapps/tool_shed/controllers/admin.py --- a/lib/galaxy/webapps/tool_shed/controllers/admin.py +++ b/lib/galaxy/webapps/tool_shed/controllers/admin.py @@ -93,6 +93,7 @@ changeset_revision=v ) ) # Render the list view return self.repository_grid( trans, **kwd ) + @web.expose @web.require_admin def browse_repository_metadata( self, trans, **kwd ): @@ -113,6 +114,7 @@ action='browse_repositories', **kwd ) ) return self.repository_metadata_grid( trans, **kwd ) + @web.expose @web.require_admin def create_category( self, trans, **kwd ): @@ -144,6 +146,7 @@ description=description, message=message, status=status ) + @web.expose @web.require_admin def delete_repository( self, trans, **kwd ): @@ -180,6 +183,7 @@ action='browse_repositories', message=util.sanitize_text( message ), status=status ) ) + @web.expose @web.require_admin def delete_repository_metadata( self, trans, **kwd ): @@ -204,6 +208,7 @@ action='browse_repository_metadata', message=util.sanitize_text( message ), status=status ) ) + @web.expose @web.require_admin def edit_category( self, trans, **kwd ): @@ -243,6 +248,7 @@ category=category, message=message, status=status ) + @web.expose @web.require_admin def manage_categories( self, trans, **kwd ): @@ -277,6 +283,7 @@ action='edit_category', **kwd ) ) return self.manage_category_grid( trans, **kwd ) + @web.expose @web.require_admin def regenerate_statistics( self, trans, **kwd ): @@ -289,6 +296,7 @@ return trans.fill_template( '/webapps/tool_shed/admin/statistics.mako', message=message, status=status ) + @web.expose @web.require_admin def reset_metadata_on_selected_repositories_in_tool_shed( self, trans, **kwd ): @@ -302,6 +310,7 @@ repositories_select_field=repositories_select_field, message=message, status=status ) + @web.expose @web.require_admin def undelete_repository( self, trans, **kwd ): @@ -341,6 +350,7 @@ action='browse_repositories', message=util.sanitize_text( message ), status='done' ) ) + @web.expose @web.require_admin def mark_category_deleted( self, trans, **kwd ): @@ -367,6 +377,7 @@ action='manage_categories', message=util.sanitize_text( message ), status='done' ) ) + @web.expose @web.require_admin def purge_category( self, trans, **kwd ): @@ -398,6 +409,7 @@ action='manage_categories', message=util.sanitize_text( message ), status='done' ) ) + @web.expose @web.require_admin def undelete_category( self, trans, **kwd ): diff -r 19d8ba6eddf37211ca69282f350bb67daa42958c -r d1f875d0f213c0ba5d858b34ac76d314803a6efb lib/galaxy/webapps/tool_shed/controllers/repository_review.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository_review.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository_review.py @@ -8,6 +8,7 @@ import tool_shed.util.shed_util_common as suc from galaxy.util.odict import odict import tool_shed.grids.repository_review_grids as repository_review_grids +import tool_shed.grids.util as grids_util from galaxy import eggs eggs.require('mercurial') @@ -48,7 +49,8 @@ id=repository_id, changeset_revision=changeset_revision, message=message, - status=status ) ) + status=status ) ) + @web.expose @web.require_login( "browse components" ) def browse_components( self, trans, **kwd ): @@ -59,6 +61,7 @@ action='create_component', **kwd ) ) return self.component_grid( trans, **kwd ) + @web.expose @web.require_login( "browse review" ) def browse_review( self, trans, **kwd ): @@ -75,6 +78,7 @@ review=review, message=message, status=status ) + def copy_review( self, trans, review_to_copy, review ): for component_review in review_to_copy.component_reviews: copied_component_review = trans.model.ComponentReview( repository_review_id=review.id, @@ -89,6 +93,7 @@ review.rating = review_to_copy.rating trans.sa_session.add( review ) trans.sa_session.flush() + @web.expose @web.require_login( "create component" ) def create_component( self, trans, **kwd ): @@ -119,6 +124,7 @@ description=description, message=message, status=status ) + @web.expose @web.require_login( "create review" ) def create_review( self, trans, **kwd ): @@ -183,6 +189,7 @@ return trans.response.send_redirect( web.url_for( controller='repository_review', action='view_or_manage_repository', **kwd ) ) + @web.expose @web.require_login( "edit component" ) def edit_component( self, trans, **kwd ): @@ -213,6 +220,7 @@ component=component, message=message, status=status ) + @web.expose @web.require_login( "edit review" ) def edit_review( self, trans, **kwd ): @@ -324,10 +332,10 @@ selected_value = review.approved else: selected_value = trans.model.ComponentReview.approved_states.NO - revision_approved_select_field = build_approved_select_field( trans, - name='revision_approved', - selected_value=selected_value, - for_component=False ) + revision_approved_select_field = grids_util.build_approved_select_field( trans, + name='revision_approved', + selected_value=selected_value, + for_component=False ) rev, changeset_revision_label = suc.get_rev_label_from_changeset_revision( repo, review.changeset_revision ) return trans.fill_template( '/webapps/tool_shed/repository_review/edit_review.mako', repository=repository, @@ -337,6 +345,7 @@ components_dict=components_dict, message=message, status=status ) + @web.expose @web.require_login( "manage components" ) def manage_components( self, trans, **kwd ): @@ -357,6 +366,7 @@ kwd[ 'message' ] = message kwd[ 'status' ] = status return self.component_grid( trans, **kwd ) + @web.expose @web.require_login( "manage repositories reviewed by me" ) def manage_repositories_reviewed_by_me( self, trans, **kwd ): @@ -371,6 +381,7 @@ **kwd ) ) self.repositories_reviewed_by_me_grid.title = 'Repositories reviewed by me' return self.repositories_reviewed_by_me_grid( trans, **kwd ) + @web.expose @web.require_login( "manage repositories with reviews" ) def manage_repositories_with_reviews( self, trans, **kwd ): @@ -386,6 +397,7 @@ action='view_or_manage_repository', **kwd ) ) return self.repositories_with_reviews_grid( trans, **kwd ) + @web.expose @web.require_login( "manage repositories without reviews" ) def manage_repositories_without_reviews( self, trans, **kwd ): @@ -400,6 +412,7 @@ action='view_or_manage_repository', **kwd ) ) return self.repositories_without_reviews_grid( trans, **kwd ) + @web.expose @web.require_login( "manage repository reviews" ) def manage_repository_reviews( self, trans, mine=False, **kwd ): @@ -447,6 +460,7 @@ mine=mine, message=message, status=status ) + @web.expose @web.require_login( "manage repository reviews of revision" ) def manage_repository_reviews_of_revision( self, trans, **kwd ): @@ -470,6 +484,7 @@ installable=installable, message=message, status=status ) + @web.expose @web.require_login( "repository reviews by user" ) def repository_reviews_by_user( self, trans, **kwd ): @@ -496,6 +511,7 @@ user = suc.get_user( trans, kwd[ 'id' ] ) self.repository_reviews_by_user_grid.title = "All repository revision reviews for user '%s'" % user.username return self.repository_reviews_by_user_grid( trans, **kwd ) + @web.expose @web.require_login( "reviewed repositories i own" ) def reviewed_repositories_i_own( self, trans, **kwd ): @@ -514,6 +530,7 @@ action='view_or_manage_repository', **kwd ) ) return self.reviewed_repositories_i_own_grid( trans, **kwd ) + @web.expose @web.require_login( "select previous review" ) def select_previous_review( self, trans, **kwd ): @@ -533,6 +550,7 @@ previous_reviews_dict=previous_reviews_dict, message=message, status=status ) + @web.expose @web.require_login( "view or manage repository" ) def view_or_manage_repository( self, trans, **kwd ): @@ -545,16 +563,3 @@ return trans.response.send_redirect( web.url_for( controller='repository', action='view_repository', **kwd ) ) - -# ----- Utility methods ----- - -def build_approved_select_field( trans, name, selected_value=None, for_component=True ): - options = [ ( 'No', trans.model.ComponentReview.approved_states.NO ), - ( 'Yes', trans.model.ComponentReview.approved_states.YES ) ] - if for_component: - options.append( ( 'Not applicable', trans.model.ComponentReview.approved_states.NA ) ) - select_field = SelectField( name=name ) - for option_tup in options: - selected = selected_value and option_tup[1] == selected_value - select_field.add_option( option_tup[0], option_tup[1], selected=selected ) - return select_field diff -r 19d8ba6eddf37211ca69282f350bb67daa42958c -r d1f875d0f213c0ba5d858b34ac76d314803a6efb lib/tool_shed/grids/util.py --- a/lib/tool_shed/grids/util.py +++ b/lib/tool_shed/grids/util.py @@ -2,8 +2,18 @@ import tool_shed.util.shed_util_common as suc from galaxy.web.form_builder import SelectField -def build_changeset_revision_select_field( trans, repository, selected_value=None, add_id_to_name=True, - downloadable=False, reviewed=False, not_reviewed=False ): +def build_approved_select_field( trans, name, selected_value=None, for_component=True ): + options = [ ( 'No', trans.model.ComponentReview.approved_states.NO ), + ( 'Yes', trans.model.ComponentReview.approved_states.YES ) ] + if for_component: + options.append( ( 'Not applicable', trans.model.ComponentReview.approved_states.NA ) ) + select_field = SelectField( name=name ) + for option_tup in options: + selected = selected_value and option_tup[ 1 ] == selected_value + select_field.add_option( option_tup[ 0 ], option_tup[ 1 ], selected=selected ) + return select_field + +def build_changeset_revision_select_field( trans, repository, selected_value=None, add_id_to_name=True, downloadable=False, reviewed=False, not_reviewed=False ): """Build a SelectField whose options are the changeset_rev strings of certain revisions of the received repository.""" options = [] changeset_tups = [] @@ -40,7 +50,7 @@ # the changeset revisions may not be sorted correctly because setting metadata over time will reset update_time. for changeset_tup in sorted( changeset_tups ): # Display the latest revision first. - options.insert( 0, ( changeset_tup[1], changeset_tup[2] ) ) + options.insert( 0, ( changeset_tup[ 1 ], changeset_tup[ 2 ] ) ) if add_id_to_name: name = 'changeset_revision_%d' % repository.id else: @@ -49,6 +59,6 @@ refresh_on_change=True, refresh_on_change_values=refresh_on_change_values ) for option_tup in options: - selected = selected_value and option_tup[1] == selected_value - select_field.add_option( option_tup[0], option_tup[1], selected=selected ) + selected = selected_value and option_tup[ 1 ] == selected_value + select_field.add_option( option_tup[ 0 ], option_tup[ 1 ], selected=selected ) return select_field diff -r 19d8ba6eddf37211ca69282f350bb67daa42958c -r d1f875d0f213c0ba5d858b34ac76d314803a6efb templates/webapps/tool_shed/repository_review/edit_review.mako --- a/templates/webapps/tool_shed/repository_review/edit_review.mako +++ b/templates/webapps/tool_shed/repository_review/edit_review.mako @@ -4,7 +4,7 @@ <% from galaxy.web.form_builder import CheckboxField - from galaxy.webapps.tool_shed.controllers.repository_review import build_approved_select_field + from tool_shed.grids.util import build_approved_select_field from galaxy.webapps.tool_shed.util.container_util import STRSEP can_manage_repository = is_admin or repository.user == trans.user %> diff -r 19d8ba6eddf37211ca69282f350bb67daa42958c -r d1f875d0f213c0ba5d858b34ac76d314803a6efb templates/webapps/tool_shed/repository_review/reviews_of_changeset_revision.mako --- a/templates/webapps/tool_shed/repository_review/reviews_of_changeset_revision.mako +++ b/templates/webapps/tool_shed/repository_review/reviews_of_changeset_revision.mako @@ -4,7 +4,7 @@ <%namespace file="/webapps/tool_shed/repository/common.mako" import="*" /><% - from galaxy.webapps.tool_shed.controllers.repository_review import build_approved_select_field + from tool_shed.grids.util import build_approved_select_field from galaxy.webapps.tool_shed.util.container_util import STRSEP is_admin = trans.user_is_admin() is_new = repository.is_new( trans.app ) 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