# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1280416255 14400 # Node ID b0cf8217826e7a289eec88fd31894683818d2bee # Parent d27912281a74ba74a8df6f5d72db7c553ca846c5 lims: - fixed couple of broken links - comminting the db migrate script (0052) skipped in the previous commit --- /dev/null +++ b/lib/galaxy/model/migrate/versions/0052_sample_dataset_table.py @@ -0,0 +1,92 @@ +""" +Migration script to add the sample_dataset table and remove the 'dataset_files' column +from the 'sample' table +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset import * +from sqlalchemy.exc import * + +from galaxy.model.custom_types import * +from galaxy.util.json import from_json_string, to_json_string + +import datetime +now = datetime.datetime.utcnow + +import logging +log = logging.getLogger( __name__ ) + +metadata = MetaData( migrate_engine ) +db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) + + +def nextval( table, col='id' ): + if migrate_engine.name == 'postgres': + return "nextval('%s_%s_seq')" % ( table, col ) + elif migrate_engine.name == 'mysql' or migrate_engine.name == 'sqlite': + return "null" + else: + raise Exception( 'Unable to convert data for unknown database type: %s' % migrate_engine.name ) + +def localtimestamp(): + if migrate_engine.name == 'postgres' or migrate_engine.name == 'mysql': + return "LOCALTIMESTAMP" + elif migrate_engine.name == 'sqlite': + return "current_date || ' ' || current_time" + else: + raise Exception( 'Unable to convert data for unknown database type: %s' % db ) + +SampleDataset_table = Table('sample_dataset', metadata, + Column( "id", Integer, primary_key=True ), + Column( "create_time", DateTime, default=now ), + Column( "update_time", DateTime, default=now, onupdate=now ), + Column( "sample_id", Integer, ForeignKey( "sample.id" ), index=True ), + Column( "name", TrimmedString( 255 ), nullable=False ), + Column( "file_path", TrimmedString( 255 ), nullable=False ), + Column( "status", TrimmedString( 255 ), nullable=False ), + Column( "error_msg", TEXT ), + Column( "size", TrimmedString( 255 ) ) ) + +def upgrade(): + print __doc__ + metadata.reflect() + try: + SampleDataset_table.create() + except Exception, e: + log.debug( "Creating sample_dataset table failed: %s" % str( e ) ) + + cmd = "SELECT id, dataset_files FROM sample" + result = db_session.execute( cmd ) + for r in result: + sample_id = r[0] + dataset_files = from_json_string(r[1]) + for df in dataset_files: + cmd = "INSERT INTO sample_dataset VALUES (%s, %s, %s, %s, '%s', '%s', '%s', '%s', '%s')" + cmd = cmd % ( nextval('sample_dataset'), + localtimestamp(), + localtimestamp(), + str(sample_id), + df['name'], + df['filepath'], + df['status'], + df['error_msg'].replace('"', '').replace("'", ""), + df['size'] ) + db_session.execute( cmd ) + + # Delete the dataset_files column in the Sample table + try: + Sample_table = Table( "sample", metadata, autoload=True ) + except NoSuchTableError: + Sample_table = None + log.debug( "Failed loading table sample" ) + if Sample_table: + try: + Sample_table.c.dataset_files.drop() + except Exception, e: + log.debug( "Deleting column 'dataset_files' from the 'sample' table failed: %s" % ( str( e ) ) ) + + +def downgrade(): + pass --- a/templates/requests/common/events.mako +++ b/templates/requests/common/events.mako @@ -4,7 +4,7 @@ <h2>History of Sequencing Request "${request.name}"</h2><ul class="manage-table-actions"><li> - <a class="action-button" href="${h.url_for( controller=cntrller, action='list', operation='show_request', id=trans.security.encode_id(request.id) )}"> + <a class="action-button" href="${h.url_for( controller=cntrller, action='list', operation='show', id=trans.security.encode_id(request.id) )}"><span>Browse this request</span></a></li><li> --- a/templates/admin/requests/reject.mako +++ b/templates/admin/requests/reject.mako @@ -8,12 +8,12 @@ <h2>Reject Sequencing Request "${request.name}"</h2><ul class="manage-table-actions"><li> - <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='show_request', id=trans.security.encode_id(request.id) )}"> - <span>Browse this request</span></a> + <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='events', id=trans.security.encode_id(request.id) )}"> + <span>Events</span></a></li><li> - <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='events', id=trans.security.encode_id(request.id) )}"> - <span>Events</span></a> + <a class="action-button" href="${h.url_for( controller='requests_admin', action='list', operation='show', id=trans.security.encode_id(request.id) )}"> + <span>Browse this request</span></a></li></ul><h3>User: ${request.user.email}</h3> --- a/templates/admin/requests/datasets_grid.mako +++ b/templates/admin/requests/datasets_grid.mako @@ -4,7 +4,6 @@ <%def name="custom_javascripts()"><script type="text/javascript"> $("#select-dataset-action-button").bind( "click", function(e) { - alert('afdhblvi') $.ajax({ url: "${h.url_for( controller='requests_admin', action='remote_file_browser' )}", data: {id: 6},