mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
merge
This commit is contained in:
@@ -27,4 +27,4 @@ class LastzCoverage( Tabular ):
|
||||
MetadataElement( name="forwardCol", default=3, desc="Forward or aggregate read column", param=metadata.ColumnParameter )
|
||||
MetadataElement( name="reverseCol", desc="Optional reverse read column", param=metadata.ColumnParameter, optional=True, no_value=0 )
|
||||
MetadataElement( name="columns", default=3, desc="Number of columns", readonly=True, visible=False )
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ class Action( object ):
|
||||
class RBACAgent:
|
||||
"""Class that handles galaxy security"""
|
||||
permitted_actions = Bunch(
|
||||
#DATASET_EDIT_METADATA = Action(
|
||||
# "edit metadata", "Role members can edit this dataset's metadata in the library", "grant" ),
|
||||
DATASET_MANAGE_PERMISSIONS = Action(
|
||||
"manage permissions", "Role members can manage the roles associated with this dataset", "grant" ),
|
||||
DATASET_ACCESS = Action(
|
||||
@@ -482,7 +480,9 @@ class LibraryRBACAgent( RBACAgent ):
|
||||
alira.flush()
|
||||
|
||||
def show_library_item( self, user, library_item ):
|
||||
if self.allow_action( user, self.permitted_actions.LIBRARY_MODIFY, library_item ) or self.allow_action( user, self.permitted_actions.LIBRARY_MANAGE, library_item ) or self.allow_action( trans.user, self.permitted_actions.LIBRARY_ADD, library_item ):
|
||||
if self.allow_action( user, self.permitted_actions.LIBRARY_MODIFY, library_item ) or \
|
||||
self.allow_action( user, self.permitted_actions.LIBRARY_MANAGE, library_item ) or \
|
||||
self.allow_action( user, self.permitted_actions.LIBRARY_ADD, library_item ):
|
||||
return True
|
||||
if isinstance( library_item, self.model.Library ):
|
||||
return self.show_library_item( user, library_item.root_folder )
|
||||
|
||||
@@ -873,7 +873,7 @@ class Admin( BaseController ):
|
||||
library.flush()
|
||||
msg = "Library '%s' and all of its contents have been marked deleted" % library.name
|
||||
return trans.response.send_redirect( web.url_for( action='library_browser', msg=util.sanitize_text( msg ), messagetype='done' ) )
|
||||
elif action =='update_roles':
|
||||
elif action == 'update_roles':
|
||||
# The user clicked the Save button on the 'Associate With Roles' form
|
||||
permissions = {}
|
||||
for k, v in trans.app.model.library_security_agent.permitted_actions.items():
|
||||
@@ -989,7 +989,7 @@ class Admin( BaseController ):
|
||||
folder.name = new_name
|
||||
folder.description = new_description
|
||||
folder.flush()
|
||||
msg = "Folder '%s'has been renamed to '%s'" % ( old_name, new_name )
|
||||
msg = "Folder '%s' has been renamed to '%s'" % ( old_name, new_name )
|
||||
return trans.response.send_redirect( web.url_for( action='library_browser', msg=util.sanitize_text( msg ), messagetype='done' ) )
|
||||
return trans.fill_template( '/admin/library/rename_folder.mako', folder=folder, msg=msg, messagetype=messagetype )
|
||||
elif action == 'delete':
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import time, glob, os
|
||||
from itertools import cycle
|
||||
import hashlib
|
||||
|
||||
from mako import exceptions
|
||||
from mako.template import Template
|
||||
@@ -27,7 +28,6 @@ import paste.httpexceptions
|
||||
|
||||
# Database helpers
|
||||
SHOW_LABEL_LIMIT = 10000
|
||||
color = cycle( [LIGHT, WHITE] )
|
||||
|
||||
def list_labels(session):
|
||||
"""
|
||||
@@ -102,10 +102,9 @@ def build_tracks( param, conf, data_label, fit_label, pred_label, strand, show=F
|
||||
|
||||
return charts
|
||||
|
||||
def feature_chart(param=None, session=None, label=None, label_dict={}):
|
||||
def feature_chart(param=None, session=None, label=None, label_dict={}, color=cycle( [LIGHT, WHITE] ) ):
|
||||
# draw the ORF tracks
|
||||
all = feature_filter(feature_query(session=session, param=param), name=label, kdict=label_dict)
|
||||
if len(all) == 0: return []
|
||||
opts = track_options(
|
||||
xscale=param.xscale, w=param.width, fgColor=PURPLE,
|
||||
show_labels=param.show_labels, ylabel=str(label),
|
||||
@@ -164,13 +163,8 @@ class WebRoot(BaseController):
|
||||
FIT_LABEL = "%s-SIGMA-%d" % (data.metadata.label, 20),
|
||||
PRED_LABEL = "PRED-%s-SIGMA-%d" % (data.metadata.label, 20),
|
||||
)
|
||||
from atlas import hdf
|
||||
db = hdf.hdf_open( conf.HDF_DATABASE, mode='r' )
|
||||
conf.CHROM_FIELDS = [(x,x) for x in hdf.GroupData(db=db, name=conf.LABEL).labels]
|
||||
db.close()
|
||||
|
||||
param = atlas.Param( word=word )
|
||||
# search with features based on param.feature
|
||||
|
||||
# search for a given
|
||||
session = sql.get_session( conf.SQL_URI )
|
||||
@@ -252,32 +246,38 @@ class WebRoot(BaseController):
|
||||
# go and search for these
|
||||
return trans.response.send_redirect( web.url_for( controller='genetrack', action='search', word=param.feature, dataset_id=dataset_id ) )
|
||||
|
||||
# keep image at a sane size
|
||||
param.width = min( [2000, int(param.img_size)] )
|
||||
param.xscale = [ param.start, param.end ]
|
||||
param.show_labels = ( param.end - param.start ) <= SHOW_LABEL_LIMIT
|
||||
|
||||
# get the template and the function used to generate the tracks
|
||||
tmpl_name, track_maker = conf.PLOT_MAPPER[param.plot]
|
||||
|
||||
charts = []
|
||||
# check against a hash, display an image that already exists if it was previously created.
|
||||
hash = hashlib.sha1()
|
||||
hash.update(str(dataset_id))
|
||||
for key in sorted(kwds.keys()):
|
||||
hash.update(str(kwds[key]))
|
||||
fname = "%s.png" % hash.hexdigest()
|
||||
fpath = os.path.join(conf.IMAGE_DIR, fname)
|
||||
|
||||
fname, fpath = atlas_utils.make_tempfile( dir=conf.IMAGE_DIR, suffix='.png')
|
||||
charts = []
|
||||
param.fname = fname
|
||||
|
||||
# set the scale of the plot
|
||||
param.xscale = [ param.start, param.end ]
|
||||
|
||||
# when visualizing on wide scales labels are not useful
|
||||
param.show_labels = ( param.end - param.start ) <= SHOW_LABEL_LIMIT
|
||||
|
||||
# The SHA1 hash should uniquely identify the qs that created the plot...
|
||||
if os.path.exists(fpath):
|
||||
os.utime(fpath, (time.time(), time.time()))
|
||||
return trans.fill_template_mako(tmpl_name, conf=conf, form=form, param=param, dataset_id=dataset_id)
|
||||
|
||||
# If the hashed filename doesn't exist, create it.
|
||||
if track_maker is not None and os.path.exists( conf.HDF_DATABASE ):
|
||||
# generate the fit track
|
||||
charts = track_maker( param=param, conf=conf )
|
||||
|
||||
for label in list_labels( session ):
|
||||
charts.extend( feature_chart(param=param, session=session, label=label.name, label_dict={label.name:label.id}) )
|
||||
charts.extend( feature_chart(param=param, session=session, label=label.name, label_dict={label.name:label.id}, color=color))
|
||||
|
||||
track_chart = consolidate_charts( charts, param )
|
||||
track_chart.save(fname=fpath)
|
||||
|
||||
|
||||
return trans.fill_template_mako(tmpl_name, conf=conf, form=form, param=param, dataset_id=dataset_id)
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,11 @@ class Library( BaseController ):
|
||||
def browse( self, trans, msg=None, messagetype=None, **kwd ):
|
||||
libraries = trans.app.model.Library.filter( trans.app.model.Library.table.c.deleted==False ) \
|
||||
.order_by( trans.app.model.Library.table.c.name ).all()
|
||||
return trans.fill_template( '/library/browser.mako', libraries=libraries, default_action=kwd.get( 'default_action', None ), msg=msg, messagetype=messagetype )
|
||||
return trans.fill_template( '/library/browser.mako',
|
||||
libraries=libraries,
|
||||
default_action=kwd.get( 'default_action', None ),
|
||||
msg=msg,
|
||||
messagetype=messagetype )
|
||||
index = browse
|
||||
@web.expose
|
||||
def import_datasets( self, trans, import_ids=[], **kwd ):
|
||||
@@ -33,7 +37,7 @@ class Library( BaseController ):
|
||||
history.add_dataset( dataset )
|
||||
dataset.flush()
|
||||
history.flush()
|
||||
return trans.show_ok_message( "%i dataset(s) have been imported in to your history" % len( import_ids ), refresh_frames=['history'] )
|
||||
return trans.show_ok_message( "%i dataset(s) have been imported into your history" % len( import_ids ), refresh_frames=['history'] )
|
||||
else:
|
||||
# Can't use mkstemp - the file must not exist first
|
||||
try:
|
||||
|
||||
@@ -27,6 +27,7 @@ database/compiled_templates
|
||||
database/job_working_directory
|
||||
database/import
|
||||
database/pbs
|
||||
static/genetrack/plots
|
||||
"
|
||||
|
||||
for sample in $SAMPLES; do
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
<div class="toolFormTitle">Active datasets in your current history (${history.name})</div>
|
||||
<div class="toolFormBody">
|
||||
<form name="add_dataset_from_history">
|
||||
%if replace_dataset is not None:
|
||||
<input type="hidden" name="replace_id" value="${replace_dataset.id}"/>
|
||||
<div class="form-row">
|
||||
You are currently selecting a new file to replace '<a href="${h.url_for( controller='admin', action='dataset', id=replace_dataset.library_folder_dataset_association.id )}">${replace_dataset.name}</a>'.
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
%if replace_dataset:
|
||||
<input type="hidden" name="replace_id" value="${replace_dataset.id}"/>
|
||||
<div class="form-row">
|
||||
You are currently selecting a new file to replace '<a href="${h.url_for( controller='admin', action='dataset', id=replace_dataset.library_folder_dataset_association.id )}">${replace_dataset.name}</a>'.
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
%else:
|
||||
<input type="hidden" name="folder_id" value="${folder.id}"/>
|
||||
<input type="hidden" name="folder_id" value="${folder.id}"/>
|
||||
%endif
|
||||
%for dataset in history.active_datasets:
|
||||
<div class="form-row">
|
||||
|
||||
@@ -820,16 +820,20 @@ class TwillTestCase( unittest.TestCase ):
|
||||
tc.fv( "1", "2", description ) # form field 1 is the field named name...
|
||||
tc.submit( "create_library_button" )
|
||||
self.home()
|
||||
def rename_library( self, library_id, name='Library One Renamed', description='This is Library One Re-described', root_folder='' ):
|
||||
def rename_library( self, library_id, old_name, name='Library One Renamed', description='This is Library One Re-described', root_folder='' ):
|
||||
"""Rename a library"""
|
||||
self.home()
|
||||
self.visit_url( "%s/admin/library?rename=True&id=%s" % ( self.url, library_id ) )
|
||||
self.check_page_for_string( 'Change library name and description' )
|
||||
tc.fv( "1", "name", name )
|
||||
tc.fv( "1", "description", description )
|
||||
# Since twill barfs on the form submisson, we ar forced to simulate it
|
||||
url = "%s/admin/library?id=%s&rename=submitted&description=%s&name=%s" % \
|
||||
( self.url, library_id, description.replace( ' ', '+' ), name.replace( ' ', '+' ) )
|
||||
if root_folder:
|
||||
tc.fv( "1", "root_folder", root_folder )
|
||||
tc.submit( "rename_library_button" )
|
||||
url += "&root_folder=on"
|
||||
self.home()
|
||||
self.visit_url( url )
|
||||
check_str = "Library '%s' has been renamed to '%s'" % ( old_name, name )
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def add_folder( self, folder_id, name='Folder One', description='NThis is Folder One' ):
|
||||
"""Create a new folder"""
|
||||
@@ -840,14 +844,18 @@ class TwillTestCase( unittest.TestCase ):
|
||||
tc.fv( "1", "description", description ) # form field 2 is the field named description...
|
||||
tc.submit( "new_folder_button" )
|
||||
self.home()
|
||||
def rename_folder( self, folder_id, name='Folder One Renamed', description='This is Folder One Re-described' ):
|
||||
def rename_folder( self, folder_id, old_name, name='Folder One Renamed', description='This is Folder One Re-described' ):
|
||||
"""Rename a Folder"""
|
||||
self.home()
|
||||
self.visit_url( "%s/admin/folder?rename=True&id=%s" % ( self.url, folder_id ) )
|
||||
self.check_page_for_string( 'Edit folder name and description' )
|
||||
tc.fv( "1", "name", name ) # form field 1 is the field named name...
|
||||
tc.fv( "1", "description", description ) # form field 2 is the field named description...
|
||||
tc.submit( "rename_folder_button" )
|
||||
# Since twill barfs on the form submisson, we ar forced to simulate it
|
||||
url = "%s/admin/folder?id=%s&rename=submitted&description=%s&name=%s" % \
|
||||
( self.url, folder_id, description.replace( ' ', '+' ), name.replace( ' ', '+' ) )
|
||||
self.home()
|
||||
self.visit_url( url )
|
||||
check_str = "Folder '%s' has been renamed to '%s'" % ( old_name, name )
|
||||
self.check_page_for_string( check_str )
|
||||
self.home()
|
||||
def add_dataset( self, filename, folder_id, extension='auto', dbkey='hg18', roles=[] ):
|
||||
"""Add a dataset to a folder"""
|
||||
|
||||
@@ -169,9 +169,9 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
latest_history = galaxy.model.History.query().order_by( desc( galaxy.model.History.table.c.create_time ) ).first()
|
||||
self.upload_file( '1.bed' )
|
||||
latest_dataset = galaxy.model.Dataset.query().order_by( desc( galaxy.model.Dataset.table.c.create_time ) ).first()
|
||||
permissions_in = [ 'DATASET_EDIT_METADATA', 'DATASET_MANAGE_PERMISSIONS' ]
|
||||
permissions_in = [ 'DATASET_MANAGE_PERMISSIONS' ]
|
||||
# Make sure these are in sorted order for later comparison
|
||||
actions_in = [ 'edit metadata', 'manage permissions' ]
|
||||
actions_in = [ 'manage permissions' ]
|
||||
permissions_out = [ 'DATASET_ACCESS' ]
|
||||
actions_out = [ 'access' ]
|
||||
private_role = None
|
||||
@@ -452,24 +452,28 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
# Rename the library
|
||||
rename = "Library One's been Renamed"
|
||||
redescription="This is Library One's Re-described"
|
||||
self.rename_library( str( library_one.id ), name=rename, description=redescription, root_folder='on' )
|
||||
self.rename_library( str( library_one.id ), library_one.name, name=rename, description=redescription, root_folder='on' )
|
||||
self.home()
|
||||
self.visit_page( 'admin/libraries' )
|
||||
self.check_page_for_string( rename )
|
||||
self.check_page_for_string( redescription )
|
||||
# Reset the library back to the original name and description
|
||||
self.rename_library( str( library_one.id ), name=name, description=description, root_folder='on' )
|
||||
library_one.refresh()
|
||||
self.rename_library( str( library_one.id ), library_one.name, name=name, description=description, root_folder='on' )
|
||||
library_one.refresh()
|
||||
# Rename the root folder
|
||||
folder = library_one.root_folder
|
||||
rename = "Library One's Root Folder"
|
||||
redescription = "This is Library One's root folder"
|
||||
self.rename_folder( str( folder.id ), name=rename, description=redescription )
|
||||
self.rename_folder( str( folder.id ), folder.name, name=rename, description=redescription )
|
||||
self.home()
|
||||
self.visit_page( 'admin/libraries' )
|
||||
self.check_page_for_string( rename )
|
||||
self.check_page_for_string( redescription )
|
||||
# Reset the root folder back to the original name and description
|
||||
self.rename_folder( str( folder.id ), name=name, description=description )
|
||||
folder.refresh()
|
||||
self.rename_folder( str( folder.id ), folder.name, name=name, description=description )
|
||||
folder.refresh()
|
||||
def test_075_add_new_folder_to_root_folder( self ):
|
||||
"""Testing adding a folder to a library root folder"""
|
||||
self.login( email = 'test@bx.psu.edu' )
|
||||
@@ -593,8 +597,8 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
# Test importing the restricted dataset into a history, can't use the
|
||||
# ~/admin/libraries form as twill barfs on it so we'll simulate the form submission
|
||||
# by going directly to the form action
|
||||
self.visit_url( '%s/library/import_datasets?action=add&import_ids=%d' % ( self.url, lfda_two.id ) )
|
||||
self.check_page_for_string( '1 dataset(s) have been imported in to your history' )
|
||||
self.visit_url( '%s/library/import_datasets?do_action=add&import_ids=%d' % ( self.url, lfda_two.id ) )
|
||||
self.check_page_for_string( '1 dataset(s) have been imported into your history' )
|
||||
self.logout()
|
||||
# regular_user2 should not be able to see 2.bed
|
||||
self.login( email = 'test2@bx.psu.edu' )
|
||||
@@ -674,8 +678,8 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
self.check_page_for_string( 'This dataset is accessible by everyone (it is public).' )
|
||||
# Test importing a library dataset into a history
|
||||
self.home()
|
||||
self.visit_url( '%s/library/import_datasets?action=add&import_ids=%d' % ( self.url, lfda_three.id ) )
|
||||
self.check_page_for_string( '1 dataset(s) have been imported in to your history' )
|
||||
self.visit_url( '%s/library/import_datasets?do_action=add&import_ids=%d' % ( self.url, lfda_three.id ) )
|
||||
self.check_page_for_string( '1 dataset(s) have been imported into your history' )
|
||||
self.logout()
|
||||
def test_110_copy_dataset_from_history_to_root_folder( self ):
|
||||
"""Testing copying a dataset from the current history to a library root folder"""
|
||||
@@ -709,7 +713,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
for lfda in latest_3_lfdas:
|
||||
lfda_ids += '%s,' % str( lfda.id )
|
||||
lfda_ids = lfda_ids.rstrip( ',' )
|
||||
permissions = [ 'DATASET_ACCESS', 'DATASET_EDIT_METADATA', 'DATASET_MANAGE_PERMISSIONS' ]
|
||||
permissions = [ 'DATASET_ACCESS', 'DATASET_MANAGE_PERMISSIONS' ]
|
||||
def build_url( permissions, role ):
|
||||
# We'll bypass the admin/datasets method and directly call the admin/dataset method, setting
|
||||
# access, manage permissions, and edit metadata permissions to role_one
|
||||
@@ -726,11 +730,10 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
# be all of the above on any of the 3 datasets that are imported into a history
|
||||
for lfda in lfdas:
|
||||
self.home()
|
||||
self.visit_url( '%s/library/import_datasets?import_ids=%s' % ( self.url, str( lfda.id ) ) )
|
||||
self.visit_url( '%s/library/import_datasets?do_action=add&import_ids=%s' % ( self.url, str( lfda.id ) ) )
|
||||
self.home()
|
||||
self.visit_url( '%s/root/edit?lid=%s' % ( self.url, str( lfda.id ) ) )
|
||||
self.check_page_for_string( 'Edit Attributes' )
|
||||
self.check_page_for_string( 'input type="text" name="name" value="%s"' % lfda.name )
|
||||
self.check_page_for_string( 'You are currently viewing a Dataset from a library' )
|
||||
self.check_page_for_string( 'Manage permissions and role associations for %s' % lfda.name )
|
||||
self.check_page_for_string( 'select name="DATASET_MANAGE_PERMISSIONS_in"' )
|
||||
# admin_user is associated with role_one, so should have all permissions on imported datasets
|
||||
@@ -758,7 +761,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
self.logout()
|
||||
self.login( email='test@bx.psu.edu' )
|
||||
# Change the permissions and test again
|
||||
permissions = [ 'DATASET_ACCESS', 'DATASET_EDIT_METADATA' ]
|
||||
permissions = [ 'DATASET_ACCESS' ]
|
||||
url = build_url( permissions, role_one )
|
||||
self.home()
|
||||
self.visit_url( url )
|
||||
@@ -768,11 +771,10 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
# be all of the above on any of the 3 datasets that are imported into a history
|
||||
for lfda in lfdas:
|
||||
self.home()
|
||||
self.visit_url( '%s/library/import_datasets?import_ids=%s' % ( self.url, str( lfda.id ) ) )
|
||||
self.visit_url( '%s/library/import_datasets?do_action=add&import_ids=%s' % ( self.url, str( lfda.id ) ) )
|
||||
self.home()
|
||||
self.visit_url( '%s/root/edit?lid=%s' % ( self.url, str( lfda.id ) ) )
|
||||
self.check_page_for_string( 'Edit Attributes' )
|
||||
self.check_page_for_string( 'input type="text" name="name" value="%s"' % lfda.name )
|
||||
self.check_page_for_string( 'View Attributes' )
|
||||
try:
|
||||
# This should no longer be possible
|
||||
self.check_page_for_string( 'Manage permissions and role associations for %s' % lfda.name )
|
||||
@@ -1039,7 +1041,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
self.login( email='test1@bx.psu.edu' )
|
||||
# Change DefaultHistoryPermissions for regular_user1 back to the default
|
||||
permissions_in = [ 'DATASET_MANAGE_PERMISSIONS' ]
|
||||
permissions_out = [ 'DATASET_ACCESS', 'DATASET_EDIT_METADATA' ]
|
||||
permissions_out = [ 'DATASET_ACCESS' ]
|
||||
role_id = str( regular_user1_private_role.id )
|
||||
self.user_set_default_permissions( permissions_in=permissions_in, permissions_out=permissions_out, role_id=role_id )
|
||||
self.logout()
|
||||
|
||||
Reference in New Issue
Block a user