galaxy-dev
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- 10007 discussions
10 Aug '09
details: http://www.bx.psu.edu/hg/galaxy/rev/50ce3d8388f8
changeset: 2550:50ce3d8388f8
user: Greg Von Kuster <greg(a)bx.psu.edu>
date: Fri Aug 07 16:11:14 2009 -0400
description:
Re-introduce library templates which are now based on the new Galaxy forms. A library template can be added to a library item ( library, folder, library dataset ), and will be inherited downward in the library hierarchy. A new template can be added to a library item as long as no template field contents have previously been filled in. If template field contents were previously filled in, that template must remain for the current time.
More work is needed on for this feature, including additional work on the forms. Functional tests are under way, but much more work is needed here as well.
56 file(s) affected in this change:
lib/galaxy/model/__init__.py
lib/galaxy/model/mapping.py
lib/galaxy/model/migrate/versions/0006_change_qual_datatype.py
lib/galaxy/model/migrate/versions/0007_sharing_histories.py
lib/galaxy/model/migrate/versions/0008_galaxy_forms.py
lib/galaxy/model/migrate/versions/0009_request_table.py
lib/galaxy/model/migrate/versions/0010_hda_display_at_authz_table.py
lib/galaxy/model/migrate/versions/0011_v0010_mysql_index_fix.py
lib/galaxy/model/migrate/versions/0012_user_address.py
lib/galaxy/model/migrate/versions/0013_change_lib_item_templates_to_forms.py
lib/galaxy/security/__init__.py
lib/galaxy/web/controllers/admin.py
lib/galaxy/web/controllers/forms.py
lib/galaxy/web/controllers/library.py
lib/galaxy/web/controllers/library_dataset.py
lib/galaxy/web/controllers/requests.py
lib/galaxy/web/controllers/requests_admin.py
templates/admin/forms/create_form.mako
templates/admin/forms/edit_form.mako
templates/admin/forms/manage_forms.mako
templates/admin/library/browse_library.mako
templates/admin/library/common.mako
templates/admin/library/create_info_template.mako
templates/admin/library/edit_info_template.mako
templates/admin/library/folder_info.mako
templates/admin/library/info_permissions.mako
templates/admin/library/info_template_permissions.mako
templates/admin/library/ldda_edit_info.mako
templates/admin/library/ldda_info.mako
templates/admin/library/library_dataset_info.mako
templates/admin/library/library_info.mako
templates/admin/library/new_dataset.mako
templates/admin/library/new_info.mako
templates/admin/library/new_info_template.mako
templates/admin/library/select_info_template.mako
templates/admin/requests/create_request_type.mako
templates/dataset/security_common.mako
templates/history/options.mako
templates/library/browse_library.mako
templates/library/common.mako
templates/library/create_info_template.mako
templates/library/edit_info_template.mako
templates/library/folder_info.mako
templates/library/info_permissions.mako
templates/library/info_template_permissions.mako
templates/library/ldda_edit_info.mako
templates/library/ldda_info.mako
templates/library/library_dataset_info.mako
templates/library/library_info.mako
templates/library/new_dataset.mako
templates/library/new_info.mako
templates/library/new_info_template.mako
templates/library/select_info_template.mako
templates/mobile/manage_library.mako
test/base/twilltestcase.py
test/functional/test_security_and_libraries.py
diffs (truncated from 5492 to 3000 lines):
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/__init__.py Fri Aug 07 16:11:14 2009 -0400
@@ -308,30 +308,6 @@
self.library_dataset_dataset_association = library_item
else:
raise "Invalid LibraryDatasetDatasetAssociation specified: %s" % library_item.__class__.__name__
- self.role = role
-
-class LibraryItemInfoPermissions( object ):
- def __init__( self, action, library_item, role ):
- # LIBRARY_ADD -> Not Applicable
- # LIBRARY_MODIFY -> Can modify LibraryItemInfoElement.contents
- # LIBRARY_MANAGE -> Can change permissions on LibraryItemInfo
- self.action = action
- if isinstance( library_item, LibraryItemInfo ):
- self.library_item_info = library_item
- else:
- raise "Invalid LibraryItemInfo specified: %s" % library_item.__class__.__name__
- self.role = role
-
-class LibraryItemInfoTemplatePermissions( object ):
- def __init__( self, action, library_item, role ):
- # LIBRARY_ADD -> Not Applicable
- # LIBRARY_MODIFY -> Can add or delete LibraryItemInfoTemplateElements
- # LIBRARY_MANAGE -> Can change permissions on LibraryItemInfoTemplate
- self.action = action
- if isinstance( library_item, LibraryItemInfoTemplate ):
- self.library_item_info_template = library_item
- else:
- raise "Invalid LibraryItemInfoTemplate specified: %s" % library_item.__class__.__name__
self.role = role
class DefaultUserPermissions( object ):
@@ -701,12 +677,10 @@
self.name = name or "Unnamed library"
self.description = description
self.root_folder = root_folder
- def get_library_item_info_templates( self, template_list=[], restrict=False ):
- # We only want the next available template in the inheritable hierarchy, so we'll only extend
- # template_list if it is empty
- if not template_list and self.library_info_template_associations:
- template_list.extend( [ lita.library_item_info_template for lita in self.library_info_template_associations if lita.library_item_info_template not in template_list ] )
- return template_list
+ def get_info_association( self, restrict=False ):
+ if self.info_association:
+ return self.info_association[0]
+ return None
class LibraryFolder( object ):
def __init__( self, name=None, description=None, item_count=0, order_id=None ):
@@ -725,18 +699,19 @@
folder.parent_id = self.id
folder.order_id = self.item_count
self.item_count += 1
- def get_library_item_info_templates( self, template_list=[], restrict=False ):
- # If restrict is True, we'll return only those templates directly associated with this Folder
- # We only want the next available template in the inheritable hierarchy, so we'll only extend
- # template_list if it is empty
- if not template_list and self.library_folder_info_template_associations:
- template_list.extend( [ lfita.library_item_info_template for lfita in self.library_folder_info_template_associations if lfita.library_item_info_template not in template_list ] )
- if not template_list and restrict not in [ 'True', True ] and self.parent:
- self.parent.get_library_item_info_templates( template_list )
- elif not template_list and restrict not in [ 'True', True, 'folder' ] and self.library_root:
- for library_root in self.library_root:
- library_root.get_library_item_info_templates( template_list )
- return template_list
+ def get_info_association( self, restrict=False ):
+ # If restrict is True, we will return this folder's info_association whether it
+ # exists or not. If restrict is False, we'll return the next available info_association
+ # in the inheritable hierarchy
+ if self.info_association:
+ return self.info_association[0]
+ if restrict:
+ return None
+ if self.parent:
+ return self.parent.get_info_association()
+ if self.library_root:
+ return self.library_root[0].get_info_association()
+ return None
@property
def active_components( self ):
return list( self.active_folders ) + list( self.active_datasets )
@@ -796,15 +771,6 @@
if not purged and self.purged:
raise Exception( "Cannot unpurge once purged" )
purged = property( get_purged, set_purged )
- def get_library_item_info_templates( self, template_list=[], restrict=False ):
- # If restrict is True, we'll return only those templates directly associated with this LibraryDataset
- # We only want the next available template in the inheritable hierarchy, so we'll only extend
- # template_list if it is empty
- if not template_list and self.library_dataset_info_template_associations:
- template_list.extend( [ ldita.library_item_info_template for ldita in self.library_dataset_info_template_associations if ldita.library_item_info_template not in template_list ] )
- if not template_list and restrict not in [ 'True', True ]:
- self.folder.get_library_item_info_templates( template_list, restrict )
- return template_list
class LibraryDatasetDatasetAssociation( DatasetInstance ):
def __init__( self,
@@ -867,105 +833,34 @@
return ldda
def clear_associated_files( self, metadata_safe = False, purge = False ):
return
- def get_library_item_info_templates( self, template_list=[], restrict=False ):
- # If restrict is True, we'll return only those templates directly associated with this LibraryDatasetDatasetAssociation
- # We only want the next available template in the inheritable hierarchy, so we'll only extend
- # template_list if it is empty
- if not template_list and self.library_dataset_dataset_info_template_associations:
- template_list.extend( [ lddita.library_item_info_template for lddita in self.library_dataset_dataset_info_template_associations if lddita.library_item_info_template not in template_list ] )
- if not template_list:
- self.library_dataset.get_library_item_info_templates( template_list, restrict )
- return template_list
-
-class LibraryInfoTemplateAssociation( object ):
- pass
-
-class LibraryFolderInfoTemplateAssociation( object ):
- pass
-
-class LibraryDatasetInfoTemplateAssociation( object ):
- pass
-
-class LibraryDatasetDatasetInfoTemplateAssociation( object ):
- pass
-
-class LibraryItemInfoTemplate( object ):
- def add_element( self, element = None, name = None, description = None ):
- if element:
- raise "undefined"
- else:
- new_elem = LibraryItemInfoTemplateElement()
- new_elem.name = name
- new_elem.description = description
- new_elem.order_id = self.item_count
- self.item_count += 1
- self.flush()
- new_elem.library_item_info_template_id = self.id
- new_elem.flush()
- return new_elem
-
-class LibraryItemInfoTemplateElement( object ):
- pass
+ def get_info_association( self, restrict=False ):
+ # If restrict is True, we will return this ldda's info_association whether it
+ # exists or not. If restrict is False, we'll return the next available info_association
+ # in the inheritable hierarchy
+ if self.info_association:
+ return self.info_association[0]
+ if restrict:
+ return None
+ return self.library_dataset.folder.get_info_association()
class LibraryInfoAssociation( object ):
- def __init__( self, user=None ):
- self.user = user
- def set_library_item( self, library_item ):
- if isinstance( library_item, Library ):
- self.library = library_item
- else:
- raise "Invalid Library specified: %s" % library_item.__class__.__name__
+ def __init__( self, library, form_definition, info ):
+ self.library = library
+ self.template = form_definition
+ self.info = info
class LibraryFolderInfoAssociation( object ):
- def __init__( self, user=None ):
- self.user = user
- def set_library_item( self, library_item ):
- if isinstance( library_item, LibraryFolder ):
- self.folder = library_item
- else:
- raise "Invalid Library specified: %s" % library_item.__class__.__name__
-
-class LibraryDatasetInfoAssociation( object ):
- def __init__( self, user=None ):
- self.user = user
- def set_library_item( self, library_item ):
- if isinstance( library_item, LibraryDataset ):
- self.library_dataset = library_item
- else:
- raise "Invalid Library specified: %s" % library_item.__class__.__name__
+ def __init__( self, folder, form_definition, info ):
+ self.folder = folder
+ self.template = form_definition
+ self.info = info
class LibraryDatasetDatasetInfoAssociation( object ):
- def __init__( self, user=None ):
- self.user = user
- def set_library_item( self, library_item ):
- if isinstance( library_item, LibraryDatasetDatasetAssociation ):
- self.library_dataset_dataset_association = library_item
- else:
- raise "Invalid Library specified: %s" % library_item.__class__.__name__
+ def __init__( self, library_dataset_dataset_association, form_definition, info ):
+ self.library_dataset_dataset_association = library_dataset_dataset_association
+ self.template = form_definition
+ self.info = info
-class LibraryItemInfo( object ):
- def __init__( self, user=None ):
- self.user = user
- def get_element_by_template_element( self, template_element, create_element=False ):
- for element in self.elements:
- if element.library_item_info_template_element == template_element:
- return element
- if create_element:
- # Template elements may have been added to the template after the
- # library item initially inherited it, so we'll add the additional
- # element to the library item
- element = LibraryItemInfoElement()
- element.library_item_info_template_element = template_element
- element.library_item_info = self
- element.flush()
- self.elements.append( element )
- return element
- else:
- return None
-
-class LibraryItemInfoElement( object ):
- pass
-
class ValidationError( object ):
def __init__( self, message=None, err_type=None, attributes=None ):
self.message = message
@@ -1102,8 +997,7 @@
raise
# Return filename inside hashed directory
return os.path.abspath( os.path.join( path, "metadata_%d.dat" % self.id ) )
-
-
+
class FormDefinition( object ):
def __init__(self, name=None, desc=None, fields=[], current_form=None):
self.name = name
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/mapping.py
--- a/lib/galaxy/model/mapping.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/mapping.py Fri Aug 07 16:11:14 2009 -0400
@@ -216,22 +216,6 @@
Column( "library_dataset_dataset_association_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), nullable=True, index=True ),
Column( "role_id", Integer, ForeignKey( "role.id" ), index=True ) )
-LibraryItemInfoPermissions.table = Table( "library_item_info_permissions", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "action", TEXT ),
- Column( "library_item_info_id", Integer, ForeignKey( "library_item_info.id" ), nullable=True, index=True ),
- Column( "role_id", Integer, ForeignKey( "role.id" ), index=True ) )
-
-LibraryItemInfoTemplatePermissions.table = Table( "library_item_info_template_permissions", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "action", TEXT ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), nullable=True, index=True ),
- Column( "role_id", Integer, ForeignKey( "role.id" ), index=True ) )
-
DefaultUserPermissions.table = Table( "default_user_permissions", metadata,
Column( "id", Integer, primary_key=True ),
Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
@@ -299,105 +283,23 @@
Column( "purged", Boolean, index=True, default=False ),
Column( "genome_build", TrimmedString( 40 ) ) )
-LibraryItemInfoTemplateElement.table = Table( "library_item_info_template_element", metadata,
+LibraryInfoAssociation.table = Table( 'library_info_association', metadata,
Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "optional", Boolean, index=True, default=True ),
- Column( "deleted", Boolean, index=True, default=False ),
- Column( "name", TEXT ),
- Column( "description", TEXT ),
- Column( "type", TEXT, default='string' ),
- Column( "order_id", Integer ),
- Column( "options", JSONType() ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), index=True ) )
-
-LibraryItemInfoTemplate.table = Table( "library_item_info_template", metadata,
+ Column( "library_id", Integer, ForeignKey( "library.id" ), index=True ),
+ Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )
+
+LibraryFolderInfoAssociation.table = Table( 'library_folder_info_association', metadata,
Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "optional", Boolean, index=True, default=True ),
- Column( "deleted", Boolean, index=True, default=False ),
- Column( "name", TEXT ),
- Column( "description", TEXT ),
- Column( "item_count", Integer, default=0 ) )
+ Column( "library_folder_id", Integer, ForeignKey( "library_folder.id" ), nullable=True, index=True ),
+ Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )
-LibraryInfoTemplateAssociation.table = Table( "library_info_template_association", metadata,
+LibraryDatasetDatasetInfoAssociation.table = Table( 'library_dataset_dataset_info_association', metadata,
Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_id", Integer, ForeignKey( "library.id" ), nullable=True, index=True ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), index=True ) )
-
-LibraryFolderInfoTemplateAssociation.table = Table( "library_folder_info_template_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_folder_id", Integer, ForeignKey( "library_folder.id" ), nullable=True, index=True ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), index=True ) )
-
-LibraryDatasetInfoTemplateAssociation.table = Table( "library_dataset_info_template_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_dataset_id", Integer, ForeignKey( "library_dataset.id" ), nullable=True, index=True ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), index=True ) )
-
-LibraryDatasetDatasetInfoTemplateAssociation.table = Table( "library_dataset_dataset_info_template_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
Column( "library_dataset_dataset_association_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), nullable=True, index=True ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), index=True ) )
-
-LibraryItemInfoElement.table = Table( "library_item_info_element", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "contents", JSONType() ),
- Column( "library_item_info_id", Integer, ForeignKey( "library_item_info.id" ), index=True ),
- Column( "library_item_info_template_element_id", Integer, ForeignKey( "library_item_info_template_element.id" ), index=True ) )
-
-LibraryItemInfo.table = Table( "library_item_info", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "deleted", Boolean, index=True, default=False ),
- Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), nullable=True, index=True ),
- Column( "library_item_info_template_id", Integer, ForeignKey( "library_item_info_template.id" ), nullable=True, index=True )
- )
-
-LibraryInfoAssociation.table = Table( "library_info_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_id", Integer, ForeignKey( "library.id" ), nullable=True, index=True ),
- Column( "library_item_info_id", Integer, ForeignKey( "library_item_info.id" ), index=True ),
- Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), nullable=True, index=True ) )
-
-LibraryFolderInfoAssociation.table = Table( "library_folder_info_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_folder_id", Integer, ForeignKey( "library_folder.id" ), nullable=True, index=True ),
- Column( "library_item_info_id", Integer, ForeignKey( "library_item_info.id" ), index=True ),
- Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), nullable=True, index=True ) )
-
-LibraryDatasetInfoAssociation.table = Table( "library_dataset_info_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_dataset_id", Integer, ForeignKey( "library_dataset.id" ), nullable=True, index=True ),
- Column( "library_item_info_id", Integer, ForeignKey( "library_item_info.id" ), index=True ),
- Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), nullable=True, index=True ) )
-
-LibraryDatasetDatasetInfoAssociation.table = Table( "library_dataset_dataset_info_association", metadata,
- Column( "id", Integer, primary_key=True ),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "library_dataset_dataset_association_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), nullable=True, index=True ),
- Column( "library_item_info_id", Integer, ForeignKey( "library_item_info.id" ), index=True ),
- Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), nullable=True, index=True ) )
+ Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )
Job.table = Table( "job", metadata,
Column( "id", Integer, primary_key=True ),
@@ -545,7 +447,6 @@
Column( "deleted", Boolean, index=True, default=False ),
Column( "purged", Boolean, index=True, default=False ) )
-
FormDefinitionCurrent.table = Table('form_definition_current', metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
@@ -553,20 +454,17 @@
Column( "latest_form_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
Column( "deleted", Boolean, index=True, default=False ))
-# new table to store all the forms which is created by the admin
FormDefinition.table = Table('form_definition', metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
Column( "update_time", DateTime, default=now, onupdate=now ),
Column( "name", TrimmedString( 255 ), nullable=False ),
Column( "desc", TEXT ),
- Column( "form_definition_current_id",
+ Column( "form_definition_current_id",
Integer,
- ForeignKey( "form_definition_current.id",
- name='for_def_form_def_current_id_fk',
- use_alter=True),
+ ForeignKey( "form_definition_current.id", name='for_def_form_def_current_id_fk', use_alter=True ),
index=True ),
- Column( "fields", JSONType()))
+ Column( "fields", JSONType() ) )
RequestType.table = Table('request_type', metadata,
Column( "id", Integer, primary_key=True),
@@ -599,7 +497,7 @@
Column( "deleted", Boolean, index=True, default=False ) )
Sample.table = Table('sample', metadata,
- Column( "id", Integer, primary_key=True),
+ Column( "id", Integer, primary_key=True ),
Column( "create_time", DateTime, default=now ),
Column( "update_time", DateTime, default=now, onupdate=now ),
Column( "name", TrimmedString( 255 ), nullable=False ),
@@ -609,10 +507,8 @@
Column( "bar_code", TrimmedString( 255 ), index=True ),
Column( "deleted", Boolean, index=True, default=False ) )
-# new table to store all the possible sample states and the sample type it
-# belongs to
SampleState.table = Table('sample_state', metadata,
- Column( "id", Integer, primary_key=True),
+ Column( "id", Integer, primary_key=True ),
Column( "create_time", DateTime, default=now ),
Column( "update_time", DateTime, default=now, onupdate=now ),
Column( "name", TrimmedString( 255 ), nullable=False ),
@@ -620,14 +516,12 @@
Column( "request_type_id", Integer, ForeignKey( "request_type.id" ), index=True ) )
SampleEvent.table = Table('sample_event', metadata,
- Column( "id", Integer, primary_key=True),
+ 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( "sample_state_id", Integer, ForeignKey( "sample_state.id" ), index=True ),
Column( "comment", TEXT ) )
-
-
# With the tables defined we can define the mappers and setup the
# relationships between the model objects.
@@ -645,7 +539,8 @@
assign_mapper( context, FormValues, FormValues.table,
properties=dict( form_definition=relation( FormDefinition,
primaryjoin=( FormValues.table.c.form_definition_id == FormDefinition.table.c.id ) )
- ) )
+ )
+)
assign_mapper( context, Request, Request.table,
properties=dict( values=relation( FormValues,
@@ -856,25 +751,20 @@
)
)
-assign_mapper( context, LibraryItemInfoPermissions, LibraryItemInfoPermissions.table,
+assign_mapper( context, Library, Library.table,
properties=dict(
- library_item_info = relation( LibraryItemInfo, backref="actions" ),
- role=relation( Role, backref="library_item_info_actions" )
- )
+ root_folder=relation( LibraryFolder, backref=backref( "library_root" ) )
+ )
)
-assign_mapper( context, LibraryItemInfoTemplatePermissions, LibraryItemInfoTemplatePermissions.table,
- properties=dict(
- library_item_info_template = relation( LibraryItemInfoTemplate, backref="actions" ),
- role=relation( Role, backref="library_item_info_template_actions" )
- )
-)
-
-assign_mapper( context, Library, Library.table,
- properties=dict(
- root_folder=relation( LibraryFolder,
- backref=backref( "library_root" ) )
- ) )
+assign_mapper( context, LibraryInfoAssociation, LibraryInfoAssociation.table,
+ properties=dict( library=relation( Library,
+ primaryjoin=( LibraryInfoAssociation.table.c.library_id == Library.table.c.id ), backref="info_association" ),
+ template=relation( FormDefinition,
+ primaryjoin=( LibraryInfoAssociation.table.c.form_definition_id == FormDefinition.table.c.id ) ),
+ info=relation( FormValues,
+ primaryjoin=( LibraryInfoAssociation.table.c.form_values_id == FormValues.table.c.id ) )
+ ) )
assign_mapper( context, LibraryFolder, LibraryFolder.table,
properties=dict(
@@ -893,6 +783,15 @@
lazy=False,
viewonly=True )
) )
+
+assign_mapper( context, LibraryFolderInfoAssociation, LibraryFolderInfoAssociation.table,
+ properties=dict( folder=relation( LibraryFolder,
+ primaryjoin=( LibraryFolderInfoAssociation.table.c.library_folder_id == LibraryFolder.table.c.id ), backref="info_association" ),
+ template=relation( FormDefinition,
+ primaryjoin=( LibraryFolderInfoAssociation.table.c.form_definition_id == FormDefinition.table.c.id ) ),
+ info=relation( FormValues,
+ primaryjoin=( LibraryFolderInfoAssociation.table.c.form_values_id == FormValues.table.c.id ) )
+ ) )
assign_mapper( context, LibraryDataset, LibraryDataset.table,
properties=dict(
@@ -924,65 +823,14 @@
primaryjoin=( ( LibraryDatasetDatasetAssociation.table.c.parent_id == LibraryDatasetDatasetAssociation.table.c.id ) & ( LibraryDatasetDatasetAssociation.table.c.visible == True ) ) )
) )
-assign_mapper( context, LibraryItemInfoTemplateElement, LibraryItemInfoTemplateElement.table,
- properties=dict( library_item_info_template=relation( LibraryItemInfoTemplate, backref="elements" ),
- ) )
-
-assign_mapper( context, LibraryItemInfoTemplate, LibraryItemInfoTemplate.table )
-
-assign_mapper( context, LibraryInfoTemplateAssociation, LibraryInfoTemplateAssociation.table,
- properties=dict( library=relation( Library, backref="library_info_template_associations" ),
- library_item_info_template = relation( LibraryItemInfoTemplate, backref="library_info_template_associations" ),
- ) )
-
-assign_mapper( context, LibraryFolderInfoTemplateAssociation, LibraryFolderInfoTemplateAssociation.table,
- properties=dict( folder=relation( LibraryFolder, backref="library_folder_info_template_associations" ),
- library_item_info_template = relation( LibraryItemInfoTemplate, backref="library_folder_info_template_associations" ),
- ) )
-
-assign_mapper( context, LibraryDatasetInfoTemplateAssociation, LibraryDatasetInfoTemplateAssociation.table,
- properties=dict( library_dataset=relation( LibraryDataset, backref="library_dataset_info_template_associations" ),
- library_item_info_template = relation( LibraryItemInfoTemplate, backref="library_dataset_info_template_associations" ),
- ) )
-
-assign_mapper( context, LibraryDatasetDatasetInfoTemplateAssociation, LibraryDatasetDatasetInfoTemplateAssociation.table,
- properties=dict( library_dataset_dataset_association = relation( LibraryDatasetDatasetAssociation, backref="library_dataset_dataset_info_template_associations" ),
- library_item_info_template = relation( LibraryItemInfoTemplate, backref="library_dataset_dataset_info_template_associations" ),
- ) )
-
-assign_mapper( context, LibraryItemInfoElement, LibraryItemInfoElement.table,
- properties=dict( library_item_info=relation( LibraryItemInfo, backref="elements" ),
- library_item_info_template_element=relation( LibraryItemInfoTemplateElement )
- ) )
-
-assign_mapper( context, LibraryItemInfo, LibraryItemInfo.table,
- properties=dict( library_item_info_template=relation( LibraryItemInfoTemplate, backref="library_item_infos" ),
- user=relation( User.mapper )
- ) )
-
-assign_mapper( context, LibraryInfoAssociation, LibraryInfoAssociation.table,
- properties=dict( library=relation( Library, backref="library_info_associations" ),
- library_item_info = relation( LibraryItemInfo, backref="library_info_associations" ),
- user=relation( User.mapper )
- ) )
-
-assign_mapper( context, LibraryFolderInfoAssociation, LibraryFolderInfoAssociation.table,
- properties=dict( folder=relation( LibraryFolder, backref="library_folder_info_associations" ),
- library_item_info = relation( LibraryItemInfo, backref="library_folder_info_associations" ),
- user=relation( User.mapper )
- ) )
-
-assign_mapper( context, LibraryDatasetInfoAssociation, LibraryDatasetInfoAssociation.table,
- properties=dict( library_dataset=relation( LibraryDataset, backref="library_dataset_info_associations" ),
- library_item_info = relation( LibraryItemInfo, backref="library_dataset_info_associations" ),
- user=relation( User.mapper )
- ) )
-
assign_mapper( context, LibraryDatasetDatasetInfoAssociation, LibraryDatasetDatasetInfoAssociation.table,
- properties=dict( library_dataset_dataset_association = relation( LibraryDatasetDatasetAssociation, backref="library_dataset_dataset_info_associations" ),
- library_item_info = relation( LibraryItemInfo, backref="library_dataset_dataset_info_associations" ),
- user=relation( User.mapper )
- ) )
+ properties=dict( library_dataset_dataset_association=relation( LibraryDatasetDatasetAssociation,
+ primaryjoin=( LibraryDatasetDatasetInfoAssociation.table.c.library_dataset_dataset_association_id == LibraryDatasetDatasetAssociation.table.c.id ), backref="info_association" ),
+ template=relation( FormDefinition,
+ primaryjoin=( LibraryDatasetDatasetInfoAssociation.table.c.form_definition_id == FormDefinition.table.c.id ) ),
+ info=relation( FormValues,
+ primaryjoin=( LibraryDatasetDatasetInfoAssociation.table.c.form_values_id == FormValues.table.c.id ) )
+ ) )
assign_mapper( context, JobToInputDatasetAssociation, JobToInputDatasetAssociation.table,
properties=dict( job=relation( Job ), dataset=relation( HistoryDatasetAssociation, lazy=False ) ) )
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0006_change_qual_datatype.py
--- a/lib/galaxy/model/migrate/versions/0006_change_qual_datatype.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0006_change_qual_datatype.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,3 +1,7 @@
+"""
+This migration script changes certain values in the history_dataset_association.extension
+column, specifically 'qual' is chaged to be 'qual454'.
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from migrate import *
@@ -13,9 +17,17 @@
metadata = MetaData( migrate_engine )
db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) )
+
+def display_migration_details():
+ print "========================================"
+ print "This migration script changes certain values in the history_dataset_association.extension"
+ print "column, specifically 'qual' is chaged to be 'qual454'."
+ print "========================================"
+
HistoryDatasetAssociation_table = Table( "history_dataset_association", metadata, autoload=True )
-
+
def upgrade():
+ display_migration_details()
# Load existing tables
metadata.reflect()
# Add 2 indexes to the galaxy_user table
@@ -42,6 +54,5 @@
except Exception, e:
log.debug( "Dropping index 'ix_hda_extension' to history_dataset_association table failed: %s" % ( str( e ) ) )
-
def downgrade():
pass
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0007_sharing_histories.py
--- a/lib/galaxy/model/migrate/versions/0007_sharing_histories.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0007_sharing_histories.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,3 +1,8 @@
+"""
+This migration script creates the new history_user_share_association table, and adds
+a new boolean type column to the history table. This provides support for sharing
+histories in the same way that workflows are shared.
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from migrate import *
@@ -14,6 +19,13 @@
metadata = MetaData( migrate_engine )
+def display_migration_details():
+ print "========================================"
+ print "This migration script creates the new history_user_share_association table, and adds"
+ print "a new boolean type column to the history table. This provides support for sharing"
+ print "histories in the same way that workflows are shared."
+ print "========================================"
+
HistoryUserShareAssociation_table = Table( "history_user_share_association", metadata,
Column( "id", Integer, primary_key=True ),
Column( "history_id", Integer, ForeignKey( "history.id" ), index=True ),
@@ -21,6 +33,7 @@
)
def upgrade():
+ display_migration_details()
# Load existing tables
metadata.reflect()
# Create the history_user_share_association table
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0008_galaxy_forms.py
--- a/lib/galaxy/model/migrate/versions/0008_galaxy_forms.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0008_galaxy_forms.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,3 +1,14 @@
+"""
+This migration script adds the following new tables for supporting Galaxy forms:
+1) form_definition_current
+2) form_definition
+3) form_values
+4) request_type
+5) request
+6) sample
+7) sample_state
+8) sample_event
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.exceptions import *
@@ -22,15 +33,26 @@
metadata = MetaData( migrate_engine )
db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) )
+def display_migration_details():
+ print "========================================"
+ print "This migration script adds the following new tables for supporting Galaxy forms:"
+ print "1) form_definition_current"
+ print "2) form_definition"
+ print "3) form_values"
+ print "4) request_type"
+ print "5) request"
+ print "6) sample"
+ print "7) sample_state"
+ print "8) sample_event"
+ print "========================================"
FormDefinitionCurrent_table = Table('form_definition_current', metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "latest_form_id", Integer,
- #ForeignKey( "form_definition.id", use_alter=True, name='form_definition_current_latest_form_id_fk'),
- index=True ),
+ Column( "latest_form_id", Integer, index=True ),
Column( "deleted", Boolean, index=True, default=False ))
+
FormDefinition_table = Table('form_definition', metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
@@ -55,7 +77,7 @@
Column( "desc", TEXT ),
Column( "request_form_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
Column( "sample_form_id", Integer, ForeignKey( "form_definition.id" ), index=True ) )
-# request table
+
Request_table = Table('request', metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
@@ -94,13 +116,10 @@
Column( "sample_state_id", Integer, ForeignKey( "sample_state.id" ), index=True ),
Column( "comment", TEXT ) )
-
-
-
def upgrade():
+ display_migration_details()
# Load existing tables
metadata.reflect()
-
# Add all of the new tables above
# metadata.create_all()
try:
@@ -145,8 +164,6 @@
SampleEvent_table.create()
except Exception, e:
log.debug( "Creating sample_event table failed: %s" % str( e ) )
-
-
def downgrade():
# Load existing tables
@@ -183,7 +200,3 @@
SampleEvent_table.drop()
except Exception, e:
log.debug( "Dropping sample_event table failed: %s" % str( e ) )
-
-
-
-
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0009_request_table.py
--- a/lib/galaxy/model/migrate/versions/0009_request_table.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0009_request_table.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,3 +1,8 @@
+"""
+This migration script adds a new column to 2 tables:
+1) a new boolean type column named 'submitted' to the 'request' table
+2) a new string type column named 'bar_code' to the 'sample' table
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from migrate import *
@@ -15,11 +20,17 @@
metadata = MetaData( migrate_engine )
+def display_migration_details():
+ print "========================================"
+ print "This migration script adds a new column to 2 tables:"
+ print "1) a new boolean type column named 'submitted' to the 'request' table"
+ print "2) a new string type column named 'bar_code' to the 'sample' table"
+ print "========================================"
def upgrade():
+ display_migration_details()
# Load existing tables
metadata.reflect()
-
# Add 1 column to the request table
try:
Request_table = Table( "request", metadata, autoload=True )
@@ -33,7 +44,6 @@
assert col is Request_table.c.submitted
except Exception, e:
log.debug( "Adding column 'submitted' to request table failed: %s" % ( str( e ) ) )
-
# Add 1 column to the sample table
try:
Sample_table = Table( "sample", metadata, autoload=True )
@@ -49,4 +59,4 @@
log.debug( "Adding column 'bar_code' to sample table failed: %s" % ( str( e ) ) )
def downgrade():
- pass
\ No newline at end of file
+ pass
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0010_hda_display_at_authz_table.py
--- a/lib/galaxy/model/migrate/versions/0010_hda_display_at_authz_table.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0010_hda_display_at_authz_table.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,3 +1,13 @@
+"""
+This migration script adds the history_dataset_association_display_at_authorization table,
+which allows 'private' datasets to be displayed at external sites without making them public.
+If using mysql, this script will display the following error, which is corrected in the next
+migration script:
+
+history_dataset_association_display_at_authorization table failed: (OperationalError)
+(1059, "Identifier name 'ix_history_dataset_association_display_at_authorization_update_time'
+is too long
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.exceptions import *
@@ -22,6 +32,17 @@
metadata = MetaData( migrate_engine )
db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) )
+def display_migration_details():
+ print "========================================"
+ print "This migration script adds the history_dataset_association_display_at_authorization table, which"
+ print "allows 'private' datasets to be displayed at external sites without making them public."
+ print ""
+ print "If using mysql, this script will display the following error, which is corrected in the next migration"
+ print "script: history_dataset_association_display_at_authorization table failed: (OperationalError)"
+ print "(1059, 'Identifier name 'ix_history_dataset_association_display_at_authorization_update_time'"
+ print "is too long."
+ print "========================================"
+
HistoryDatasetAssociationDisplayAtAuthorization_table = Table( "history_dataset_association_display_at_authorization", metadata,
Column( "id", Integer, primary_key=True ),
Column( "create_time", DateTime, default=now ),
@@ -31,13 +52,14 @@
Column( "site", TrimmedString( 255 ) ) )
def upgrade():
+ display_migration_details()
# Load existing tables
metadata.reflect()
try:
HistoryDatasetAssociationDisplayAtAuthorization_table.create()
except Exception, e:
log.debug( "Creating history_dataset_association_display_at_authorization table failed: %s" % str( e ) )
-
+
def downgrade():
# Load existing tables
metadata.reflect()
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0011_v0010_mysql_index_fix.py
--- a/lib/galaxy/model/migrate/versions/0011_v0010_mysql_index_fix.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0011_v0010_mysql_index_fix.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,3 +1,8 @@
+"""
+This script fixes a problem introduced in 0010_hda_display_at_atuhz_table.py. MySQL has a
+name length limit and thus the index "ix_hdadaa_history_dataset_association_id" has to be
+manually created.
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.exceptions import *
@@ -22,6 +27,13 @@
metadata = MetaData( migrate_engine )
db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) )
+def display_migration_details():
+ print "========================================"
+ print "This script fixes a problem introduced in the previous migration script ( 9->10 ). MySQL"
+ print "has a name length limit and thus the index 'ix_hdadaa_history_dataset_association_id' has"
+ print "to be manually created."
+ print "========================================"
+
HistoryDatasetAssociationDisplayAtAuthorization_table = Table( "history_dataset_association_display_at_authorization", metadata,
Column( "id", Integer, primary_key=True ),
Column( "create_time", DateTime, default=now ),
@@ -31,6 +43,7 @@
Column( "site", TrimmedString( 255 ) ) )
def upgrade():
+ display_migration_details()
if migrate_engine.name == 'mysql':
# Load existing tables
metadata.reflect()
@@ -39,7 +52,7 @@
i.create()
except Exception, e:
log.debug( "Adding index 'ix_hdadaa_history_dataset_association_id' to table 'history_dataset_association_display_at_authorization' table failed: %s" % str( e ) )
-
+
def downgrade():
if migrate_engine.name == 'mysql':
# Load existing tables
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0012_user_address.py
--- a/lib/galaxy/model/migrate/versions/0012_user_address.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0012_user_address.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,13 +1,20 @@
+"""
+This script adds a new user_address table that is currently only used with sample requests, where
+a user can select from a list of his addresses to associate with the request. This script also
+drops the request.submitted column which was boolean and replaces it with a request.state column
+which is a string, allowing for more flexibility with request states.
+"""
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.exceptions import *
from migrate import *
from migrate.changeset import *
-
import datetime
now = datetime.datetime.utcnow
+import sys, logging
+# Need our custom types, but don't import anything else from model
+from galaxy.model.custom_types import *
-import sys, logging
log = logging.getLogger( __name__ )
log.setLevel(logging.DEBUG)
handler = logging.StreamHandler( sys.stdout )
@@ -16,12 +23,16 @@
handler.setFormatter( formatter )
log.addHandler( handler )
-# Need our custom types, but don't import anything else from model
-from galaxy.model.custom_types import *
-
metadata = MetaData( migrate_engine )
db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) )
+def display_migration_details():
+ print "========================================"
+ print "This script adds a new user_address table that is currently only used with sample requests, where"
+ print "a user can select from a list of his addresses to associate with the request. This script also"
+ print "drops the request.submitted column which was boolean and replaces it with a request.state column"
+ print "which is a string, allowing for more flexibility with request states."
+ print "========================================"
UserAddress_table = Table( "user_address", metadata,
Column( "id", Integer, primary_key=True),
@@ -41,15 +52,14 @@
Column( "purged", Boolean, index=True, default=False ) )
def upgrade():
+ display_migration_details()
# Load existing tables
metadata.reflect()
-
# Add all of the new tables above
try:
UserAddress_table.create()
except Exception, e:
log.debug( "Creating user_address table failed: %s" % str( e ) )
-
# Add 1 column to the request_type table
try:
RequestType_table = Table( "request_type", metadata, autoload=True )
@@ -63,7 +73,6 @@
assert col is RequestType_table.c.deleted
except Exception, e:
log.debug( "Adding column 'deleted' to request_type table failed: %s" % ( str( e ) ) )
-
# Delete the submitted column
try:
Request_table = Table( "request", metadata, autoload=True )
@@ -82,8 +91,5 @@
except Exception, e:
log.debug( "Adding column 'state' to request table failed: %s" % ( str( e ) ) )
-
def downgrade():
pass
-
-
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/model/migrate/versions/0013_change_lib_item_templates_to_forms.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/galaxy/model/migrate/versions/0013_change_lib_item_templates_to_forms.py Fri Aug 07 16:11:14 2009 -0400
@@ -0,0 +1,255 @@
+"""
+This migration script eliminates all of the tables that were used for the 1st version of the
+library templates where template fields and contents were each stored as a separate table row
+in various library item tables. All of these tables are dropped in this script, eliminating all
+existing template data. A total of 14 existing tables are dropped.
+
+We're now basing library templates on forms, so field contents are
+stored as a jsonified list in the form_values table. This script introduces the following 3
+new association tables:
+1) library_info_association
+2) library_folder_info_association
+3) library_dataset_dataset_info_association
+
+If using mysql, this script will throw an (OperationalError) exception due to a long index name on
+the library_dataset_dataset_info_association table, which is OK because the script creates an index
+with a shortened name.
+"""
+from sqlalchemy import *
+from sqlalchemy.orm import *
+from sqlalchemy.exceptions import *
+from migrate import *
+from migrate.changeset import *
+import sys, logging
+
+log = logging.getLogger( __name__ )
+log.setLevel(logging.DEBUG)
+handler = logging.StreamHandler( sys.stdout )
+format = "%(name)s %(levelname)s %(asctime)s %(message)s"
+formatter = logging.Formatter( format )
+handler.setFormatter( formatter )
+log.addHandler( handler )
+
+metadata = MetaData( migrate_engine )
+
+def display_migration_details():
+ print "========================================"
+ print "This migration script eliminates all of the tables that were used for the 1st version of the"
+ print "library templates where template fields and contents were each stored as a separate table row"
+ print "in various library item tables. All of these tables are dropped in this script, eliminating all"
+ print "existing template data. A total of 14 existing tables are dropped."
+ print ""
+ print "We're now basing library templates on Galaxy forms, so field contents are stored as a jsonified"
+ print "list in the form_values table. This script introduces the following 3 new association tables:"
+ print "1) library_info_association"
+ print "2) library_folder_info_association"
+ print "3) library_dataset_dataset_info_association"
+ print ""
+ print "If using mysql, this script will throw an (OperationalError) exception due to a long index name"
+ print "on the library_dataset_dataset_info_association table, which is OK because the script creates"
+ print "an index with a shortened name."
+ print "========================================"
+
+if migrate_engine.name == 'postgres':
+ # http://blog.pythonisito.com/2008/01/cascading-drop-table-with-sqlalchemy.ht…
+ from sqlalchemy.databases import postgres
+ class PGCascadeSchemaDropper(postgres.PGSchemaDropper):
+ def visit_table(self, table):
+ for column in table.columns:
+ if column.default is not None:
+ self.traverse_single(column.default)
+ self.append("\nDROP TABLE " +
+ self.preparer.format_table(table) +
+ " CASCADE")
+ self.execute()
+ postgres.dialect.schemadropper = PGCascadeSchemaDropper
+
+LibraryInfoAssociation_table = Table( 'library_info_association', metadata,
+ Column( "id", Integer, primary_key=True),
+ Column( "library_id", Integer, ForeignKey( "library.id" ), index=True ),
+ Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )
+
+LibraryFolderInfoAssociation_table = Table( 'library_folder_info_association', metadata,
+ Column( "id", Integer, primary_key=True),
+ Column( "library_folder_id", Integer, ForeignKey( "library_folder.id" ), nullable=True, index=True ),
+ Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )
+
+LibraryDatasetDatasetInfoAssociation_table = Table( 'library_dataset_dataset_info_association', metadata,
+ Column( "id", Integer, primary_key=True),
+ Column( "library_dataset_dataset_association_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), nullable=True, index=True ),
+ Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )
+
+def upgrade():
+ display_migration_details()
+ # Load existing tables
+ metadata.reflect()
+ # Drop all of the original library_item_info tables
+ # NOTE: all existing library item into template data is eliminated here via table drops
+ try:
+ LibraryItemInfoPermissions_table = Table( "library_item_info_permissions", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryItemInfoPermissions_table = None
+ log.debug( "Failed loading table library_item_info_permissions" )
+ try:
+ LibraryItemInfoPermissions_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_item_info_permissions table failed: %s" % str( e ) )
+
+ try:
+ LibraryItemInfoTemplatePermissions_table = Table( "library_item_info_template_permissions", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryItemInfoTemplatePermissions_table = None
+ log.debug( "Failed loading table library_item_info_template_permissions" )
+ try:
+ LibraryItemInfoTemplatePermissions_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_item_info_template_permissions table failed: %s" % str( e ) )
+
+ try:
+ LibraryItemInfoElement_table = Table( "library_item_info_element", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryItemInfoElement_table = None
+ log.debug( "Failed loading table library_item_info_element" )
+ try:
+ LibraryItemInfoElement_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_item_info_element table failed: %s" % str( e ) )
+
+ try:
+ LibraryItemInfoTemplateElement_table = Table( "library_item_info_template_element", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryItemInfoTemplateElement_table = None
+ log.debug( "Failed loading table library_item_info_template_element" )
+ try:
+ LibraryItemInfoTemplateElement_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_item_info_template_element table failed: %s" % str( e ) )
+
+ try:
+ LibraryInfoTemplateAssociation_table = Table( "library_info_template_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryInfoTemplateAssociation_table = None
+ log.debug( "Failed loading table library_info_template_association" )
+ try:
+ LibraryInfoTemplateAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_info_template_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryFolderInfoTemplateAssociation_table = Table( "library_folder_info_template_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryFolderInfoTemplateAssociation_table = None
+ log.debug( "Failed loading table library_folder_info_template_association" )
+ try:
+ LibraryFolderInfoTemplateAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_folder_info_template_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryDatasetInfoTemplateAssociation_table = Table( "library_dataset_info_template_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryDatasetInfoTemplateAssociation_table = None
+ log.debug( "Failed loading table library_dataset_info_template_association" )
+ try:
+ LibraryDatasetInfoTemplateAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_dataset_info_template_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryDatasetDatasetInfoTemplateAssociation_table = Table( "library_dataset_dataset_info_template_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryDatasetDatasetInfoTemplateAssociation_table = None
+ log.debug( "Failed loading table library_dataset_dataset_info_template_association" )
+ try:
+ LibraryDatasetDatasetInfoTemplateAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_dataset_dataset_info_template_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryInfoAssociation_table = Table( "library_info_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryInfoAssociation_table = None
+ log.debug( "Failed loading table library_info_association" )
+ try:
+ LibraryInfoAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_info_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryFolderInfoAssociation_table = Table( "library_folder_info_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryFolderInfoAssociation_table = None
+ log.debug( "Failed loading table library_folder_info_association" )
+ try:
+ LibraryFolderInfoAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_folder_info_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryDatasetInfoAssociation_table = Table( "library_dataset_info_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryDatasetInfoAssociation_table = None
+ log.debug( "Failed loading table library_dataset_info_association" )
+ try:
+ LibraryDatasetInfoAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_dataset_info_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryDatasetDatasetInfoAssociation_table = Table( "library_dataset_dataset_info_association", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryDatasetDatasetInfoAssociation_table = None
+ log.debug( "Failed loading table library_dataset_dataset_info_association" )
+ try:
+ LibraryDatasetDatasetInfoAssociation_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_dataset_dataset_info_association table failed: %s" % str( e ) )
+
+ try:
+ LibraryItemInfo_table = Table( "library_item_info", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryItemInfo_table = None
+ log.debug( "Failed loading table library_item_info" )
+ try:
+ LibraryItemInfo_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_item_info table failed: %s" % str( e ) )
+
+ try:
+ LibraryItemInfoTemplate_table = Table( "library_item_info_template", metadata, autoload=True )
+ except NoSuchTableError:
+ LibraryItemInfoTemplate_table = None
+ log.debug( "Failed loading table library_item_info_template" )
+ try:
+ LibraryItemInfoTemplate_table.drop()
+ except Exception, e:
+ log.debug( "Dropping library_item_info_template table failed: %s" % str( e ) )
+
+ # Create all new tables above
+ try:
+ LibraryInfoAssociation_table.create()
+ except Exception, e:
+ log.debug( "Creating library_info_association table failed: %s" % str( e ) )
+ try:
+ LibraryFolderInfoAssociation_table.create()
+ except Exception, e:
+ log.debug( "Creating library_folder_info_association table failed: %s" % str( e ) )
+ try:
+ LibraryDatasetDatasetInfoAssociation_table.create()
+ except Exception, e:
+ log.debug( "Creating library_dataset_dataset_info_association table failed: %s" % str( e ) )
+ # Fix index on LibraryDatasetDatasetInfoAssociation_table for mysql
+ if migrate_engine.name == 'mysql':
+ # Load existing tables
+ metadata.reflect()
+ i = Index( "ix_lddaia_ldda_id", LibraryDatasetDatasetInfoAssociation_table.c.library_dataset_dataset_association_id )
+ try:
+ i.create()
+ except Exception, e:
+ log.debug( "Adding index 'ix_lddaia_ldda_id' to table 'library_dataset_dataset_info_association' table failed: %s" % str( e ) )
+
+def downgrade():
+ log.debug( "Downgrade is not possible." )
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/security/__init__.py
--- a/lib/galaxy/security/__init__.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/security/__init__.py Fri Aug 07 16:11:14 2009 -0400
@@ -75,12 +75,10 @@
self.permitted_actions = permitted_actions
# List of "library_item" objects and their associated permissions and info template objects
self.library_item_assocs = (
- ( self.model.Library, self.model.LibraryPermissions, self.model.LibraryInfoAssociation ),
- ( self.model.LibraryFolder, self.model.LibraryFolderPermissions, self.model.LibraryFolderInfoAssociation ),
- ( self.model.LibraryDataset, self.model.LibraryDatasetPermissions, self.model.LibraryDatasetInfoAssociation ),
- ( self.model.LibraryDatasetDatasetAssociation, self.model.LibraryDatasetDatasetAssociationPermissions, self.model.LibraryDatasetDatasetInfoAssociation ),
- ( self.model.LibraryItemInfo, self.model.LibraryItemInfoPermissions, None ),
- ( self.model.LibraryItemInfoTemplate, self.model.LibraryItemInfoTemplatePermissions, None ) )
+ ( self.model.Library, self.model.LibraryPermissions ),
+ ( self.model.LibraryFolder, self.model.LibraryFolderPermissions ),
+ ( self.model.LibraryDataset, self.model.LibraryDatasetPermissions ),
+ ( self.model.LibraryDatasetDatasetAssociation, self.model.LibraryDatasetDatasetAssociationPermissions ) )
def allow_action( self, user, action, **kwd ):
if 'dataset' in kwd:
return self.allow_dataset_action( user, action, kwd[ 'dataset' ] )
@@ -117,7 +115,7 @@
user_role_ids = [ r.id for r in user.all_roles() ]
# Check to see if user has access to any of the roles
allowed_role_assocs = []
- for item_class, permission_class, info_association_class in self.library_item_assocs:
+ for item_class, permission_class in self.library_item_assocs:
if isinstance( library_item, item_class ):
if permission_class == self.model.LibraryPermissions:
allowed_role_assocs = permission_class.filter_by( action=action.action, library_id=library_item.id ).all()
@@ -127,10 +125,6 @@
allowed_role_assocs = permission_class.filter_by( action=action.action, library_dataset_id=library_item.id ).all()
elif permission_class == self.model.LibraryDatasetDatasetAssociationPermissions:
allowed_role_assocs = permission_class.filter_by( action=action.action, library_dataset_dataset_association_id=library_item.id ).all()
- elif permission_class == self.model.LibraryItemInfoPermissions:
- allowed_role_assocs = permission_class.filter_by( action=action.action, library_item_info_id=library_item.id ).all()
- elif permission_class == self.model.LibraryItemInfoTemplatePermissions:
- allowed_role_assocs = permission_class.filter_by( action=action.action, library_item_info_template_id=library_item.id ).all()
for allowed_role_assoc in allowed_role_assocs:
if allowed_role_assoc.role_id in user_role_ids:
return True
@@ -366,7 +360,7 @@
role_assoc.delete()
role_assoc.flush()
# Add the new permissions on library_item
- for item_class, permission_class, info_association_class in self.library_item_assocs:
+ for item_class, permission_class in self.library_item_assocs:
if isinstance( library_item, item_class ):
for action, roles in permissions.items():
if isinstance( action, Action ):
@@ -396,12 +390,12 @@
permissions[role_assoc.action] = [ role_assoc.role ]
self.set_all_library_permissions( target_library_item, permissions )
if user:
- # The user passed will be the current Galaxy user. Make sure user's private role is included
item_class = None
- for item_class, permission_class, info_association_class in self.library_item_assocs:
+ for item_class, permission_class in self.library_item_assocs:
if isinstance( target_library_item, item_class ):
break
if item_class:
+ # Make sure user's private role is included
private_role = self.model.security_agent.get_private_user_role( user )
for name, action in self.permitted_actions.items():
if not permission_class.filter_by( role_id = private_role.id, action = action.action ).first():
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/web/controllers/admin.py
--- a/lib/galaxy/web/controllers/admin.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/web/controllers/admin.py Fri Aug 07 16:11:14 2009 -0400
@@ -1,9 +1,9 @@
-import shutil, StringIO, operator, urllib, gzip, tempfile, sets, string
+import shutil, StringIO, operator, urllib, gzip, tempfile, sets, string, sys
from datetime import datetime, timedelta
from galaxy import util, datatypes
from galaxy.web.base.controller import *
from galaxy.model.orm import *
-import sys
+from galaxy.web.controllers.forms import get_all_forms, get_form_widgets
import logging
log = logging.getLogger( __name__ )
@@ -710,6 +710,7 @@
library=trans.app.model.Library.get( id ),
deleted=deleted,
created_ldda_ids=created_ldda_ids,
+ forms=get_all_forms( trans ),
msg=msg,
messagetype=messagetype,
show_deleted=show_deleted )
@@ -751,6 +752,22 @@
messagetype='done' ) )
return trans.fill_template( '/admin/library/new_library.mako', msg=msg, messagetype=messagetype )
elif action == 'information':
+ # See if we have any associated templates
+ info_association = library.get_info_association()
+ if info_association:
+ template = info_association.template
+ # See if we have any field contents
+ info = info_association.info
+ if info:
+ field_contents = {}
+ for index, value in enumerate( info.content ):
+ key = 'field_%i' % index
+ field_contents[ key ] = value
+ widgets = get_form_widgets( trans, template, field_contents )
+ else:
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
if params.get( 'rename_library_button', False ):
old_name = library.name
new_name = util.restore_text( params.name )
@@ -759,8 +776,7 @@
msg = 'Enter a valid name'
return trans.fill_template( '/admin/library/library_info.mako',
library=library,
- restrict=params.get( 'restrict', False ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype='error' )
else:
@@ -780,12 +796,10 @@
messagetype='done' ) )
return trans.fill_template( '/admin/library/library_info.mako',
library=library,
- restrict=params.get( 'restrict', False ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif action == 'delete':
- # TODO: need to revamp the way we delete libraries, folders and contained LibraryDatasets.
def delete_folder( library_folder ):
library_folder.refresh()
for folder in library_folder.folders:
@@ -939,6 +953,22 @@
msg=msg,
messagetype=messagetype )
elif action == 'information':
+ # See if we have any associated templates
+ info_association = folder.get_info_association()
+ if info_association:
+ template = info_association.template
+ # See if we have any field contents
+ info = info_association.info
+ if info:
+ field_contents = {}
+ for index, value in enumerate( info.content ):
+ key = 'field_%i' % index
+ field_contents[ key ] = value
+ widgets = get_form_widgets( trans, template, field_contents )
+ else:
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
if params.get( 'rename_folder_button', False ):
old_name = folder.name
new_name = util.restore_text( params.name )
@@ -948,8 +978,7 @@
return trans.fill_template( '/admin/library/folder_info.mako',
folder=folder,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype='error' )
else:
@@ -967,12 +996,10 @@
return trans.fill_template( '/admin/library/folder_info.mako',
folder=folder,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif action == 'delete':
- # TODO: need to revamp the way we delete folders and contained LibraryDatasets
def delete_folder( folder ):
folder.refresh()
for subfolder in folder.active_folders:
@@ -1045,8 +1072,6 @@
return trans.fill_template( '/admin/library/library_dataset_info.mako',
library_dataset=library_dataset,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
msg=msg,
messagetype=messagetype )
elif action == 'permissions':
@@ -1101,7 +1126,7 @@
created_ldda_ids = trans.webapp.controllers[ 'library_dataset' ].upload_dataset( trans,
controller='admin',
library_id=library_id,
- folder_id=folder_id,
+ folder_id=folder_id,
replace_dataset=replace_dataset,
**kwd )
if created_ldda_ids:
@@ -1126,6 +1151,13 @@
msg=util.sanitize_text( msg ),
messagetype=messagetype ) )
elif not id or replace_dataset:
+ # See if we have any associated templates
+ info_association = folder.get_info_association()
+ if info_association:
+ template = info_association.template
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
upload_option = params.get( 'upload_option', 'upload_file' )
# No dataset(s) specified, so display the upload form. Send list of data formats to the form
# so the "extension" select list can be populated dynamically
@@ -1150,6 +1182,7 @@
last_used_build=last_used_build,
roles=roles,
history=history,
+ widgets=widgets,
msg=msg,
messagetype=messagetype,
replace_dataset=replace_dataset )
@@ -1175,6 +1208,23 @@
id=library_id,
msg=util.sanitize_text( msg ),
messagetype='error' ) )
+ # See if we have any associated templates
+ info_association = ldda.get_info_association()
+ if info_association:
+ template = info_association.template
+ # See if we have any field contents
+ info = info_association.info
+ log.debug("####In library_dataset_dataset_association, info.content: %s" % str( info.content))
+ if info:
+ field_contents = {}
+ for index, value in enumerate( info.content ):
+ key = 'field_%i' % index
+ field_contents[ key ] = value
+ widgets = get_form_widgets( trans, template, field_contents )
+ else:
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
if action == 'permissions':
if params.get( 'update_roles_button', False ):
permissions = {}
@@ -1242,6 +1292,7 @@
library_id=library_id,
deleted=deleted,
show_deleted=show_deleted,
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif action == 'edit_info':
@@ -1255,8 +1306,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
else:
@@ -1293,8 +1343,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif params.get( 'detect', False ):
@@ -1312,8 +1361,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif params.get( 'delete', False ):
@@ -1324,8 +1372,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
ldda.datatype.before_edit( ldda )
@@ -1340,8 +1387,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif ids:
@@ -1553,26 +1599,17 @@
last_used_build=last_used_build,
roles=roles,
history=history,
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
@web.expose
@web.require_admin
- def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ):
+ def info_template( self, trans, library_id, id=None, folder_id=None, ldda_id=None, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- if not num_fields:
- num_fields = 0
- else:
- num_fields = int( num_fields )
- if params.get( 'new_template', False ):
- action = 'new_template'
- elif params.get( 'permissions', False ):
- action = 'permissions'
- else:
- action = 'edit_template'
if id:
- library_item = trans.app.model.LibraryItemInfoTemplate.get( int( id ) )
+ library_item = trans.app.model.FormDefinition.get( int( id ) )
library_item_desc = 'information template'
response_action = 'info_template'
response_id = id
@@ -1586,174 +1623,51 @@
library_item_desc = 'library dataset'
response_action = 'library_dataset_dataset_association'
response_id = ldda_id
- elif library_dataset_id:
- library_item = trans.app.model.LibraryDataset.get( int( library_dataset_id ) )
- library_item_desc = 'dataset'
- response_action = 'library_dataset_dataset_association'
- response_id = library_item.library_dataset_dataset_association.id
else:
library_item = trans.app.model.Library.get( int( library_id ) )
library_item_desc = 'library'
response_action = 'browse_library'
response_id = library_id
- if action == 'new_template':
- if params.get( 'create_info_template_button', False ):
- return trans.fill_template( '/admin/library/new_info_template.mako',
- library_item_name=library_item.name,
- library_item_desc=library_item_desc,
- num_fields=num_fields,
- library_id=library_id,
- folder_id=folder_id,
- ldda_id=ldda_id,
- library_dataset_id=library_dataset_id,
- msg=msg,
- messagetype=messagetype )
- elif params.get( 'new_info_template_button', False ):
- # Make sure at least 1 template field is filled in
- # TODO: Eventually we'll enhance templates to allow for required and optional fields.
- proceed = False
- for i in range( int( params.get( 'set_num_fields', 0 ) ) ):
- elem_name = params.get( 'new_element_name_%i' % i, None )
- elem_description = params.get( 'new_element_description_%i' % i, None )
- if elem_name or elem_description:
- proceed = True
- break
- if not proceed:
- msg = "At least 1 of the fields must be completed."
- return trans.fill_template( '/admin/library/new_info_template.mako',
- library_item_name=library_item.name,
- library_item_desc=library_item_desc,
- num_fields=num_fields,
- library_id=library_id,
- folder_id=folder_id,
- ldda_id=ldda_id,
- library_dataset_id=library_dataset_id,
- msg=msg,
- messagetype=messagetype )
- # Create template
- liit = trans.app.model.LibraryItemInfoTemplate()
- liit.name = util.restore_text( params.get( 'name', '' ) )
- liit.description = util.restore_text( params.get( 'description', '' ) )
- liit.flush()
- # Inherit the template's permissions from the library_item
- trans.app.security_agent.copy_library_permissions( library_item, liit )
- # Create template association
+ forms = get_all_forms( trans )
+ 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
+ trans.response.send_redirect( web.url_for( controller='forms',
+ action='new',
+ new=True,
+ msg=msg,
+ messagetype='done' ) )
+ if params.get( 'add', False ):
+ if params.get( 'add_info_template_button', False ):
+ form = trans.app.model.FormDefinition.get( int( kwd[ 'form_id' ] ) )
+ #fields = list( copy.deepcopy( form.fields ) )
+ form_values = trans.app.model.FormValues( form, [] )
+ form_values.flush()
if folder_id:
- liit_assoc = trans.app.model.LibraryFolderInfoTemplateAssociation()
- liit_assoc.folder = trans.app.model.LibraryFolder.get( folder_id )
+ assoc = trans.app.model.LibraryFolderInfoAssociation( library_item, form, form_values )
elif ldda_id:
- liit_assoc = trans.app.model.LibraryDatasetDatasetInfoTemplateAssociation()
- ldda = trans.app.model.LibraryDatasetDatasetAssociation.get( ldda_id )
- liit_assoc.library_dataset_dataset_association = ldda
- # This response_action method requires a folder_id
- folder_id = ldda.library_dataset.folder.id
- elif library_dataset_id:
- liit_assoc = trans.app.model.LibraryDatasetInfoTemplateAssociation()
- library_dataset = trans.app.model.LibraryDataset.get( library_dataset_id )
- liit_assoc.library_dataset = library_dataset
- # This response_action method requires a folder_id
- folder_id = library_dataset.folder.id
+ assoc = trans.app.model.LibraryDatasetDatasetInfoAssociation( library_item, form, form_values )
else:
- # We'll always be sent a library_id
- liit_assoc = trans.app.model.LibraryInfoTemplateAssociation()
- liit_assoc.library = trans.app.model.Library.get( library_id )
- liit_assoc.library_item_info_template = liit
- liit_assoc.flush()
- # Create and add elements
- for i in range( int( params.get( 'set_num_fields', 0 ) ) ):
- elem_name = params.get( 'new_element_name_%i' % i, None )
- elem_description = params.get( 'new_element_description_%i' % i, None )
- if elem_description and not elem_name:
- # If we have a description but no name, the description will be both
- # ( a name cannot be empty, but a description can )
- elem_name = elem_description
- if elem_name:
- # Skip any elements that have a missing name
- liit.add_element( name=elem_name, description=elem_description )
- msg = "The new information template has been created."
- return trans.response.send_redirect( web.url_for( controller='admin',
- action=response_action,
- id=response_id,
- library_id=library_id,
- folder_id=folder_id,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( '/admin/library/create_info_template.mako',
- library_item=library_item,
- library_id=library_id,
- msg=msg,
- messagetype=messagetype )
- elif action == 'edit_template':
- define_or_save = 'define'
- edit_info_template_button = params.get( 'edit_info_template_button', False )
- if edit_info_template_button:
- if edit_info_template_button == 'Define fields':
- define_or_save = 'save'
- else:
- define_or_save = 'define'
- # Save changes to existing attributes, only set name if nonempty/nonNone is passed, but always set description
- name = params.get( 'name', None )
- if name:
- library_item.name = name
- library_item.description = params.get( 'description', '' )
- library_item.flush()
- # Save changes to exisiting elements
- for elem_id in util.listify( params.get( 'element_ids', [] ) ):
- liit_element = trans.app.model.LibraryItemInfoTemplateElement.get( elem_id )
- name = params.get( 'element_name_%s' % elem_id, None )
- if name:
- liit_element.name = name
- liit_element.description = params.get( 'element_description_%s' % elem_id, None )
- liit_element.flush()
- # Add new elements
- for i in range( int( params.get( 'set_num_fields', 0 ) ) ):
- elem_name = params.get( 'new_element_name_%i' % i, None )
- elem_description = params.get( 'new_element_description_%i' % i, None )
- # Skip any elements that have a missing name and description
- if not elem_name:
- # If we have a description but no name, the description will be both
- # ( a name cannot be empty, but a description can )
- elem_name = elem_description
- if elem_name:
- library_item.add_element( name=elem_name, description=elem_description )
- library_item.refresh()
- msg = "Information template '%s' has been updated" % library_item.name
- return trans.fill_template( "/admin/library/edit_info_template.mako",
- liit=library_item,
- num_fields=num_fields,
- library_id=library_id,
- library_dataset_id=library_dataset_id,
- ldda_id=ldda_id,
- folder_id=folder_id,
+ assoc = trans.app.model.LibraryInfoAssociation( library_item, form, form_values )
+ assoc.flush()
+ msg = 'An information template based on the form "%s" has been added to this %s.' % ( form.name, library_item_desc )
+ trans.response.send_redirect( web.url_for( controller='admin',
+ action=response_action,
+ id=response_id,
+ msg=msg,
+ message_type='done' ) )
+ return trans.fill_template( '/admin/library/select_info_template.mako',
library_item_name=library_item.name,
library_item_desc=library_item_desc,
- define_or_save=define_or_save,
- msg=msg,
- messagetype=messagetype )
- elif action == 'permissions':
- if params.get( 'update_roles_button', False ):
- permissions = {}
- for k, v in trans.app.model.Library.permitted_actions.items():
- in_roles = [ trans.app.model.Role.get( x ) for x in util.listify( kwd.get( k + '_in', [] ) ) ]
- permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
- trans.app.security_agent.set_all_library_permissions( library_item, permissions )
- library_item.refresh()
- msg = "Permissions updated for information template '%s'" % library_item.name
- return trans.response.send_redirect( web.url_for( controller='admin',
- action='info_template',
- library_id=library_id,
- id=id,
- permissions=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( '/admin/library/info_template_permissions.mako',
- liit=library_item,
library_id=library_id,
+ folder_id=folder_id,
+ ldda_id=ldda_id,
+ forms=forms,
msg=msg,
messagetype=messagetype )
@web.expose
@web.require_admin
- def library_item_info( self, trans, library_id, id=None, library_item_id=None, library_item_type=None, **kwd ):
+ def edit_template_info( self, trans, library_id, num_widgets, library_item_id=None, library_item_type=None, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
@@ -1768,8 +1682,6 @@
library_item = trans.app.model.LibraryDatasetDatasetAssociation.get( library_item_id )
# This response_action method requires a folder_id
folder_id = library_item.library_dataset.folder.id
- elif library_item_type == 'library_item_info_elememt':
- library_item = trans.app.model.LibraryItemInfoElement.get( library_item_id )
else:
msg = "Invalid library item type ( %s ) specified, id ( %s )" % ( str( library_item_type ), str( library_item_id ) )
return trans.response.send_redirect( web.url_for( controller='admin',
@@ -1777,107 +1689,47 @@
id=library_id,
msg=util.sanitize_text( msg ),
messagetype='error' ) )
- if params.get( 'new_info', False ):
- if library_item:
- if params.get( 'create_new_info_button', False ):
- library_item_info_template_id = params.get( 'library_item_info_template_id', None )
- library_item_info_template = trans.app.model.LibraryItemInfoTemplate.get( int( library_item_info_template_id ) )
- # Make sure at least 1 template field is filled in
- # TODO: Eventually we'll enhance templates to allow for required and optional fields.
- proceed = False
- for template_element in library_item_info_template.elements:
- if params.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None ):
- proceed = True
- break
- if not proceed:
- msg = "At least 1 of the fields must be completed."
- return trans.response.send_redirect( web.url_for( controller='admin',
- action=library_item_type,
- id=library_item.id,
- library_id=library_id,
- folder_id=folder_id,
- edit_info=True,
- msg=util.sanitize_text( msg ),
- messagetype='error' ) )
- user = trans.get_user()
- library_item_info = trans.app.model.LibraryItemInfo( user=user )
- library_item_info.library_item_info_template = library_item_info_template
- library_item_info.flush()
- trans.app.security_agent.copy_library_permissions( library_item_info_template, library_item_info )
- for template_element in library_item_info_template.elements:
- info_element_value = params.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None )
- info_element = trans.app.model.LibraryItemInfoElement()
- info_element.contents = info_element_value
- info_element.library_item_info_template_element = template_element
- info_element.library_item_info = library_item_info
- info_element.flush()
- info_association_class = None
- for item_class, permission_class, info_association_class in trans.app.security_agent.library_item_assocs:
- if isinstance( library_item, item_class ):
- break
- if info_association_class:
- library_item_info_association = info_association_class( user=user )
- library_item_info_association.set_library_item( library_item )
- library_item_info_association.library_item_info = library_item_info
- library_item_info_association.flush()
- else:
- raise 'Invalid class (%s) specified for library_item (%s)' % ( library_item.__class__, library_item.__class__.__name__ )
- msg = 'The information has been saved'
- return trans.response.send_redirect( web.url_for( controller='admin',
- action=library_item_type,
- id=library_item.id,
- library_id=library_id,
- folder_id=folder_id,
- edit_info=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( "/admin/library/new_info.mako",
- library_id=library_id,
- library_item=library_item,
- library_item_type=library_item_type,
- msg=msg,
- messagetype=messagetype )
- elif params.get( 'edit_info', False ):
- if params.get( 'edit_info_button', False ):
- ids = util.listify( id )
- for id in ids:
- library_item_info_element = trans.app.model.LibraryItemInfoElement.get( int( id ) )
- new_contents = util.restore_text( params.get( ( 'info_element_%s' % id ), '' ) )
- library_item_info_element.contents = new_contents
- library_item_info_element.flush()
- msg = 'The information has been updated.'
- return trans.response.send_redirect( web.url_for( controller='admin',
- action=library_item_type,
- id=library_item.id,
- library_id=library_id,
- folder_id=folder_id,
- edit_info=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- elif params.get( 'permissions', False ):
- if params.get( 'update_roles_button', False ):
- permissions = {}
- for k, v in trans.app.model.Library.permitted_actions.items():
- in_roles = [ trans.app.model.Role.get( x ) for x in util.listify( kwd.get( k + '_in', [] ) ) ]
- permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
- trans.app.security_agent.set_all_library_permissions( library_item.library_item_info, permissions )
- library_item.library_item_info.refresh()
- library_item.refresh()
- msg = "Permissions updated for field '%s'" % library_item.library_item_info_template_element.name
- return trans.response.send_redirect( web.url_for( controller='admin',
- action='library_item_info',
- library_id=library_id,
- id=id,
- library_item_id=library_item_id,
- library_item_type=library_item_type,
- permissions=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( '/admin/library/info_permissions.mako',
- library_item_info_element=library_item,
- library_id=library_id,
- msg=msg,
- messagetype=messagetype )
+ # Save updated template field contents
+ field_contents = []
+ for index in range( int( num_widgets ) ):
+ field_contents.append( util.restore_text( params.get( 'field_%i' % ( index ), '' ) ) )
+ if field_contents:
+ # Since information templates are inherited, the template fields can be displayed on the information
+ # page for a folder or library dataset when it has no info_association object. If the user has added
+ # field contents on an inherited template via a parent's info_association, we'll need to create a new
+ # form_values and info_association for the current object.
+ info_association = library_item.get_info_association( restrict=True )
+ if info_association:
+ template = info_association.template
+ info = info_association.info
+ form_values = trans.app.model.FormValues.get( info.id )
+ # Update existing content only if it has changed
+ if form_values.content != field_contents:
+ form_values.content = field_contents
+ form_values.flush()
+ else:
+ # Inherit the next available info_association so we can get the template
+ info_association = library_item.get_info_association()
+ template = info_association.template
+ # Create a new FormValues object
+ form_values = trans.app.model.FormValues( template, field_contents )
+ form_values.flush()
+ # Create a new info_association between the current library item and form_values
+ if library_item_type == 'folder':
+ info_association = trans.app.model.LibraryFolderInfoAssociation( library_item, template, form_values )
+ info_association.flush()
+ elif library_item_type == 'library_dataset_dataset_association':
+ info_association = trans.app.model.LibraryDatasetDatasetInfoAssociation( library_item, template, form_values )
+ info_association.flush()
+ msg = 'The information has been updated.'
+ return trans.response.send_redirect( web.url_for( controller='admin',
+ action=library_item_type,
+ id=library_item.id,
+ library_id=library_id,
+ folder_id=folder_id,
+ edit_info=True,
+ msg=util.sanitize_text( msg ),
+ messagetype='done' ) )
@web.expose
@web.require_admin
def download_dataset_from_folder(self, trans, id, library_id=None, **kwd):
@@ -2101,19 +1953,6 @@
else:
last_updated[job.id] = '%s minutes' % int( delta.seconds / 60 )
return trans.fill_template( '/admin/jobs.mako', jobs = jobs, last_updated = last_updated, cutoff = cutoff, msg = msg, messagetype = messagetype )
-
- def _get_all_forms(self, trans, all_versions=False):
- '''
- This method returns all the latest forms from the
- form_definition_current table if all_versions is set to True. Otherwise
- this method return all the versions of all the forms from form_definition
- table
- '''
- if all_versions:
- return trans.app.model.FormDefinition.query().all()
- else:
- fdc_list = trans.app.model.FormDefinitionCurrent.query().all()
- return [fdc.latest_form for fdc in fdc_list]
@web.expose
@web.require_admin
def manage_request_types( self, trans, **kwd ):
@@ -2121,7 +1960,7 @@
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
show_filter = util.restore_text( params.get( 'show_filter', 'Active' ) )
- forms = self._get_all_forms(trans, all_versions=True)
+ forms = get_all_forms(trans, all_versions=True)
request_types_list = trans.app.model.RequestType.query().all()
if show_filter == 'All':
request_types = request_types_list
@@ -2141,12 +1980,12 @@
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- if params.get('create', False) == 'True':
+ if params.get( 'create', False ):
return trans.fill_template( '/admin/requests/create_request_type.mako',
- forms=self._get_all_forms(trans, all_versions=False),
+ forms=get_all_forms( trans ),
msg=msg,
messagetype=messagetype)
- elif params.get('add_states', False) == 'True':
+ elif params.get( 'add_states', False ):
return trans.fill_template( '/admin/requests/add_states.mako',
sample_type_name=util.restore_text( params.name ),
desc=util.restore_text( params.description ),
@@ -2155,11 +1994,11 @@
sample_form_id=int(util.restore_text( params.sample_form_id )),
msg=msg,
messagetype=messagetype)
- elif params.get('save_new', False) == 'True':
+ elif params.get( 'save_new', False ):
st, msg = self._save_request_type(trans, **kwd)
if not st:
return trans.fill_template( '/admin/requests/create_request_type.mako',
- forms=self._get_all_forms(trans, all_versions=False),
+ forms=get_all_forms( trans ),
msg=msg,
messagetype='error')
return trans.response.send_redirect( web.url_for( controller='admin',
@@ -2171,7 +2010,7 @@
ss_list = trans.app.model.SampleState.filter(trans.app.model.SampleState.table.c.request_type_id == rt.id).all()
return trans.fill_template( '/admin/requests/view_request_type.mako',
request_type=rt,
- forms=self._get_all_forms(trans, all_versions=False),
+ forms=get_all_forms( trans ),
states_list=ss_list,
deleted=False,
show_deleted=False,
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/web/controllers/forms.py
--- a/lib/galaxy/web/controllers/forms.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/web/controllers/forms.py Fri Aug 07 16:11:14 2009 -0400
@@ -10,7 +10,6 @@
import copy
log = logging.getLogger( __name__ )
-
class Forms( BaseController ):
@web.expose
@@ -44,45 +43,30 @@
show_filter=show_filter,
msg=msg,
messagetype=messagetype )
- def _get_all_forms(self, trans, all_versions=False):
- '''
- This method returns all the latest forms from the
- form_definition_current table if all_versions is set to True. Otherwise
- this method return all the versions of all the forms from form_definition
- table
- '''
- if all_versions:
- return trans.app.model.FormDefinition.query().all()
- else:
- fdc_list = trans.app.model.FormDefinitionCurrent.query().all()
- return [fdc.latest_form for fdc in fdc_list]
@web.expose
@web.require_admin
def new( self, trans, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
- messagetype = params.get( 'messagetype', 'done' )
- if params.get('new', False) and not params.get('create_form', False):
- self.current_form = {}
- self.current_form['name'] = 'New Form'
- self.current_form['desc'] = ''
- self.current_form['fields'] = []
- inputs = [ ( 'Name', TextField('name', 40,self.current_form['name'] ) ),
- ( 'Description', TextField('description', 40, self.current_form['desc']) ),
- ( 'Import from csv file (Optional)', TextField('csv_file', 40, '') ) ]
- return trans.fill_template( '/admin/forms/create_form.mako',
- inputs=inputs,
- msg=msg,
- messagetype=messagetype )
- elif params.get('create_form', False) == 'True':
- if 'submitted' in params.new:
- self.num_add_fields = 0
- fd, msg = self.__save_form(trans, fdc_id=None, **kwd)
- self.__get_saved_form(fd)
- return trans.response.send_redirect( web.url_for( controller='forms',
- action='edit',
- form_id=fd.id,
- show_form=True) )
+ messagetype = params.get( 'messagetype', 'done' )
+ if params.get( 'create_form_button', False ):
+ fd, msg = self.__save_form( trans, fdc_id=None, **kwd )
+ self.__get_saved_form( fd )
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='edit',
+ form_id=fd.id,
+ show_form=True ) )
+ self.current_form = {}
+ self.current_form[ 'name' ] = 'New Form'
+ self.current_form[ 'desc' ] = ''
+ self.current_form[ 'fields' ] = []
+ inputs = [ ( 'Name', TextField( 'name', 40, self.current_form[ 'name' ] ) ),
+ ( 'Description', TextField( 'description', 40, self.current_form[ 'desc' ] ) ),
+ ( 'Import from csv file (Optional)', TextField( 'csv_file', 40, '' ) ) ]
+ return trans.fill_template( '/admin/forms/create_form.mako',
+ inputs=inputs,
+ msg=msg,
+ messagetype=messagetype )
@web.expose
@web.require_admin
def delete( self, trans, **kwd ):
@@ -111,73 +95,75 @@
@web.require_admin
def edit( self, trans, **kwd ):
'''
- This callback method is for handling all the editing functions like:
- remaning fields, adding/deleting fields, changing fields attributes
+ This callback method is for handling all the editing functions like
+ renaming fields, adding/deleting fields, changing fields attributes.
'''
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- fd = trans.app.model.FormDefinition.get(int(util.restore_text( params.form_id )))
- # SHOW THE FORM FOR EDITING.
- if params.get('show_form', False) == 'True':
- self.__get_saved_form(fd)
- # the following two dicts store the unsaved select box options
+ form_id = params.get( 'form_id', None )
+ if not form_id:
+ msg = 'Invalid form id %s' % str( form_id )
+ trans.response.send_redirect( web.url_for( controller='forms',
+ action='manage',
+ msg=msg,
+ messagetype='error' ) )
+ fd = trans.app.model.FormDefinition.get( int( params.form_id ) )
+ # Show the form for editing
+ if params.get( 'show_form', False ):
+ self.__get_saved_form( fd )
+ # The following two dicts store the unsaved select box options
self.del_options = {}
self.add_options = {}
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
- # DELETE FIELD
- elif params.get('remove_button', False):
- self.__update_current_form(**kwd)
- index = int(params.get('remove_button', None).split(' ')[2])-1
- self.__remove_field(index)
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
- # SAVE CHANGES
- elif params.get('save_changes_button', False) == 'Save':
- self.__update_current_form(**kwd)
- fd_new, msg = self.__save_form(trans, fd.form_definition_current.id, **kwd)
+ if fd.fields:
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
+ else:
+ # If the form is empty, we'll simulate a click on the add_field_button so the
+ # form will be displayed with the field choice, saving a mouse click.
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, empty_form=True, **kwd )
+ # Delete a field
+ elif params.get( 'remove_button', False ):
+ self.__update_current_form( **kwd )
+ index = int( kwd[ 'remove_button' ].split( ' ' )[2] ) - 1
+ self.__remove_field( index )
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
+ # Save changes
+ elif params.get( 'save_changes_button', False ):
+ self.__update_current_form( **kwd )
+ fd_new, msg = self.__save_form( trans, fd.form_definition_current.id, **kwd )
if not fd_new:
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype='error', **kwd)
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype='error', **kwd )
else:
fd = fd_new
msg = "The form '%s' has been updated with the changes." % fd.name
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
- #ADD A FIELD
- elif params.get('add_field_button', False) == 'Add field':
- self.__update_current_form(**kwd)
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
+ #Add a field
+ elif params.get( 'add_field_button', False ):
+ self.__update_current_form( **kwd )
self.__add_field()
# show the form again with one empty field
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
- # SHOW FORM READ ONLY
- elif params.get('read_only', False):
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
+ # Show form read-only
+ elif params.get( 'read_only', False ):
return trans.fill_template( '/admin/forms/show_form_read_only.mako',
form=fd,
msg=msg,
messagetype=messagetype )
- # REFRESH PAGE, SelectField is selected/deselected as the type of a field
- elif params.get('refresh', False) == 'true':
- self.__update_current_form(**kwd)
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
- # REMOVE SelectField OPTION
- elif params.get('select_box_options', False) == 'remove':
- #self.__update_current_form(**kwd)
- index = int(params.get( 'field_index', None ))
- option = int(params.get( 'option_index', None ))
- del self.current_form['fields'][index]['selectlist'][option]
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
- # ADD SelectField OPTION
- elif params.get('select_box_options', False) == 'add':
- #self.__update_current_form(**kwd)
- index = int(params.get( 'field_index', None ))
- self.current_form['fields'][index]['selectlist'].append('')
- return self.__show(trans=trans, form=fd, msg=msg,
- messagetype=messagetype, **kwd)
+ # Refresh page, SelectField is selected/deselected as the type of a field
+ elif params.get( 'refresh', False ):
+ self.__update_current_form( **kwd )
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
+ # Remove SelectField option
+ elif params.get( 'select_box_options', False ) == 'remove':
+ index = int( kwd[ 'field_index' ] )
+ option = int( kwd[ 'option_index' ] )
+ del self.current_form[ 'fields' ][ index ][ 'selectlist' ][ option ]
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
+ # Add SelectField option
+ elif params.get( 'select_box_options', False ) == 'add':
+ index = int( kwd[ 'field_index' ] )
+ self.current_form[ 'fields' ][ index ][ 'selectlist' ].append( '' )
+ return self.__show( trans=trans, form=fd, msg=msg, messagetype=messagetype, **kwd )
def __remove_field(self, index):
del self.current_form['fields'][index]
def __add_field(self):
@@ -193,6 +179,10 @@
self.current_form['fields'].append(empty_field)
def __get_field(self, index, **kwd):
params = util.Params( kwd )
+ #TODO: RC this needs to be handled so that it does not throw an exception.
+ # To reproduce, create a new form, click the "add field" button, click the
+ # browser back arrow, then click the "add field" button again.
+ # You should never attempt to "restore_text()" on a None object...
name = util.restore_text( params.get( 'field_name_%i' % index, None ) )
helptext = util.restore_text( params.get( 'field_helptext_%i' % index, None ) )
required = params.get( 'field_required_%i' % index, False )
@@ -314,9 +304,6 @@
trans.sa_session.save_or_update( fdc )
trans.sa_session.flush()
msg = "The new form named '%s' has been created. " % (fd.name)
- request_types = trans.app.model.RequestType.query().all()
- if not request_types:
- msg = msg + "Now you can create requests to associate with this form."
return fd, msg
class FieldUI(object):
@@ -381,18 +368,31 @@
def label(self):
return str(self.index)+'.'+self.label
- def __show(self, trans, form, msg=None, messagetype='done', **kwd):
+ def __show( self, trans, form, msg='', messagetype='done', empty_form=False, **kwd ):
'''
- This method displays the form and any of the changes made to it
+ This method displays the form and any of the changes made to it,
+ The empty_form param allows for this method to simulate clicking
+ the "add_field_button" on the edit_form.mako page so that the page
+ is displayed with the first field to be added, saving a mouse click.
'''
+ if empty_form:
+ # Send params that will simulate a button click on the add_field_button
+ # button on edit_form.mako.
+ param_dict = { 'form_id' : str( form.id ),
+ 'num_fields' : '0',
+ 'refresh' : 'true',
+ 'name' : form.name,
+ 'description' : form.desc,
+ 'add_field_button' : 'Add field' }
+ self.edit( trans, **param_dict )
params = util.Params( kwd )
# name & description
- form_details = [ ( 'Name', TextField('name', 40, self.current_form['name']) ),
- ( 'Description', TextField('description', 40, self.current_form['desc']) ) ]
+ form_details = [ ( 'Name', TextField( 'name', 40, self.current_form[ 'name' ] ) ),
+ ( 'Description', TextField( 'description', 40, self.current_form[ 'desc' ] ) ) ]
# fields
field_details = []
- for index, field in enumerate(self.current_form['fields']):
- field_ui = self.FieldUI(index, field)
+ for index, field in enumerate( self.current_form[ 'fields' ] ):
+ field_ui = self.FieldUI( index, field )
field_details.append( field_ui.get() )
return trans.fill_template( '/admin/forms/edit_form.mako',
form_details=form_details,
@@ -401,3 +401,59 @@
field_types=BaseField.form_field_types(),
msg=msg,
messagetype=messagetype )
+
+# Common methods for all components that use forms
+def get_all_forms( trans, all_versions=False, filter=None ):
+ '''
+ Return all the latest forms from the form_definition_current table
+ if all_versions is set to True. Otherwise return all the versions
+ of all the forms from the form_definition table.
+
+ TODO: when we add the concept of a form_definition_type ( e.g.,
+ 'request_header', 'request_sample', 'library_template' ), filter
+ the query if received filter is not None.
+ '''
+ if all_versions:
+ return trans.app.model.FormDefinition.query().all()
+ else:
+ fdc_list = trans.app.model.FormDefinitionCurrent.query().all()
+ return [ fdc.latest_form for fdc in fdc_list ]
+def get_form_widgets( trans, form, contents={} ):
+ '''
+ Return the list of widgets that comprise a form definition,
+ including field contents if any.
+ '''
+ widgets = []
+ for index, field in enumerate( form.fields ):
+ field_name = 'field_%i' % index
+ if field_name in contents:
+ value = contents[ field_name ]
+ elif field[ 'type' ] == 'CheckboxField':
+ # Since we do not have contents, set checkbox value to False
+ value = False
+ else:
+ # Set other field types to empty string
+ value = ''
+ field_widget = eval( field[ 'type' ] )( field_name )
+ if field[ 'type' ] == 'TextField':
+ field_widget.set_size( 40 )
+ field_widget.value = value
+ elif field[ 'type' ] == 'TextArea':
+ field_widget.set_size( 3, 40 )
+ field_widget.value = value
+ elif field[ 'type' ] == 'SelectField':
+ for option in field[ 'selectlist' ]:
+ if option == value:
+ field_widget.add_option( option, option, selected=True )
+ else:
+ field_widget.add_option( option, option )
+ elif field[ 'type' ] == 'CheckboxField':
+ field_widget.checked = value
+ if field[ 'required' ] == 'required':
+ req = 'Required'
+ else:
+ req = 'Optional'
+ widgets.append( dict( label=field[ 'label' ],
+ widget=field_widget,
+ helptext='%s (%s)' % ( field[ 'helptext' ], req ) ) )
+ return widgets
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/web/controllers/library.py
--- a/lib/galaxy/web/controllers/library.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/web/controllers/library.py Fri Aug 07 16:11:14 2009 -0400
@@ -2,6 +2,7 @@
from galaxy.model.orm import *
from galaxy.datatypes import sniff
from galaxy import util
+from galaxy.web.controllers.forms import get_all_forms, get_form_widgets
from galaxy.util.streamball import StreamBall
import logging, tempfile, zipfile, tarfile, os, sys
@@ -130,6 +131,21 @@
msg=util.sanitize_text( msg ),
messagetype='error' ) )
if action == 'information':
+ # See if we have any associated templates
+ if library.info_association:
+ template = library.info_association[0].template
+ # See if we have any field contents
+ info = library.info_association[0].info
+ if info:
+ field_contents = {}
+ for index, value in enumerate( info.content ):
+ key = 'field_%i' % index
+ field_contents[ key ] = value
+ widgets = get_form_widgets( trans, template, field_contents )
+ else:
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
if params.get( 'rename_library_button', False ):
old_name = library.name
new_name = util.restore_text( params.name )
@@ -138,8 +154,7 @@
msg = 'Enter a valid name'
return trans.fill_template( '/library/library_info.mako',
library=library,
- restrict=params.get( 'restrict', False ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype='error' )
else:
@@ -159,8 +174,7 @@
messagetype='done' ) )
return trans.fill_template( '/library/library_info.mako',
library=library,
- restrict=params.get( 'restrict', False ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif action == 'permissions':
@@ -377,8 +391,6 @@
return trans.fill_template( '/library/library_dataset_info.mako',
library_dataset=library_dataset,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
msg=msg,
messagetype=messagetype )
elif action == 'permissions':
@@ -456,6 +468,22 @@
id=library_id,
msg=util.sanitize_text( msg ),
messagetype='error' ) )
+ # See if we have any associated templates
+ info_association = folder.get_info_association()
+ if info_association:
+ template = info_association.template
+ # See if we have any field contents
+ info = info_association.info
+ if info:
+ field_contents = {}
+ for index, value in enumerate( info.content ):
+ key = 'field_%i' % index
+ field_contents[ key ] = value
+ widgets = get_form_widgets( trans, template, field_contents )
+ else:
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
if action == 'permissions':
if params.get( 'update_roles_button', False ):
# The user clicked the Save button on the 'Associate With Roles' form
@@ -497,6 +525,7 @@
return trans.fill_template( '/library/ldda_info.mako',
ldda=ldda,
library_id=library_id,
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif action == 'edit_info':
@@ -520,8 +549,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif params.get( 'save', False ):
@@ -562,8 +590,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif params.get( 'detect', False ):
@@ -588,8 +615,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif params.get( 'delete', False ):
@@ -607,8 +633,7 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
if trans.app.security_agent.allow_action( trans.user,
@@ -626,12 +651,11 @@
ldda=ldda,
library_id=library_id,
datatypes=ldatatypes,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif ids:
- # Multiple ids specfied, display permission form, permissions will be updated for all simultaneously.
+ # Multiple ids specified, display permission form, permissions will be updated for all simultaneously.
lddas = []
for id in [ int( id ) for id in ids ]:
ldda = trans.app.model.LibraryDatasetDatasetAssociation.get( id )
@@ -737,7 +761,7 @@
controller='library',
library_id=library_id,
folder_id=folder_id,
- replace_dataset=replace_dataset,
+ replace_dataset=replace_dataset,
**kwd )
if created_ldda_ids:
ldda_id_list = created_ldda_ids.split( ',' )
@@ -965,6 +989,22 @@
msg=msg,
messagetype=messagetype )
elif action == 'information':
+ # See if we have any associated templates
+ info_association = folder.get_info_association()
+ if info_association:
+ template = info_association.template
+ # See if we have any field contents
+ info = info_association.info
+ if info:
+ field_contents = {}
+ for index, value in enumerate( info.content ):
+ key = 'field_%i' % index
+ field_contents[ key ] = value
+ widgets = get_form_widgets( trans, template, field_contents )
+ else:
+ widgets = get_form_widgets( trans, template )
+ else:
+ widgets = []
if params.get( 'rename_folder_button', False ):
if trans.app.security_agent.allow_action( trans.user,
trans.app.security_agent.permitted_actions.LIBRARY_MODIFY,
@@ -977,8 +1017,7 @@
return trans.fill_template( "/library/folder_info.mako",
folder=folder,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype='error' )
else:
@@ -998,15 +1037,13 @@
return trans.fill_template( "/library/folder_info.mako",
folder=folder,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype='error' )
return trans.fill_template( '/library/folder_info.mako',
folder=folder,
library_id=library_id,
- restrict=params.get( 'restrict', True ),
- render_templates=params.get( 'render_templates', False ),
+ widgets=widgets,
msg=msg,
messagetype=messagetype )
elif action == 'permissions':
@@ -1044,22 +1081,12 @@
msg=msg,
messagetype=messagetype )
@web.expose
- def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ):
+ def info_template( self, trans, library_id, id=None, folder_id=None, ldda_id=None, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- if not num_fields:
- num_fields = 0
- else:
- num_fields = int( num_fields )
- if params.get( 'new_template', False ):
- action = 'new_template'
- elif params.get( 'permissions', False ):
- action = 'permissions'
- else:
- action = 'edit_template'
if id:
- library_item = trans.app.model.LibraryItemInfoTemplate.get( int( id ) )
+ library_item = trans.app.model.FormDefinition.get( int( id ) )
library_item_desc = 'information template'
response_action = 'info_template'
response_id = id
@@ -1073,176 +1100,41 @@
library_item_desc = 'library dataset'
response_action = 'library_dataset_dataset_association'
response_id = ldda_id
- elif library_dataset_id:
- library_item = trans.app.model.LibraryDataset.get( int( library_dataset_id ) )
- library_item_desc = 'dataset'
- response_action = 'library_dataset_dataset_association'
- response_id = library_item.library_dataset_dataset_association.id
else:
library_item = trans.app.model.Library.get( int( library_id ) )
library_item_desc = 'library'
response_action = 'browse_library'
response_id = library_id
- if action == 'new_template':
- if params.get( 'create_info_template_button', False ):
- return trans.fill_template( '/library/new_info_template.mako',
- library_item=library_item,
- library_item_name=library_item.name,
- library_item_desc=library_item_desc,
- num_fields=num_fields,
- library_id=library_id,
- folder_id=folder_id,
- ldda_id=ldda_id,
- library_dataset_id=library_dataset_id,
- msg=msg,
- messagetype=messagetype )
- elif params.get( 'new_info_template_button', False ):
- # Make sure at least 1 template field is filled in
- # TODO: Eventually we'll enhance templates to allow for required and optional fields.
- proceed = False
- for i in range( int( params.get( 'set_num_fields', 0 ) ) ):
- elem_name = params.get( 'new_element_name_%i' % i, None )
- elem_description = params.get( 'new_element_description_%i' % i, None )
- if elem_name or elem_description:
- proceed = True
- break
- if not proceed:
- msg = "At least 1 of the fields must be completed."
- return trans.fill_template( '/library/new_info_template.mako',
- library_item=library_item,
- library_item_name=library_item.name,
- library_item_desc=library_item_desc,
- num_fields=num_fields,
- library_id=library_id,
- folder_id=folder_id,
- ldda_id=ldda_id,
- library_dataset_id=library_dataset_id,
- msg=msg,
- messagetype=messagetype )
- # Create template
- liit = trans.app.model.LibraryItemInfoTemplate()
- liit.name = util.restore_text( params.get( 'name', '' ) )
- liit.description = util.restore_text( params.get( 'description', '' ) )
- liit.flush()
- # Inherit the template's permissions from the library_item
- trans.app.security_agent.copy_library_permissions( liit, library_item )
- # Create template association
+ if params.get( 'add', False ):
+ if params.get( 'add_info_template_button', False ):
+ form = trans.app.model.FormDefinition.get( int( kwd[ 'form_id' ] ) )
+ #fields = list( copy.deepcopy( form.fields ) )
+ form_values = trans.app.model.FormValues( form, [] )
+ form_values.flush()
if folder_id:
- liit_assoc = trans.app.model.LibraryFolderInfoTemplateAssociation()
- liit_assoc.folder = trans.app.model.LibraryFolder.get( folder_id )
+ assoc = trans.app.model.LibraryFolderInfoAssociation( library_item, form, form_values )
elif ldda_id:
- liit_assoc = trans.app.model.LibraryDatasetDatasetInfoTemplateAssociation()
- ldda = trans.app.model.LibraryDatasetDatasetAssociation.get( ldda_id )
- liit_assoc.library_dataset_dataset_association = ldda
- # This response_action method requires a folder_id
- folder_id = ldda.library_dataset.folder.id
- elif library_dataset_id:
- liit_assoc = trans.app.model.LibraryDatasetInfoTemplateAssociation()
- library_dataset = trans.app.model.LibraryDataset.get( library_dataset_id )
- liit_assoc.library_dataset = library_dataset
- # This response_action method requires a folder_id
- folder_id = library_dataset.folder.id
+ assoc = trans.app.model.LibraryDatasetDatasetInfoAssociation( library_item, form, form_values )
else:
- # We'll always be sent a library_id
- liit_assoc = trans.app.model.LibraryInfoTemplateAssociation()
- liit_assoc.library = trans.app.model.Library.get( library_id )
- liit_assoc.library_item_info_template = liit
- liit_assoc.flush()
- # Create and add elements
- for i in range( int( params.get( 'set_num_fields', 0 ) ) ):
- elem_name = params.get( 'new_element_name_%i' % i, None )
- elem_description = params.get( 'new_element_description_%i' % i, None )
- if elem_description and not elem_name:
- # If we have a description but no name, the description will be both
- # ( a name cannot be empty, but a description can )
- elem_name = elem_description
- if elem_name:
- # Skip any elements that have a missing name
- liit.add_element( name=elem_name, description=elem_description )
- msg = "The new information template has been created."
- return trans.response.send_redirect( web.url_for( controller='library',
- action=response_action,
- id=response_id,
- library_id=library_id,
- folder_id=folder_id,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( '/library/create_info_template.mako',
- library_item=library_item,
- library_id=library_id,
- msg=msg,
- messagetype=messagetype )
- elif action == 'edit_template':
- define_or_save = 'define'
- edit_info_template_button = params.get( 'edit_info_template_button', False )
- if edit_info_template_button:
- if edit_info_template_button == 'Define fields':
- define_or_save = 'save'
- else:
- define_or_save = 'define'
- # Save changes to existing attributes, only set name if nonempty/nonNone is passed, but always set description
- name = params.get( 'name', None )
- if name:
- library_item.name = name
- library_item.description = params.get( 'description', '' )
- library_item.flush()
- # Save changes to exisiting elements
- for elem_id in util.listify( params.get( 'element_ids', [] ) ):
- liit_element = trans.app.model.LibraryItemInfoTemplateElement.get( elem_id )
- name = params.get( 'element_name_%s' % elem_id, None )
- if name:
- liit_element.name = name
- liit_element.description = params.get( 'element_description_%s' % elem_id, None )
- liit_element.flush()
- # Add new elements
- for i in range( int( params.get( 'set_num_fields', 0 ) ) ):
- elem_name = params.get( 'new_element_name_%i' % i, None )
- elem_description = params.get( 'new_element_description_%i' % i, None )
- # Skip any elements that have a missing name and description
- if not elem_name:
- # If we have a description but no name, the description will be both
- # ( a name cannot be empty, but a description can )
- elem_name = elem_description
- if elem_name:
- library_item.add_element( name=elem_name, description=elem_description )
- library_item.refresh()
- msg = 'Information template %s has been updated' % library_item.name
- return trans.fill_template( "/library/edit_info_template.mako",
- liit=library_item,
- num_fields=num_fields,
- library_id=library_id,
- library_dataset_id=library_dataset_id,
- ldda_id=ldda_id,
- folder_id=folder_id,
+ assoc = trans.app.model.LibraryInfoAssociation( library_item, form, form_values )
+ assoc.flush()
+ msg = 'An information template based on the form "%s" has been added to this %s.' % ( form.name, library_item_desc )
+ trans.response.send_redirect( web.url_for( controller='library',
+ action=response_action,
+ id=response_id,
+ msg=msg,
+ message_type='done' ) )
+ return trans.fill_template( '/library/select_info_template.mako',
library_item_name=library_item.name,
library_item_desc=library_item_desc,
- define_or_save=define_or_save,
- msg=msg,
- messagetype=messagetype )
- elif action == 'permissions':
- if params.get( 'update_roles_button', False ):
- # The user clicked the Save button on the 'Associate With Roles' form
- permissions = {}
- for k, v in trans.app.model.Library.permitted_actions.items():
- in_roles = [ trans.app.model.Role.get( x ) for x in util.listify( kwd.get( k + '_in', [] ) ) ]
- permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
- trans.app.security_agent.set_all_library_permissions( library_item, permissions )
- library_item.refresh()
- msg = "Permissions updated for information template '%s'" % library_item.name
- return trans.response.send_redirect( web.url_for( controller='library',
- action='info_template',
- library_id=library_id,
- id=id,
- permissions=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( '/library/info_template_permissions.mako',
- liit=library_item,
library_id=library_id,
+ folder_id=folder_id,
+ ldda_id=ldda_id,
+ forms=get_all_forms( trans ),
msg=msg,
messagetype=messagetype )
@web.expose
- def library_item_info( self, trans, library_id, id=None, library_item_id=None, library_item_type=None, **kwd ):
+ def edit_template_info( self, trans, library_id, num_widgets, library_item_id=None, library_item_type=None, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
@@ -1257,8 +1149,6 @@
library_item = trans.app.model.LibraryDatasetDatasetAssociation.get( library_item_id )
# This response_action method requires a folder_id
folder_id = library_item.library_dataset.folder.id
- elif library_item_type == 'library_item_info_elememt':
- library_item = trans.app.model.LibraryItemInfoElement.get( library_item_id )
else:
msg = "Invalid library item type ( %s ) specified, id ( %s )" % ( str( library_item_type ), str( library_item_id ) )
return trans.response.send_redirect( web.url_for( controller='library',
@@ -1266,104 +1156,20 @@
id=library_id,
msg=util.sanitize_text( msg ),
messagetype='error' ) )
- if params.get( 'new_info', False ):
- if library_item:
- if params.get( 'create_new_info_button', False ):
- library_item_info_template_id = params.get( 'library_item_info_template_id', None )
- library_item_info_template = trans.app.model.LibraryItemInfoTemplate.get( int( library_item_info_template_id ) )
- # Make sure at least 1 template field is filled in
- # TODO: Eventually we'll enhance templates to allow for required and optional fields.
- proceed = False
- for template_element in library_item_info_template.elements:
- if params.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None ):
- proceed = True
- break
- if not proceed:
- msg = "At least 1 of the fields must be completed."
- return trans.response.send_redirect( web.url_for( controller='admin',
- action=library_item_type,
- id=library_item.id,
- library_id=library_id,
- folder_id=folder_id,
- edit_info=True,
- msg=util.sanitize_text( msg ),
- messagetype='error' ) )
- user = trans.get_user()
- library_item_info = trans.app.model.LibraryItemInfo( user=user )
- library_item_info.library_item_info_template = library_item_info_template
- library_item_info.flush()
- trans.app.security_agent.copy_library_permissions( library_item_info_template, library_item_info )
- for template_element in library_item_info_template.elements:
- info_element_value = params.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None )
- info_element = trans.app.model.LibraryItemInfoElement()
- info_element.contents = info_element_value
- info_element.library_item_info_template_element = template_element
- info_element.library_item_info = library_item_info
- info_element.flush()
- info_association_class = None
- for item_class, permission_class, info_association_class in trans.app.security_agent.library_item_assocs:
- if isinstance( library_item, item_class ):
- break
- if info_association_class:
- library_item_info_association = info_association_class( user=user )
- library_item_info_association.set_library_item( library_item )
- library_item_info_association.library_item_info = library_item_info
- library_item_info_association.flush()
- else:
- raise 'Invalid class (%s) specified for library_item (%s)' % ( library_item.__class__, library_item.__class__.__name__ )
- msg = 'The information has been saved.'
- return trans.response.send_redirect( web.url_for( controller='library',
- action=library_item_type,
- id=library_item.id,
- library_id=library_id,
- folder_id=folder_id,
- edit_info=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( "/library/new_info.mako",
- library_id=library_id,
- library_item=library_item,
- library_item_type=library_item_type,
- msg=msg,
- messagetype=messagetype )
- elif params.get( 'edit_info', False ):
- if params.get( 'edit_info_button', False ):
- ids = util.listify( id )
- for id in ids:
- library_item_info_element = trans.app.model.LibraryItemInfoElement.get( int( id ) )
- new_contents = util.restore_text( params.get( ( 'info_element_%s' % id ), '' ) )
- library_item_info_element.contents = new_contents
- library_item_info_element.flush()
- msg = 'The information has been updated.'
- return trans.response.send_redirect( web.url_for( controller='library',
- action=library_item_type,
- id=library_item.id,
- library_id=library_id,
- folder_id=folder_id,
- edit_info=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- elif params.get( 'permissions', False ):
- if params.get( 'update_roles_button', False ):
- permissions = {}
- for k, v in trans.app.model.Library.permitted_actions.items():
- in_roles = [ trans.app.model.Role.get( x ) for x in util.listify( kwd.get( k + '_in', [] ) ) ]
- permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
- trans.app.security_agent.set_all_library_permissions( library_item.library_item_info, permissions )
- library_item.library_item_info.refresh()
- library_item.refresh()
- msg = "Permissions updated for field '%s'" % library_item.library_item_info_template_element.name
- return trans.response.send_redirect( web.url_for( controller='library',
- action='library_item_info',
- library_id=library_id,
- id=id,
- library_item_id=library_item_id,
- library_item_type=library_item_type,
- permissions=True,
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
- return trans.fill_template( '/library/info_permissions.mako',
- library_item_info_element=library_item,
- library_id=library_id,
- msg=msg,
- messagetype=messagetype )
+ # Save updated template field contents
+ field_values = []
+ for index in range( int( num_widgets ) ):
+ field_values.append( util.restore_text( params.get( 'field_%i' % ( index ), '' ) ) )
+ info = library_item.info_association[0].info
+ form_values = trans.app.model.FormValues.get( info.id )
+ form_values.content = field_values
+ form_values.flush()
+ msg = 'The information has been updated.'
+ return trans.response.send_redirect( web.url_for( controller='library',
+ action=library_item_type,
+ id=library_item.id,
+ library_id=library_id,
+ folder_id=folder_id,
+ edit_info=True,
+ msg=util.sanitize_text( msg ),
+ messagetype='done' ) )
diff -r eb09beda047d -r 50ce3d8388f8 lib/galaxy/web/controllers/library_dataset.py
--- a/lib/galaxy/web/controllers/library_dataset.py Fri Aug 07 12:55:07 2009 -0400
+++ b/lib/galaxy/web/controllers/library_dataset.py Fri Aug 07 16:11:14 2009 -0400
@@ -12,9 +12,9 @@
os.unlink( filename )
except:
log.exception( 'failure removing temporary file: %s' % filename )
- def add_file( self, trans, folder_id, file_obj, name, file_format, dbkey, roles, info='no info', space_to_tab=False,
- replace_dataset=None, library_item_info_template=None, template_elements={}, message=None ):
- folder = trans.app.model.LibraryFolder.get( folder_id )
+ def add_file( self, trans, folder, file_obj, name, file_format, dbkey, roles,
+ info='no info', space_to_tab=False, replace_dataset=None,
+ template=None, template_field_contents=[], message=None ):
data_type = None
line_count = 0
temp_name, is_multi_byte = sniff.stream_to_file( file_obj )
@@ -142,24 +142,17 @@
folder.flush()
library_dataset.library_dataset_dataset_association_id = ldda.id
library_dataset.flush()
- # Handle any templates included in the upload form
- if library_item_info_template:
- user = trans.get_user()
- library_item_info = trans.app.model.LibraryItemInfo( user=user )
- library_item_info.library_item_info_template = library_item_info_template
- library_item_info.flush()
- trans.app.security_agent.copy_library_permissions( library_item_info_template, library_item_info )
- for template_element in library_item_info_template.elements:
- info_element_value = template_elements.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None )
- info_element = trans.app.model.LibraryItemInfoElement()
- info_element.contents = info_element_value
- info_element.library_item_info_template_element = template_element
- info_element.library_item_info = library_item_info
- info_element.flush()
- library_item_info_association = trans.app.model.LibraryDatasetDatasetInfoAssociation( user=user )
- library_item_info_association.set_library_item( ldda )
- library_item_info_association.library_item_info = library_item_info
- library_item_info_association.flush()
+ # Handle template included in the upload form, if any
+ if template and template_field_contents:
+ # Since information templates are inherited, the template fields can be displayed on the upload form.
+ # If the user has added field contents, we'll need to create a new form_values and info_association
+ # for the new library_dataset_dataset_association object.
+ # Create a new FormValues object, using the template we previously retrieved
+ form_values = trans.app.model.FormValues( template, template_field_contents )
+ form_values.flush()
+ # Create a new info_association between the current ldda and form_values
+ info_association = trans.app.model.LibraryDatasetDatasetInfoAssociation( ldda, template, form_values )
+ info_association.flush()
# If roles were selected upon upload, restrict access to the Dataset to those roles
if roles:
for role in roles:
@@ -207,22 +200,19 @@
replace_id = None
message = params.get( 'message', '' )
upload_option = params.get( 'upload_option', 'upload_file' )
- # Handle any templates included in the upload form by building a dictionary of info elements to send to add_file
- template_elements = {}
- library_item_info_template = None
- library_item_info_template_id = params.get( 'library_item_info_template_id', None )
- if library_item_info_template_id:
- library_item_info_template = trans.app.model.LibraryItemInfoTemplate.get( int( library_item_info_template_id ) )
- for template_element in library_item_info_template.elements:
- # Make sure at least 1 template field is filled in
- # TODO: Eventually we'll enhance templates to allow for required and optional fields.
- if params.get( "info_element_%s_%s" % ( library_item_info_template.id, template_element.id ), None ):
- for template_element in library_item_info_template.elements:
- key = "info_element_%s_%s" % ( library_item_info_template.id, template_element.id )
- value = params.get( key, None )
- if value:
- template_elements[ key ] = value
err_redirect = False
+ # See if we have any template field contents
+ template_field_contents = []
+ template = None
+ folder = trans.app.model.LibraryFolder.get( folder_id )
+ info_association = folder.get_info_association()
+ if info_association:
+ template = info_association.template
+ for field_index in range( len( template.fields ) ):
+ field_name = 'field_%i' % field_index
+ if params.get( field_name, False ):
+ field_value = util.restore_text( params.get( field_name, '' ) )
+ template_field_contents.append( field_value )
if upload_option == 'upload_file' and data_file == '' and url_paste == '':
msg = 'Select a file, enter a URL or enter text'
err_redirect = True
@@ -263,7 +253,7 @@
file_name = file_name.split( '/' )[-1]
try:
created_ldda = self.add_file( trans,
- folder_id,
+ folder,
data_file.file,
file_name,
file_format,
@@ -272,8 +262,8 @@
info="uploaded file",
space_to_tab=space_to_tab,
replace_dataset=replace_dataset,
- library_item_info_template=library_item_info_template,
- template_elements=template_elements,
+ template=template,
+ template_field_contents=template_field_contents,
message=message )
created_ldda_ids = str( created_ldda.id )
except Exception, e:
@@ -291,7 +281,7 @@
name_set_from_line = True
try:
created_ldda = self.add_file( trans,
- folder_id,
+ folder,
urllib.urlopen( line ),
line,
file_format,
@@ -300,8 +290,8 @@
info="uploaded url",
space_to_tab=space_to_tab,
replace_dataset=replace_dataset,
- library_item_info_template=library_item_info_template,
- template_elements=template_elements,
+ template=template,
+ template_field_contents=template_field_contents,
message=message )
created_ldda_ids = '%s,%s' % ( created_ldda_ids, str( created_ldda.id ) )
except Exception, e:
@@ -317,7 +307,7 @@
1
0
10 Aug '09
details: http://www.bx.psu.edu/hg/galaxy/rev/eb09beda047d
changeset: 2549:eb09beda047d
user: Dan Blankenberg <dan(a)bx.psu.edu>
date: Fri Aug 07 12:55:07 2009 -0400
description:
Have metadata editing tests wait for completion of file conversion before editing resultant dataset's metadata.
1 file(s) affected in this change:
test/base/twilltestcase.py
diffs (11 lines):
diff -r b8b7b6c67839 -r eb09beda047d test/base/twilltestcase.py
--- a/test/base/twilltestcase.py Fri Aug 07 11:14:03 2009 -0400
+++ b/test/base/twilltestcase.py Fri Aug 07 12:55:07 2009 -0400
@@ -425,6 +425,7 @@
tc.fv( 'convert_data', 'target_type', target_type )
tc.submit( 'convert_data' )
self.check_page_for_string( 'The file conversion of Convert BED to GFF on data' )
+ self.wait() #wait for the format convert tool to finish before returning
self.home()
def change_datatype( self, hda_id, datatype ):
"""Change format of history_dataset_association"""
1
0
details: http://www.bx.psu.edu/hg/galaxy/rev/e97c45040b3e
changeset: 2547:e97c45040b3e
user: James Taylor <james(a)jamestaylor.org>
date: Thu Aug 06 16:04:52 2009 -0400
description:
Merge.
1 file(s) affected in this change:
static/june_2007_style/blue/tiny_arror_right.png
diffs (103 lines):
diff -r 93dda9c3ded3 -r e97c45040b3e lib/galaxy/web/controllers/history.py
--- a/lib/galaxy/web/controllers/history.py Thu Aug 06 10:48:14 2009 -0400
+++ b/lib/galaxy/web/controllers/history.py Thu Aug 06 16:04:52 2009 -0400
@@ -47,8 +47,8 @@
attach_popup=True ),
DatasetsByStateColumn( "Datasets (by state)", ncells=4 ),
StatusColumn( "Status", attach_popup=False ),
- grids.GridColumn( "Age", key="create_time", format=time_ago ),
- grids.GridColumn( "Last update", key="update_time", format=time_ago ),
+ grids.GridColumn( "Created", key="create_time", format=time_ago ),
+ grids.GridColumn( "Last Updated", key="update_time", format=time_ago ),
# Valid for filtering but invisible
grids.GridColumn( "Deleted", key="deleted", visible=False )
]
diff -r 93dda9c3ded3 -r e97c45040b3e lib/galaxy/web/framework/helpers/__init__.py
--- a/lib/galaxy/web/framework/helpers/__init__.py Thu Aug 06 10:48:14 2009 -0400
+++ b/lib/galaxy/web/framework/helpers/__init__.py Thu Aug 06 16:04:52 2009 -0400
@@ -3,10 +3,16 @@
pkg_resources.require( "WebHelpers" )
from webhelpers import *
-from datetime import datetime
+from datetime import datetime, timedelta
+# If the date is more than one week ago, then display the actual date instead of in words
def time_ago( x ):
- return date.distance_of_time_in_words( x, datetime.utcnow() )
+ delta = timedelta(weeks=1)
+
+ if (datetime.utcnow() - x) > delta: # Greater than a week difference
+ return x.strftime("%b %d, %Y")
+ else:
+ return date.distance_of_time_in_words( x, datetime.utcnow() ) + " ago"
def iff( a, b, c ):
if a:
diff -r 93dda9c3ded3 -r e97c45040b3e static/images/overview_arrows.png
Binary file static/images/overview_arrows.png has changed
diff -r 93dda9c3ded3 -r e97c45040b3e static/images/resizable.png
Binary file static/images/resizable.png has changed
diff -r 93dda9c3ded3 -r e97c45040b3e static/june_2007_style/blue/tiny_arror_right.png
Binary file static/june_2007_style/blue/tiny_arror_right.png has changed
diff -r 93dda9c3ded3 -r e97c45040b3e templates/base_panels.mako
--- a/templates/base_panels.mako Thu Aug 06 10:48:14 2009 -0400
+++ b/templates/base_panels.mako Thu Aug 06 16:04:52 2009 -0400
@@ -115,6 +115,8 @@
## Masthead
<%def name="masthead()">
+ <div style="position: absolute; left: 0px; width: 100%; text-align: center">
+
<div class="title" style="float: left;">
<a href="/">
<img border="0" src="${h.url_for('/static/images/galaxyIcon_noText.png')}" style="width: 26px; vertical-align: top;">
@@ -124,8 +126,6 @@
%endif
</a>
</div>
-
- <div style="z-index: -1; position: absolute; left: 0px; width: 100%; text-align: center">
<table class="tab-group" border="0" cellspacing="0" style="margin: auto;">
<tr>
diff -r 93dda9c3ded3 -r e97c45040b3e templates/workflow/editor.mako
--- a/templates/workflow/editor.mako Thu Aug 06 10:48:14 2009 -0400
+++ b/templates/workflow/editor.mako Thu Aug 06 16:04:52 2009 -0400
@@ -119,6 +119,19 @@
workflow.fit_canvas_to_nodes();
scroll_to_nodes();
canvas_manager.draw_overview();
+ });
+
+ /* Lets the viewport be toggled visible and invisible, adjusting the arrows accordingly */
+ $("#close-viewport").click( function() {
+ if ( $("#overview-border").css("right") == "0px" ) {
+ $("#overview-border").css("right", "20000px");
+ $("#close-viewport").css("background-position", "12px 0px");
+
+ } else {
+ $("#overview-border").css("right", "0px");
+ $("#close-viewport").css("background-position", "0px 0px");
+ }
+
});
// Unload handler
@@ -629,7 +642,7 @@
<div id="canvas-viewport" style="width: 100%; height: 100%; position: absolute; overflow: hidden; background: #EEEEEE; background: white url(${h.url_for('/static/images/light_gray_grid.gif')}) repeat;">
<div id="canvas-container" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
- <div id="overview-border" style="position: absolute; width: 150px; height: 150px; right: 0; bottom: 0; border-top: solid gray 1px; border-left: solid grey 1px; padding: 7px 0 0 7px; background: #EEEEEE; z-index: 50000; overflow: hidden;">
+ <div id="overview-border" style="position: absolute; width: 150px; height: 150px; right: 0px; bottom: 0px; border-top: solid gray 1px; border-left: solid grey 1px; padding: 7px 0 0 7px; background: #EEEEEE no-repeat url(${h.url_for('/static/images/resizable.png')}); z-index: 20000; overflow: hidden; max-width: 300px; max-height: 300px; min-width: 50px; min-height: 50px">
<div style="position: relative; overflow: hidden; width: 100%; height: 100%; border-top: solid gray 1px; border-left: solid grey 1px;">
<div id="overview" style="position: absolute;">
<canvas width="0" height="0" style="background: white; width: 100%; height: 100%;" id="overview-canvas"></canvas>
@@ -637,6 +650,7 @@
</div>
</div>
</div>
+ <div id="close-viewport" style="border-left: 1px solid #999; border-top: 1px solid #999; background: #ddd url(${h.url_for('/static/images/overview_arrows.png')}); position: absolute; right: 0px; bottom: 0px; width: 12px; height: 12px; z-index: 25000;"></div>
</div>
</%def>
1
0
10 Aug '09
details: http://www.bx.psu.edu/hg/galaxy/rev/b8b7b6c67839
changeset: 2548:b8b7b6c67839
user: Dan Blankenberg <dan(a)bx.psu.edu>
date: Fri Aug 07 11:14:03 2009 -0400
description:
Prevent metadata or datatype from being changed by the user when the dataset is part of a running/queued job.
1 file(s) affected in this change:
lib/galaxy/web/controllers/root.py
diffs (87 lines):
diff -r e97c45040b3e -r b8b7b6c67839 lib/galaxy/web/controllers/root.py
--- a/lib/galaxy/web/controllers/root.py Thu Aug 06 16:04:52 2009 -0400
+++ b/lib/galaxy/web/controllers/root.py Fri Aug 07 11:14:03 2009 -0400
@@ -226,7 +226,14 @@
@web.expose
def edit(self, trans, id=None, hid=None, **kwd):
- """Returns data directly into the browser. Sets the mime-type according to the extension"""
+ """Allows user to modify parameters of an HDA."""
+ def __ok_to_edit_metadata( dataset_id ):
+ #prevent modifying metadata when dataset is queued or running as input/output
+ #This code could be more efficient, i.e. by using mappers, but to prevent slowing down loading a History panel, we'll leave the code here for now
+ for job_to_dataset_association in self.app.model.JobToInputDatasetAssociation.filter_by( dataset_id=dataset_id ).all() + self.app.model.JobToOutputDatasetAssociation.filter_by( dataset_id=dataset_id ).all():
+ if job_to_dataset_association.job.state not in [ job_to_dataset_association.job.states.OK, job_to_dataset_association.job.states.ERROR, job_to_dataset_association.job.states.DELETED ]:
+ return False
+ return True
if hid is not None:
history = trans.get_history()
# TODO: hid handling
@@ -248,6 +255,9 @@
if params.change:
# The user clicked the Save button on the 'Change data type' form
if data.datatype.allow_datatype_change and trans.app.datatypes_registry.get_datatype_by_extension( params.datatype ).allow_datatype_change:
+ #prevent modifying datatype when dataset is queued or running as input/output
+ if not __ok_to_edit_metadata( data.id ):
+ return trans.show_error_message( "This dataset is currently being used as input or output. You cannot change datatype until the jobs have completed or you have canceled them." )
trans.app.datatypes_registry.change_datatype( data, params.datatype )
trans.app.model.flush()
else:
@@ -256,27 +266,32 @@
# The user clicked the Save button on the 'Edit Attributes' form
data.name = params.name
data.info = params.info
-
- # The following for loop will save all metadata_spec items
- for name, spec in data.datatype.metadata_spec.items():
- if spec.get("readonly"):
- continue
- optional = params.get("is_"+name, None)
- other = params.get("or_"+name, None)
- if optional and optional == 'true':
- # optional element... == 'true' actually means it is NOT checked (and therefore omitted)
- setattr(data.metadata, name, None)
- else:
- if other:
- setattr( data.metadata, name, other )
+ msg = ''
+ if __ok_to_edit_metadata( data.id ):
+ # The following for loop will save all metadata_spec items
+ for name, spec in data.datatype.metadata_spec.items():
+ if spec.get("readonly"):
+ continue
+ optional = params.get("is_"+name, None)
+ other = params.get("or_"+name, None)
+ if optional and optional == 'true':
+ # optional element... == 'true' actually means it is NOT checked (and therefore omitted)
+ setattr(data.metadata, name, None)
else:
- setattr( data.metadata, name, spec.unwrap( params.get (name, None) ) )
-
- data.datatype.after_edit( data )
+ if other:
+ setattr( data.metadata, name, other )
+ else:
+ setattr( data.metadata, name, spec.unwrap( params.get (name, None) ) )
+ data.datatype.after_edit( data )
+ else:
+ msg = ' (Metadata could not be changed because this dataset is currently being used as input or output. You must cancel or wait for these jobs to complete before changing metadata.)'
trans.app.model.flush()
- return trans.show_ok_message( "Attributes updated", refresh_frames=['history'] )
+ return trans.show_ok_message( "Attributes updated%s" % msg, refresh_frames=['history'] )
elif params.detect:
# The user clicked the Auto-detect button on the 'Edit Attributes' form
+ #prevent modifying metadata when dataset is queued or running as input/output
+ if not __ok_to_edit_metadata( data.id ):
+ return trans.show_error_message( "This dataset is currently being used as input or output. You cannot change metadata until the jobs have completed or you have canceled them." )
for name, spec in data.metadata.spec.items():
# We need to be careful about the attributes we are resetting
if name not in [ 'name', 'info', 'dbkey' ]:
@@ -314,6 +329,7 @@
# returns the metadata dbkey unless it is None, in which
# case it resorts to the old dbkey. Setting the dbkey
# sets it properly in the metadata
+ #### This is likely no longer required, since the dbkey exists entirely within metadata (the old_dbkey field is gone): REMOVE ME?
data.metadata.dbkey = data.dbkey
# let's not overwrite the imported datatypes module with the variable datatypes?
# the built-in 'id' is overwritten in lots of places as well
1
0
10 Aug '09
details: http://www.bx.psu.edu/hg/galaxy/rev/2489f9da0d29
changeset: 2545:2489f9da0d29
user: Kanwei Li <kanwei(a)gmail.com>
date: Thu Aug 06 15:19:02 2009 -0400
description:
Fixed masthead disappearing in older firefox
1 file(s) affected in this change:
templates/base_panels.mako
diffs (21 lines):
diff -r 73ac2b7cad26 -r 2489f9da0d29 templates/base_panels.mako
--- a/templates/base_panels.mako Thu Aug 06 14:43:51 2009 -0400
+++ b/templates/base_panels.mako Thu Aug 06 15:19:02 2009 -0400
@@ -115,6 +115,8 @@
## Masthead
<%def name="masthead()">
+ <div style="position: absolute; left: 0px; width: 100%; text-align: center">
+
<div class="title" style="float: left;">
<a href="/">
<img border="0" src="${h.url_for('/static/images/galaxyIcon_noText.png')}" style="width: 26px; vertical-align: top;">
@@ -124,8 +126,6 @@
%endif
</a>
</div>
-
- <div style="z-index: -1; position: absolute; left: 0px; width: 100%; text-align: center">
<table class="tab-group" border="0" cellspacing="0" style="margin: auto;">
<tr>
1
0
details: http://www.bx.psu.edu/hg/galaxy/rev/397800eff312
changeset: 2546:397800eff312
user: Kanwei Li <kanwei(a)gmail.com>
date: Thu Aug 06 15:25:18 2009 -0400
description:
Merging trunk
7 file(s) affected in this change:
templates/base_panels.mako
templates/dataset/errors.tmpl
templates/dataset/validation.tmpl
templates/requests/select_request_type.mako
test-data/s2fq_out1.tabular
test-data/s2fq_out2.tabular
test-data/s2fq_out3.tabular
diffs (truncated from 6105 to 3000 lines):
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/model/__init__.py Thu Aug 06 15:25:18 2009 -0400
@@ -1121,15 +1121,18 @@
self.content = content
class Request( object ):
+ states = Bunch( UNSUBMITTED = 'Unsubmitted',
+ SUBMITTED = 'Submitted',
+ COMPLETE = 'Complete')
def __init__(self, name=None, desc=None, request_type=None, user=None,
- form_values=None, library=None, submitted=False):
+ form_values=None, library=None, state=False):
self.name = name
self.desc = desc
self.type = request_type
self.values = form_values
self.user = user
self.library = library
- self.submitted = submitted
+ self.state = state
self.samples_list = []
def add_sample(self, sample_name=None, sample_desc=None, sample_values=None):
# create a form_values row
@@ -1151,6 +1154,18 @@
if s.name == sample_name:
return s
return False
+ def submitted(self):
+ if self.state == self.states.SUBMITTED:
+ return True
+ return False
+ def unsubmitted(self):
+ if self.state == self.states.UNSUBMITTED:
+ return True
+ return False
+ def complete(self):
+ if self.state == self.states.COMPLETE:
+ return True
+ return False
class RequestType( object ):
def __init__(self, name=None, desc=None, request_form=None, sample_form=None):
@@ -1160,12 +1175,12 @@
self.sample_form = sample_form
class Sample( object ):
- def __init__(self, name=None, desc=None, request=None, form_values=None):
+ def __init__(self, name=None, desc=None, request=None, form_values=None, bar_code=None):
self.name = name
self.desc = desc
self.request = request
self.values = form_values
-
+ self.bar_code = bar_code
def current_state(self):
return self.events[0].state
@@ -1180,6 +1195,37 @@
self.sample = sample
self.state = sample_state
self.comment = comment
+
+class UserAddress( object ):
+ def __init__(self, user=None, desc=None, name=None, institution=None,
+ address=None, city=None, state=None, postal_code=None,
+ country=None, phone=None):
+ self.user = user
+ self.desc = desc
+ self.name = name
+ self.institution = institution
+ self.address = address
+ self.city = city
+ self.state = state
+ self.postal_code = postal_code
+ self.country = country
+ self.phone = phone
+ def display(self):
+ return self.name+'<br/>'+ \
+ self.institution+'<br/>'+ \
+ self.address+'<br/>'+ \
+ self.city+' '+self.state+' '+self.postal_code+'<br/>'+ \
+ self.country+'<br/>'+ \
+ 'Phone: '+self.phone
+ def get_html(self):
+ return self.name+'<br/>'+ \
+ self.institution+'<br/>'+ \
+ self.address+'<br/>'+ \
+ self.city+' '+self.state+' '+self.postal_code+'<br/>'+ \
+ self.country+'<br/>'+ \
+ 'Phone: '+self.phone
+
+
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/model/mapping.py
--- a/lib/galaxy/model/mapping.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/model/mapping.py Thu Aug 06 15:25:18 2009 -0400
@@ -46,7 +46,24 @@
Column( "external", Boolean, default=False ),
Column( "deleted", Boolean, index=True, default=False ),
Column( "purged", Boolean, index=True, default=False ) )
-
+
+UserAddress.table = Table( "user_address", metadata,
+ Column( "id", Integer, primary_key=True),
+ Column( "create_time", DateTime, default=now ),
+ Column( "update_time", DateTime, default=now, onupdate=now ),
+ Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
+ Column( "desc", TrimmedString( 255 )),
+ Column( "name", TrimmedString( 255 ), nullable=False),
+ Column( "institution", TrimmedString( 255 )),
+ Column( "address", TrimmedString( 255 ), nullable=False),
+ Column( "city", TrimmedString( 255 ), nullable=False),
+ Column( "state", TrimmedString( 255 ), nullable=False),
+ Column( "postal_code", TrimmedString( 255 ), nullable=False),
+ Column( "country", TrimmedString( 255 ), nullable=False),
+ Column( "phone", TrimmedString( 255 )),
+ Column( "deleted", Boolean, index=True, default=False ),
+ Column( "purged", Boolean, index=True, default=False ) )
+
History.table = Table( "history", metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
@@ -558,7 +575,8 @@
Column( "name", TrimmedString( 255 ), nullable=False ),
Column( "desc", TEXT ),
Column( "request_form_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
- Column( "sample_form_id", Integer, ForeignKey( "form_definition.id" ), index=True ) )
+ Column( "sample_form_id", Integer, ForeignKey( "form_definition.id" ), index=True ),
+ Column( "deleted", Boolean, index=True, default=False ) )
FormValues.table = Table('form_values', metadata,
Column( "id", Integer, primary_key=True),
@@ -577,8 +595,15 @@
Column( "request_type_id", Integer, ForeignKey( "request_type.id" ), index=True ),
Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
Column( "library_id", Integer, ForeignKey( "library.id" ), index=True ),
- Column( "submitted", Boolean, index=True, default=False ),
+ Column( "state", TrimmedString( 255 ), index=True ),
Column( "deleted", Boolean, index=True, default=False ) )
+
+RequestState_table = Table('request_state', metadata,
+ Column( "id", Integer, primary_key=True),
+ Column( "create_time", DateTime, default=now ),
+ Column( "update_time", DateTime, default=now, onupdate=now ),
+ Column( "name", TrimmedString( 255 ), nullable=False ),
+ Column( "desc", TEXT ))
Sample.table = Table('sample', metadata,
Column( "id", Integer, primary_key=True),
@@ -615,13 +640,14 @@
# relationships between the model objects.
assign_mapper( context, Sample, Sample.table,
- properties=dict( events=relation( SampleEvent, backref="sample",
- order_by=desc(SampleEvent.table.c.update_time) ),
- values=relation( FormValues,
- primaryjoin=( Sample.table.c.form_values_id == FormValues.table.c.id ) ),
- request=relation( Request,
- primaryjoin=( Sample.table.c.request_id == Request.table.c.id ) ),
- ) )
+ properties=dict(
+ events=relation( SampleEvent, backref="sample",
+ order_by=desc(SampleEvent.table.c.update_time) ),
+ values=relation( FormValues,
+ primaryjoin=( Sample.table.c.form_values_id == FormValues.table.c.id ) ),
+ request=relation( Request,
+ primaryjoin=( Sample.table.c.request_id == Request.table.c.id ) ),
+ ) )
assign_mapper( context, FormValues, FormValues.table,
properties=dict( form_definition=relation( FormDefinition,
@@ -673,6 +699,15 @@
assign_mapper( context, SampleState, SampleState.table,
properties=None )
+
+assign_mapper( context, UserAddress, UserAddress.table,
+ properties=dict(
+ user=relation( User,
+ primaryjoin=( UserAddress.table.c.user_id == User.table.c.id ),
+ backref='addresses',
+ order_by=desc(UserAddress.table.c.update_time)),
+ ) )
+
assign_mapper( context, ValidationError, ValidationError.table )
@@ -749,7 +784,9 @@
galaxy_sessions=relation( GalaxySession, order_by=desc( GalaxySession.table.c.update_time ) ),
stored_workflow_menu_entries=relation( StoredWorkflowMenuEntry, backref="user",
cascade="all, delete-orphan",
- collection_class=ordering_list( 'order_index' ) )
+ collection_class=ordering_list( 'order_index' ) ),
+# addresses=relation( UserAddress,
+# primaryjoin=( User.table.c.id == UserAddress.table.c.user_id ) )
) )
assign_mapper( context, Group, Group.table,
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/model/migrate/versions/0009_request_table.py
--- a/lib/galaxy/model/migrate/versions/0009_request_table.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0009_request_table.py Thu Aug 06 15:25:18 2009 -0400
@@ -32,7 +32,7 @@
col.create( Request_table )
assert col is Request_table.c.submitted
except Exception, e:
- log.debug( "Adding column 'submitted' to submitted table failed: %s" % ( str( e ) ) )
+ log.debug( "Adding column 'submitted' to request table failed: %s" % ( str( e ) ) )
# Add 1 column to the sample table
try:
@@ -46,7 +46,7 @@
col.create( Sample_table )
assert col is Sample_table.c.bar_code
except Exception, e:
- log.debug( "Adding column 'bar_code' to submitted table failed: %s" % ( str( e ) ) )
+ log.debug( "Adding column 'bar_code' to sample table failed: %s" % ( str( e ) ) )
def downgrade():
pass
\ No newline at end of file
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/model/migrate/versions/0012_user_address.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/galaxy/model/migrate/versions/0012_user_address.py Thu Aug 06 15:25:18 2009 -0400
@@ -0,0 +1,118 @@
+from sqlalchemy import *
+from sqlalchemy.orm import *
+from sqlalchemy.exceptions import *
+from migrate import *
+from migrate.changeset import *
+
+import datetime
+now = datetime.datetime.utcnow
+
+import sys, logging
+log = logging.getLogger( __name__ )
+log.setLevel(logging.DEBUG)
+handler = logging.StreamHandler( sys.stdout )
+format = "%(name)s %(levelname)s %(asctime)s %(message)s"
+formatter = logging.Formatter( format )
+handler.setFormatter( formatter )
+log.addHandler( handler )
+
+# Need our custom types, but don't import anything else from model
+from galaxy.model.custom_types import *
+
+metadata = MetaData( migrate_engine )
+db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) )
+
+
+UserAddress_table = Table( "user_address", metadata,
+ Column( "id", Integer, primary_key=True),
+ Column( "create_time", DateTime, default=now ),
+ Column( "update_time", DateTime, default=now, onupdate=now ),
+ Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
+ Column( "desc", TEXT),
+ Column( "name", TrimmedString( 255 ), nullable=False),
+ Column( "institution", TrimmedString( 255 )),
+ Column( "address", TrimmedString( 255 ), nullable=False),
+ Column( "city", TrimmedString( 255 ), nullable=False),
+ Column( "state", TrimmedString( 255 ), nullable=False),
+ Column( "postal_code", TrimmedString( 255 ), nullable=False),
+ Column( "country", TrimmedString( 255 ), nullable=False),
+ Column( "phone", TrimmedString( 255 )),
+ Column( "deleted", Boolean, index=True, default=False ),
+ Column( "purged", Boolean, index=True, default=False ) )
+
+#RequestState_table = Table('request_state', metadata,
+# Column( "id", Integer, primary_key=True),
+# Column( "create_time", DateTime, default=now ),
+# Column( "update_time", DateTime, default=now, onupdate=now ),
+# Column( "name", TrimmedString( 255 ), nullable=False ),
+# Column( "desc", TEXT ))
+
+def upgrade():
+ # Load existing tables
+ metadata.reflect()
+
+ # Add all of the new tables above
+ try:
+ UserAddress_table.create()
+ except Exception, e:
+ log.debug( "Creating user_address table failed: %s" % str( e ) )
+# try:
+# RequestState_table.create()
+# except Exception, e:
+# log.debug( "Creating request_state table failed: %s" % str( e ) )
+
+ # Add 1 column to the request_type table
+ try:
+ RequestType_table = Table( "request_type", metadata, autoload=True )
+ except NoSuchTableError:
+ RequestType_table = None
+ log.debug( "Failed loading table request_type" )
+ if RequestType_table:
+ try:
+ col = Column( "deleted", Boolean, index=True, default=False )
+ col.create( RequestType_table )
+ assert col is RequestType_table.c.deleted
+ except Exception, e:
+ log.debug( "Adding column 'deleted' to request_type table failed: %s" % ( str( e ) ) )
+
+ # Delete the submitted column
+ try:
+ Request_table = Table( "request", metadata, autoload=True )
+ except NoSuchTableError:
+ Request_table = None
+ log.debug( "Failed loading table request" )
+ if Request_table:
+ try:
+ Request_table.c.submitted.drop()
+ except Exception, e:
+ log.debug( "Deleting column 'submitted' to request table failed: %s" % ( str( e ) ) )
+ try:
+ col = Column( "state", TrimmedString( 255 ), index=True )
+ col.create( Request_table )
+ assert col is Request_table.c.state
+ except Exception, e:
+ log.debug( "Adding column 'state' to request table failed: %s" % ( str( e ) ) )
+#
+# # new column which points to the current state in the request_state table
+# try:
+# col = Column( "request_state_id", Integer, index=True )
+# col.create( Request_table )
+# assert col is Request_table.c.request_state_id
+# except Exception, e:
+# log.debug( "Adding column 'request_state_id' to request table failed: %s" % ( str( e ) ) )
+# # Add 1 foreign key constraint to the form_definition_current table
+# if RequestState_table and Request_table:
+# try:
+# cons = ForeignKeyConstraint( [Request_table.c.request_state_id],
+# [RequestState_table.c.id],
+# name='request_request_state_id_fk' )
+# # Create the constraint
+# cons.create()
+# except Exception, e:
+# log.debug( "Adding foreign key constraint 'request_request_state_id_fk' to table 'request' failed: %s" % ( str( e ) ) )
+
+
+def downgrade():
+ pass
+
+
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/tools/test.py
--- a/lib/galaxy/tools/test.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/tools/test.py Thu Aug 06 15:25:18 2009 -0400
@@ -25,7 +25,7 @@
for input_name, input_value in self.tool.inputs.items():
if isinstance( input_value, grouping.Conditional ) or isinstance( input_value, grouping.Repeat ):
self.__expand_grouping_for_data_input(name, value, extra, input_name, input_value)
- elif isinstance( self.tool.inputs[name], parameters.DataToolParameter ):
+ elif isinstance( self.tool.inputs[name], parameters.DataToolParameter ) and ( value, extra ) not in self.required_files:
self.required_files.append( ( value, extra ) )
except: pass
self.inputs.append( ( name, value, extra ) )
@@ -37,7 +37,7 @@
if name != grouping_value.test_param.name:
for case in grouping_value.cases:
for case_input_name, case_input_value in case.inputs.items():
- if case_input_name == name and isinstance( case_input_value, basic.DataToolParameter ):
+ if case_input_name == name and isinstance( case_input_value, basic.DataToolParameter ) and ( value, extra ) not in self.required_files:
self.required_files.append( ( value, extra ) )
return True
elif isinstance( case_input_value, grouping.Conditional ):
@@ -49,6 +49,6 @@
# with the same name ( "input2" ) is not yet supported in our test code ( the lat one added is the only
# one used ).
for input_name, input_value in grouping_value.inputs.items():
- if input_name == name and isinstance( input_value, basic.DataToolParameter ):
+ if input_name == name and isinstance( input_value, basic.DataToolParameter ) and ( value, extra ) not in self.required_files:
self.required_files.append( ( value, extra ) )
return True
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/admin.py
--- a/lib/galaxy/web/controllers/admin.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/admin.py Thu Aug 06 15:25:18 2009 -0400
@@ -2120,12 +2120,19 @@
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
+ show_filter = util.restore_text( params.get( 'show_filter', 'Active' ) )
forms = self._get_all_forms(trans, all_versions=True)
+ request_types_list = trans.app.model.RequestType.query().all()
+ if show_filter == 'All':
+ request_types = request_types_list
+ elif show_filter == 'Deleted':
+ request_types = [rt for rt in request_types_list if rt.deleted]
+ else:
+ request_types = [rt for rt in request_types_list if not rt.deleted]
return trans.fill_template( '/admin/requests/manage_request_types.mako',
- request_types=trans.app.model.RequestType.query().all(),
+ request_types=request_types,
forms=forms,
- deleted=False,
- show_deleted=False,
+ show_filter=show_filter,
msg=msg,
messagetype=messagetype )
@web.expose
@@ -2155,13 +2162,10 @@
forms=self._get_all_forms(trans, all_versions=False),
msg=msg,
messagetype='error')
- return trans.fill_template( '/admin/requests/manage_request_types.mako',
- request_types=trans.app.model.RequestType.query().all(),
- forms=self._get_all_forms(trans, all_versions=True),
- deleted=False,
- show_deleted=False,
- msg=msg,
- messagetype=messagetype )
+ return trans.response.send_redirect( web.url_for( controller='admin',
+ action='manage_request_types',
+ msg='Request type <b>%s</b> has been created' % st.name,
+ messagetype='done') )
elif params.get('edit', False) == 'True':
rt = trans.app.model.RequestType.get(int(util.restore_text( params.id )))
ss_list = trans.app.model.SampleState.filter(trans.app.model.SampleState.table.c.request_type_id == rt.id).all()
@@ -2197,8 +2201,8 @@
ss.delete()
ss.flush()
# unsubmitted state
- ss = trans.app.model.SampleState('Unsubmitted', 'Sample not yet submitted', rt)
- ss.flush()
+ #ss = trans.app.model.SampleState('Unsubmitted', 'Sample not yet submitted', rt)
+ ##ss.flush()
for i in range( num_states ):
name = util.restore_text( params.get( 'new_element_name_%i' % i, None ))
desc = util.restore_text( params.get( 'new_element_description_%i' % i, None ))
@@ -2206,3 +2210,31 @@
ss.flush()
msg = "The new request type named '%s' with %s state(s) has been created" % (rt.name, num_states)
return rt, msg
+
+ @web.expose
+ @web.require_admin
+ def delete_request_type( self, trans, **kwd ):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ rt = trans.app.model.RequestType.get(int(util.restore_text( params.request_type_id )))
+ rt.deleted = True
+ rt.flush()
+ return trans.response.send_redirect( web.url_for( controller='admin',
+ action='manage_request_types',
+ msg='Request type <b>%s</b> has been deleted' % rt.name,
+ messagetype='done') )
+
+ @web.expose
+ @web.require_admin
+ def undelete_request_type( self, trans, **kwd ):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ rt = trans.app.model.RequestType.get(int(util.restore_text( params.request_type_id )))
+ rt.deleted = False
+ rt.flush()
+ return trans.response.send_redirect( web.url_for( controller='admin',
+ action='manage_request_types',
+ msg='Request type <b>%s</b> has been deleted' % rt.name,
+ messagetype='done') )
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/dataset.py
--- a/lib/galaxy/web/controllers/dataset.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/dataset.py Thu Aug 06 15:25:18 2009 -0400
@@ -44,7 +44,7 @@
@web.expose
def errors( self, trans, id ):
dataset = model.HistoryDatasetAssociation.get( id )
- return trans.fill_template( "dataset/errors.tmpl", dataset=dataset )
+ return trans.fill_template( "dataset/errors.mako", dataset=dataset )
@web.expose
def stderr( self, trans, id ):
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/forms.py
--- a/lib/galaxy/web/controllers/forms.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/forms.py Thu Aug 06 15:25:18 2009 -0400
@@ -29,13 +29,19 @@
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- return self._show_forms_list(trans, msg, messagetype)
- def _show_forms_list(self, trans, msg, messagetype):
+ show_filter = params.get( 'show_filter', 'Active' )
+ return self._show_forms_list(trans, msg, messagetype, show_filter)
+ def _show_forms_list(self, trans, msg, messagetype, show_filter='Active'):
fdc_list = trans.app.model.FormDefinitionCurrent.query().all()
+ if show_filter == 'All':
+ forms_list = fdc_list
+ elif show_filter == 'Deleted':
+ forms_list = [form for form in fdc_list if form.deleted]
+ else:
+ forms_list = [form for form in fdc_list if not form.deleted]
return trans.fill_template( '/admin/forms/manage_forms.mako',
- fdc_list=fdc_list,
- deleted=False,
- show_deleted=False,
+ fdc_list=forms_list,
+ show_filter=show_filter,
msg=msg,
messagetype=messagetype )
def _get_all_forms(self, trans, all_versions=False):
@@ -73,7 +79,34 @@
self.num_add_fields = 0
fd, msg = self.__save_form(trans, fdc_id=None, **kwd)
self.__get_saved_form(fd)
- return self._show_forms_list(trans, msg, messagetype)
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='edit',
+ form_id=fd.id,
+ show_form=True) )
+ @web.expose
+ @web.require_admin
+ def delete( self, trans, **kwd ):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ fd = trans.app.model.FormDefinition.get(int(util.restore_text( params.form_id )))
+ fd.form_definition_current.deleted = True
+ fd.form_definition_current.flush()
+ return self._show_forms_list(trans,
+ msg='The form definition named %s is deleted.' % fd.name,
+ messagetype='done')
+ @web.expose
+ @web.require_admin
+ def undelete( self, trans, **kwd ):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ fd = trans.app.model.FormDefinition.get(int(util.restore_text( params.form_id )))
+ fd.form_definition_current.deleted = False
+ fd.form_definition_current.flush()
+ return self._show_forms_list(trans,
+ msg='The form definition named %s is undeleted.' % fd.name,
+ messagetype='done')
@web.expose
@web.require_admin
def edit( self, trans, **kwd ):
@@ -241,15 +274,22 @@
'''
import csv
fields = []
- reader = csv.reader(open(csv_file))
- for row in reader:
- options = row[5].split(',')
- fields.append({'label': row[0],
- 'helptext': row[1],
- 'visible': row[2],
- 'required': row[3],
- 'type': row[4],
- 'selectlist': options})
+ try:
+ reader = csv.reader(open(csv_file))
+ for row in reader:
+ options = row[5].split(',')
+ fields.append({'label': row[0],
+ 'helptext': row[1],
+ 'visible': row[2],
+ 'required': row[3],
+ 'type': row[4],
+ 'selectlist': options})
+ except:
+ return trans.response.send_redirect( web.url_for( controller='forms',
+ action='new',
+ status='error',
+ message='Error in importing <b>%s</b> file' % csv_file,
+ **kwd))
return fields
def __save_form(self, trans, fdc_id=None, **kwd):
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/requests.py
--- a/lib/galaxy/web/controllers/requests.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/requests.py Thu Aug 06 15:25:18 2009 -0400
@@ -14,6 +14,7 @@
title = "Sequencing Requests"
model_class = model.Request
default_sort_key = "-create_time"
+ show_filter = model.Request.states.UNSUBMITTED
columns = [
grids.GridColumn( "Name", key="name",
link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ),
@@ -23,18 +24,23 @@
link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ), ),
grids.GridColumn( "Type", key="request_type_id", method='get_request_type'),
grids.GridColumn( "Last update", key="update_time", format=time_ago ),
- grids.GridColumn( "Submitted", method='submitted'),
+ grids.GridColumn( "State", key='state'),
]
operations = [
-# grids.GridOperation( "Edit", allow_multiple=False, condition=( lambda item: not item.deleted ) ),
- grids.GridOperation( "Submit", allow_multiple=False, condition=( lambda item: not item.submitted ) )
-# grids.GridOperation( "Delete", condition=( lambda item: not item.deleted ) ),
-# grids.GridOperation( "Undelete", condition=( lambda item: item.deleted ) ),
+ grids.GridOperation( "Submit", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() and item.samples ) ),
+ grids.GridOperation( "Edit", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
+ grids.GridOperation( "Delete", allow_multiple=False, condition=( lambda item: not item.deleted and item.unsubmitted() ) ),
+ grids.GridOperation( "Undelete", allow_multiple=False, condition=( lambda item: item.deleted ) )
+
]
standard_filters = [
- grids.GridColumnFilter( "Active", args=dict( deleted=False ) ),
+ grids.GridColumnFilter( model.Request.states.UNSUBMITTED,
+ args=dict( state=model.Request.states.UNSUBMITTED, deleted=False ) ),
+ grids.GridColumnFilter( model.Request.states.SUBMITTED,
+ args=dict( state=model.Request.states.SUBMITTED, deleted=False ) ),
+ grids.GridColumnFilter( model.Request.states.COMPLETE, args=dict( state=model.Request.states.COMPLETE, deleted=False ) ),
grids.GridColumnFilter( "Deleted", args=dict( deleted=True ) ),
- grids.GridColumnFilter( "All", args=dict( deleted='All' ) )
+ grids.GridColumnFilter( "All", args={} )
]
#default_filter = dict( deleted=False )
def get_current_item( self, trans ):
@@ -45,10 +51,8 @@
return query.filter_by( user=trans.user )
def number_of_samples(self, trans, request):
return str(len(request.samples))
- def submitted(self, trans, request):
- if request.submitted:
- return 'Yes'
- return 'No'
+ def get_state(self, trans, request):
+ return request.state
@@ -73,6 +77,8 @@
List all request made by the current user
'''
status = message = None
+ self.request_grid.default_filter = dict(state=trans.app.model.Request.states.UNSUBMITTED,
+ deleted=False)
if 'operation' in kwargs:
operation = kwargs['operation'].lower()
if operation == "show_request":
@@ -81,6 +87,23 @@
elif operation == "submit":
id = trans.security.decode_id(kwargs['id'])
return self.__submit(trans, id)
+ elif operation == "delete":
+ id = trans.security.decode_id(kwargs['id'])
+ return self.__delete_request(trans, id)
+ elif operation == "undelete":
+ id = trans.security.decode_id(kwargs['id'])
+ return self.__undelete_request(trans, id)
+ elif operation == "edit":
+ id = trans.security.decode_id(kwargs['id'])
+ return self.__edit_request(trans, id)
+ if 'show_filter' in kwargs.keys():
+ if kwargs['show_filter'] == 'All':
+ self.request_grid.default_filter = {}
+ elif kwargs['show_filter'] == 'Deleted':
+ self.request_grid.default_filter = dict(deleted=True)
+ else:
+ self.request_grid.default_filter = dict(state=kwargs['show_filter'], deleted=False)
+ self.request_grid.show_filter = kwargs.get('show_filter', trans.app.model.Request.states.UNSUBMITTED)
# Render the list view
return self.request_grid( trans, template='/requests/grid.mako', **kwargs )
@@ -94,21 +117,19 @@
message="Invalid request ID",
**kwd) )
self.current_samples = []
+ self.edit_mode = False
for s in request.samples:
self.current_samples.append([s.name, s.values.content])
if add_sample:
self.current_samples.append(['Sample_%i' % (len(self.current_samples)+1),['' for field in request.type.sample_form.fields]])
- # selectfield of all samples
- copy_list = SelectField('copy_sample')
- copy_list.add_option('None', -1, selected=True)
- for i, s in enumerate(self.current_samples):
- copy_list.add_option(i+1, i)
self.details_state = 'Show request details'
return trans.fill_template( '/requests/show_request.mako',
request=request,
request_details=self.request_details(trans, id),
current_samples = self.current_samples,
- sample_copy=copy_list, details_state=self.details_state)
+ sample_copy=self.__copy_sample(),
+ details_state=self.details_state,
+ edit_mode=self.edit_mode)
def request_details(self, trans, id):
'''
Shows the request details
@@ -128,19 +149,37 @@
value=request.create_time,
helptext=''))
# library associated
- request_details.append(dict(label='Library',
- value=request.library.name,
- helptext='Associated library where the resultant \
- dataset will be stored'))
+ if request.library:
+ request_details.append(dict(label='Library',
+ value=request.library.name,
+ helptext='Associated library where the resultant \
+ dataset will be stored'))
+ else:
+ request_details.append(dict(label='Library',
+ value=None,
+ helptext='Associated library where the resultant \
+ dataset will be stored'))
+
# form fields
for index, field in enumerate(request.type.request_form.fields):
if field['required']:
req = 'Required'
else:
req = 'Optional'
- request_details.append(dict(label=field['label'],
- value=request.values.content[index],
- helptext=field['helptext']+' ('+req+')'))
+ if field['type'] == 'AddressField':
+ if request.values.content[index]:
+ request_details.append(dict(label=field['label'],
+ value=trans.app.model.UserAddress.get(int(request.values.content[index])).get_html(),
+ helptext=field['helptext']+' ('+req+')'))
+ else:
+ request_details.append(dict(label=field['label'],
+ value=None,
+ helptext=field['helptext']+' ('+req+')'))
+
+ else:
+ request_details.append(dict(label=field['label'],
+ value=request.values.content[index],
+ helptext=field['helptext']+' ('+req+')'))
return request_details
def __update_samples(self, request, **kwd):
@@ -156,6 +195,13 @@
for field_index in range(len(request.type.sample_form.fields)):
sample_values.append(util.restore_text( params.get( 'sample_%i_field_%i' % (sample_index, field_index), '' ) ))
self.current_samples.append([sample_name, sample_values])
+
+ def __copy_sample(self):
+ copy_list = SelectField('copy_sample')
+ copy_list.add_option('None', -1, selected=True)
+ for i, s in enumerate(self.current_samples):
+ copy_list.add_option(s[0], i)
+ return copy_list
@web.expose
def show_request(self, trans, **kwd):
params = util.Params( kwd )
@@ -169,7 +215,28 @@
status='error',
message="Invalid request ID",
**kwd) )
- if params.get('add_sample_button', False) == 'Add New':
+ if params.get('import_samples_button', False) == 'Import samples':
+ import traceback
+ try:
+ fname = params.get('import_samples', '')
+ import csv
+ reader = csv.reader(open(fname))
+ for row in reader:
+ self.current_samples.append([row[0], row[1:]])
+ return trans.fill_template( '/requests/show_request.mako',
+ request=request,
+ request_details=self.request_details(trans, request.id),
+ current_samples=self.current_samples,
+ sample_copy=self.__copy_sample(),
+ details_state=self.details_state,
+ edit_mode=self.edit_mode)
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message='Error in importing <b>%s</b> samples file' % fname,
+ **kwd))
+ elif params.get('add_sample_button', False) == 'Add New':
# save the all (saved+unsaved) sample info in 'current_samples'
self.__update_samples(request, **kwd)
# add an empty or filled sample
@@ -182,17 +249,14 @@
else:
self.current_samples.append([self.current_samples[src_sample_index][0]+'_%i' % (len(self.current_samples)+1),
[val for val in self.current_samples[src_sample_index][1]]])
- # selectfield of all samples
- copy_list = SelectField('copy_sample')
- copy_list.add_option('None', -1, selected=True)
- for i, s in enumerate(self.current_samples):
- copy_list.add_option(i+1, i)
return trans.fill_template( '/requests/show_request.mako',
request=request,
request_details=self.request_details(trans, request.id),
- current_samples = self.current_samples,
- sample_copy=copy_list, details_state=self.details_state)
- if params.get('save_samples_button', False) == 'Save':
+ current_samples=self.current_samples,
+ sample_copy=self.__copy_sample(),
+ details_state=self.details_state,
+ edit_mode=self.edit_mode)
+ elif params.get('save_samples_button', False) == 'Save':
# update current_samples
self.__update_samples(request, **kwd)
# check for duplicate sample names
@@ -211,35 +275,59 @@
msg = "This request has <b>%i</b> samples with the name <b>%s</b>.\nSamples belonging to a request must have unique names." % (count, sample_name)
break
if msg:
- copy_list = SelectField('copy_sample')
- copy_list.add_option('None', -1, selected=True)
- for i, s in enumerate(self.current_samples):
- copy_list.add_option(i+1, i)
return trans.fill_template( '/requests/show_request.mako',
request=request,
request_details=self.request_details(trans, request.id),
current_samples = self.current_samples,
- sample_copy=copy_list, details_state=self.details_state,
+ sample_copy=self.__copy_sample(), details_state=self.details_state,
messagetype='error', msg=msg)
# save all the new/unsaved samples entered by the user
- for index in range(len(self.current_samples)-len(request.samples)):
- sample_index = index + len(request.samples)
- sample_name = util.restore_text( params.get( 'sample_%i_name' % sample_index, '' ) )
- sample_values = []
- for field_index in range(len(request.type.sample_form.fields)):
- sample_values.append(util.restore_text( params.get( 'sample_%i_field_%i' % (sample_index, field_index), '' ) ))
- form_values = trans.app.model.FormValues(request.type.sample_form, sample_values)
- form_values.flush()
- s = trans.app.model.Sample(sample_name, '', request, form_values)
- s.flush()
- # set the initial state
- state = s.request.type.states[0]
- event = trans.app.model.SampleEvent(s, state)
- event.flush()
+ if not self.edit_mode:
+ for index in range(len(self.current_samples)-len(request.samples)):
+ sample_index = index + len(request.samples)
+ sample_name = util.restore_text( params.get( 'sample_%i_name' % sample_index, '' ) )
+ sample_values = []
+ for field_index in range(len(request.type.sample_form.fields)):
+ sample_values.append(util.restore_text( params.get( 'sample_%i_field_%i' % (sample_index, field_index), '' ) ))
+ form_values = trans.app.model.FormValues(request.type.sample_form, sample_values)
+ form_values.flush()
+ s = trans.app.model.Sample(sample_name, '', request, form_values)
+ s.flush()
+ else:
+ for index in range(len(self.current_samples)):
+ sample_index = index
+ sample_name = self.current_samples[sample_index][0]
+ new_sample_name = util.restore_text( params.get( 'sample_%i_name' % sample_index, '' ) )
+ sample_values = []
+ for field_index in range(len(request.type.sample_form.fields)):
+ sample_values.append(util.restore_text( params.get( 'sample_%i_field_%i' % (sample_index, field_index), '' ) ))
+ sample = request.has_sample(sample_name)
+ if sample:
+ form_values = trans.app.model.FormValues.get(sample.values.id)
+ form_values.content = sample_values
+ form_values.flush()
+ sample.name = new_sample_name
+ sample.flush()
return trans.response.send_redirect( web.url_for( controller='requests',
action='list',
operation='show_request',
id=trans.security.encode_id(request.id)) )
+ elif params.get('edit_samples_button', False) == 'Edit samples':
+ self.edit_mode = True
+ return trans.fill_template( '/requests/show_request.mako',
+ request=request,
+ request_details=self.request_details(trans, request.id),
+ current_samples=self.current_samples,
+ sample_copy=self.__copy_sample(),
+ details_state=self.details_state,
+ edit_mode=self.edit_mode)
+ elif params.get('cancel_changes_button', False) == 'Cancel':
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ operation='show_request',
+ id=trans.security.encode_id(request.id)) )
+
+
@web.expose
def delete_sample(self, trans, **kwd):
params = util.Params( kwd )
@@ -253,16 +341,15 @@
s.delete()
s.flush()
request.flush()
- del self.current_samples[sample_index]
- copy_list = SelectField('copy_sample')
- copy_list.add_option('None', -1, selected=True)
- for i, s in enumerate(self.current_samples):
- copy_list.add_option(i+1, i)
+ del self.current_samples[sample_index]
return trans.fill_template( '/requests/show_request.mako',
request=request,
request_details=self.request_details(trans, request.id),
current_samples = self.current_samples,
- sample_copy=copy_list, details_state=self.details_state)
+ sample_copy=self.__copy_sample(),
+ details_state=self.details_state,
+ edit_mode=self.edit_mode)
+
@web.expose
def toggle_request_details(self, trans, **kwd):
params = util.Params( kwd )
@@ -272,121 +359,95 @@
if self.details_state == 'Show request details':
self.details_state = 'Hide request details'
elif self.details_state == 'Hide request details':
- self.details_state = 'Show request details'
- copy_list = SelectField('copy_sample')
- copy_list.add_option('None', -1, selected=True)
- for i, s in enumerate(self.current_samples):
- copy_list.add_option(i+1, i)
+ self.details_state = 'Show request details'
return trans.fill_template( '/requests/show_request.mako',
request=request,
request_details=self.request_details(trans, request.id),
current_samples = self.current_samples,
- sample_copy=copy_list, details_state=self.details_state)
+ sample_copy=self.__copy_sample(),
+ details_state=self.details_state,
+ edit_mode=self.edit_mode)
+ def __select_request_type(self, trans, rtid):
+ rt_ids = ['none']
+ for rt in trans.app.model.RequestType.query().all():
+ if not rt.deleted:
+ rt_ids.append(str(rt.id))
+ select_reqtype = SelectField('select_request_type',
+ refresh_on_change=True,
+ refresh_on_change_values=rt_ids[1:])
+ if rtid == 'none':
+ select_reqtype.add_option('Select one', 'none', selected=True)
+ else:
+ select_reqtype.add_option('Select one', 'none')
+ for rt in trans.app.model.RequestType.query().all():
+ if not rt.deleted:
+ if rtid == rt.id:
+ select_reqtype.add_option(rt.name, rt.id, selected=True)
+ else:
+ select_reqtype.add_option(rt.name, rt.id)
+ return select_reqtype
@web.expose
def new(self, trans, **kwd):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
if params.get('select_request_type', False) == 'True':
- return trans.fill_template( '/requests/select_request_type.mako',
- request_types=trans.app.model.RequestType.query().all(),
- libraries=self.get_authorized_libs(trans),
+ return trans.fill_template( '/requests/new_request.mako',
+ select_request_type=self.__select_request_type(trans, 'none'),
+ widgets=[],
msg=msg,
- messagetype=messagetype )
+ messagetype=messagetype)
elif params.get('create', False) == 'True':
- return self.__show_request_form(trans=trans,
- request=None, **kwd)
- elif params.get('save', False) == 'True':
- request_type = trans.app.model.RequestType.get(int(params.request_type_id))
- msg = self.__validate(trans,
- [('name','Name')],
- request_type.request_form.fields,
- **kwd)
- if msg:
- kwd['create'] = 'True'
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='new',
- msg=msg,
- messagetype='error',
- **kwd) )
- request = self.__save_request(trans, None, **kwd)
- msg = 'The new request named %s has been created' % request.name
- request_type_id = int(util.restore_text( params.request_type_id ))
- if params.get('create_request_button', False) == 'Save':
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- msg=msg ,
- messagetype='done') )
- elif params.get('create_request_samples_button', False) == 'Add samples':
- new_kwd = {}
- new_kwd['id'] = trans.security.encode_id(request.id)
- new_kwd['operation'] = 'show_request'
- new_kwd['add_sample'] = True
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- msg=msg ,
- messagetype='done',
- **new_kwd) )
+ if params.get('create_request_button', False) == 'Save' \
+ or params.get('create_request_samples_button', False) == 'Add samples':
+ request_type = trans.app.model.RequestType.get(int(params.select_request_type))
+ if not util.restore_text(params.get('name', '')):
+ msg = 'Please enter the <b>Name</b> of the request'
+ kwd['create'] = 'True'
+ kwd['messagetype'] = 'error'
+ kwd['msg'] = msg
+ kwd['create_request_button'] = None
+ kwd['create_request_samples_button'] = None
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='new',
+ **kwd) )
+ request = self.__save_request(trans, None, **kwd)
+ msg = 'The new request named %s has been created' % request.name
+ if params.get('create_request_button', False) == 'Save':
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ msg=msg ,
+ messagetype='done') )
+ elif params.get('create_request_samples_button', False) == 'Add samples':
+ new_kwd = {}
+ new_kwd['id'] = trans.security.encode_id(request.id)
+ new_kwd['operation'] = 'show_request'
+ new_kwd['add_sample'] = True
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ msg=msg ,
+ messagetype='done',
+ **new_kwd) )
+ else:
+ return self.__show_request_form(trans, **kwd)
+ elif params.get('refresh', False) == 'true':
+ return self.__show_request_form(trans, **kwd)
- def __validate(self, trans, main_fields=[], form_fields=[], **kwd):
- '''
- Validates the request entered by the user
- '''
- params = util.Params( kwd )
- for field, field_name in main_fields:
- if not util.restore_text(params.get(field, '')):
- return 'Please enter the <b>%s</b> of the request' % field_name
- # check rest of the fields of the form
- for index, field in enumerate(form_fields):
- if not util.restore_text(params.get('field_%i' % index, None)) \
- and field['required'] == 'required':
- return 'Please enter the <b>%s</b> field of the request' % field['label']
- return None
- def __save_request(self, trans, request_id=None, **kwd):
- '''
- This method saves a new request if request_id is None.
- '''
- params = util.Params( kwd )
- if not request_id:
- request_type = trans.app.model.RequestType.get(int(params.request_type_id ))
- else:
- # TODO editing
- pass
- name = util.restore_text(params.get('name', ''))
- desc = util.restore_text(params.get('desc', ''))
- try:
- library_id = int(util.restore_text(params.get('library_id', None)))
- except:
- msg = "Sequencing request could not be saved. Invalid library"
- return trans.response.send_redirect( web.url_for( controller='requests',
- action='list',
- status='error',
- message=msg,
- **kwd) )
- values = []
- for index, field in enumerate(request_type.request_form.fields):
- values.append(util.restore_text(params.get('field_%i' % index, '')))
- if not request_id:
- form_values = trans.app.model.FormValues(request_type.request_form, values)
- form_values.flush()
- request = trans.app.model.Request(name, desc, request_type,
- trans.user, form_values,
- trans.app.model.Library.get(library_id),
- submitted=False)
- request.flush()
- else:
- # TODO editing
- pass
- return request
- def __show_request_form(self, trans, request=None, **kwd):
+
+ def __show_request_form(self, trans, **kwd):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
- request_type = trans.app.model.RequestType.get(int(params.request_type_id))
- if request:
- form_values = request.values
- else:
- form_values = None
+ try:
+ request_type = trans.app.model.RequestType.get(int(params.select_request_type))
+ except:
+ return trans.fill_template( '/requests/new_request.mako',
+ select_request_type=self.__select_request_type(trans, 'none'),
+ widgets=[],
+ msg=msg,
+ messagetype=messagetype)
+ form_values = None
+ select_request_type = self.__select_request_type(trans, request_type.id)
# list of widgets to be rendered on the request form
widgets = []
widgets.append(dict(label='Name',
@@ -397,53 +458,305 @@
widget=TextField('desc', 40,
util.restore_text( params.get( 'desc', '' ) )),
helptext='(Optional)'))
+
# libraries selectbox
libraries = self.get_authorized_libs(trans)
- if libraries:
- libui = self.__library_ui(libraries, **kwd)
- widgets.append(libui)
+ libui = self.__library_ui(libraries, **kwd)
+ widgets = widgets + libui
widgets = self.__create_form(trans, request_type.request_form_id, widgets,
form_values, **kwd)
title = 'Add a new request of type: %s' % request_type.name
return trans.fill_template( '/requests/new_request.mako',
- request_form_id=request_type.request_form_id,
- request_type=request_type,
- widgets=widgets,
- title=title,
- msg=msg,
- messagetype=messagetype)
+ select_request_type=select_request_type,
+ request_type=request_type,
+ widgets=widgets,
+ msg=msg,
+ messagetype=messagetype)
- def __library_ui(self, libraries, **kwd):
+ def __library_ui(self, libraries, request=None, **kwd):
params = util.Params( kwd )
- create_lib_str = 'Create a new library'
- value = int(params.get( 'library_id', 0 ))
- if not value: # if no library previously selected
- # show the selectbox with 'create a new library' option selected
- lib_list = SelectField('library_id', refresh_on_change=True,
- refresh_on_change_values=[create_lib_str])
- #lib_list.add_option(create_lib_str, 0, selected=True)
- for lib in libraries:
+ lib_id = params.get( 'library_id', 'none' )
+ lib_list = SelectField('library_id', refresh_on_change=True,
+ refresh_on_change_values=['new'])
+ if request and lib_id == 'none':
+ if request.library:
+ lib_id = str(request.library.id)
+ if lib_id == 'none':
+ lib_list.add_option('Select one', 'none', selected=True)
+ else:
+ lib_list.add_option('Select one', 'none')
+ for lib in libraries:
+ if str(lib.id) == lib_id:
+ lib_list.add_option(lib.name, lib.id, selected=True)
+ else:
lib_list.add_option(lib.name, lib.id)
- widget = dict(label='Library',
- widget=lib_list,
- helptext='Associated library where the resultant \
- dataset will be stored.')
- else: # if some library previously selected
- # show the selectbox with some library selected
- lib_list = SelectField('library_id', refresh_on_change=True,
- refresh_on_change_values=[create_lib_str])
- #lib_list.add_option(create_lib_str, 0)
- for lib in libraries:
- if value == lib.id:
- lib_list.add_option(lib.name, lib.id, selected=True)
+ if lib_id == 'new':
+ lib_list.add_option('Create a new library', 'new', selected=True)
+ else:
+ lib_list.add_option('Create a new library', 'new')
+ widget = dict(label='Library',
+ widget=lib_list,
+ helptext='Associated library where the resultant \
+ dataset will be stored.')
+ if lib_id == 'new':
+ new_lib = dict(label='Create a new Library',
+ widget=TextField('new_library_name', 40,
+ util.restore_text( params.get( 'new_library_name', '' ) )),
+ helptext='Enter a library name here to request a new library')
+ return [widget, new_lib]
+ else:
+ return [widget]
+
+ def __create_form(self, trans, form_id, widgets=[], form_values=None, **kwd):
+ params = util.Params( kwd )
+ form = trans.app.model.FormDefinition.get(form_id)
+ # form fields
+ for index, field in enumerate(form.fields):
+ # value of the field
+ if field['type'] == 'CheckboxField':
+ value = util.restore_text( params.get( 'field_%i' % index, False ) )
+ else:
+ value = util.restore_text( params.get( 'field_%i' % index, '' ) )
+ if not value:
+ if form_values:
+ value = str(form_values.content[index])
+ # create the field
+ fw = eval(field['type'])('field_%i' % index)
+ if field['type'] == 'TextField':
+ fw.set_size(40)
+ fw.value = value
+ elif field['type'] == 'TextArea':
+ fw.set_size(3, 40)
+ fw.value = value
+ elif field['type'] == 'AddressField':
+ fw.user = trans.user
+ fw.value = value
+ fw.params = params
+ elif field['type'] == 'SelectField':
+ for option in field['selectlist']:
+ if option == value:
+ fw.add_option(option, option, selected=True)
+ else:
+ fw.add_option(option, option)
+ elif field['type'] == 'CheckboxField':
+ fw.checked = value
+ # require/optional
+ if field['required'] == 'required':
+ req = 'Required'
+ else:
+ req = 'Optional'
+ widgets.append(dict(label=field['label'],
+ widget=fw,
+ helptext=field['helptext']+' ('+req+')'))
+ return widgets
+ def __validate(self, trans, request):
+ '''
+ Validates the request entered by the user
+ '''
+ empty_fields = []
+ if not request.library:
+ empty_fields.append('Library')
+ # check rest of the fields of the form
+ for index, field in enumerate(request.type.request_form.fields):
+ if field['required'] == 'required' and request.values.content[index] in ['', None]:
+ empty_fields.append(field['label'])
+ if empty_fields:
+ msg = 'Fill the following fields of the request <b>%s</b> before submitting<br/>' % request.name
+ for ef in empty_fields:
+ msg = msg + '<b>' +ef + '</b><br/>'
+ return msg
+ return None
+ def __save_request(self, trans, request=None, **kwd):
+ '''
+ This method saves a new request if request_id is None.
+ '''
+ params = util.Params( kwd )
+ request_type = trans.app.model.RequestType.get(int(params.select_request_type))
+ name = util.restore_text(params.get('name', ''))
+ desc = util.restore_text(params.get('desc', ''))
+ # library
+ try:
+ library = trans.app.model.Library.get(int(params.get('library_id', None)))
+ except:
+ library = None
+ # fields
+ values = []
+ for index, field in enumerate(request_type.request_form.fields):
+ if field['type'] == 'AddressField':
+ value = util.restore_text(params.get('field_%i' % index, ''))
+ if value == 'new':
+ # save this new address in the list of this user's addresses
+ user_address = trans.app.model.UserAddress( user=trans.user )
+ user_address.desc = util.restore_text(params.get('field_%i_short_desc' % index, ''))
+ user_address.name = util.restore_text(params.get('field_%i_name' % index, ''))
+ user_address.institution = util.restore_text(params.get('field_%i_institution' % index, ''))
+ user_address.address = util.restore_text(params.get('field_%i_address1' % index, ''))+' '+util.restore_text(params.get('field_%i_address2' % index, ''))
+ user_address.city = util.restore_text(params.get('field_%i_city' % index, ''))
+ user_address.state = util.restore_text(params.get('field_%i_state' % index, ''))
+ user_address.postal_code = util.restore_text(params.get('field_%i_postal_code' % index, ''))
+ user_address.country = util.restore_text(params.get('field_%i_country' % index, ''))
+ user_address.phone = util.restore_text(params.get('field_%i_phone' % index, ''))
+ user_address.flush()
+ trans.user.refresh()
+ values.append(int(user_address.id))
+ elif value == unicode('none'):
+ values.append('')
else:
- lib_list.add_option(lib.name, lib.id)
- widget = dict(label='Library',
- widget=lib_list,
- helptext='Associated library where the resultant \
- dataset will be stored.')
- return widget
-
+ values.append(int(value))
+ else:
+ values.append(util.restore_text(params.get('field_%i' % index, '')))
+ form_values = trans.app.model.FormValues(request_type.request_form, values)
+ form_values.flush()
+ if not request:
+ request = trans.app.model.Request(name, desc, request_type,
+ trans.user, form_values,
+ library=library,
+ state=trans.app.model.Request.states.UNSUBMITTED)
+ request.flush()
+ else:
+ request.name = name
+ request.desc = desc
+ request.type = request_type
+ request.user = trans.user
+ request.values = form_values
+ request.library = library
+ request.state = trans.app.model.Request.states.UNSUBMITTED
+ request.flush()
+ return request
+ @web.expose
+ def edit(self, trans, **kwd):
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ try:
+ request = trans.app.model.Request.get(int(params.get('request_id', None)))
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message="Invalid request ID",
+ **kwd) )
+ if params.get('show', False) == 'True':
+ return self.__edit_request(trans, request.id, **kwd)
+ elif params.get('save_changes_request_button', False) == 'Save changes' \
+ or params.get('edit_samples_button', False) == 'Edit samples':
+ request_type = trans.app.model.RequestType.get(int(params.select_request_type))
+ if not util.restore_text(params.get('name', '')):
+ msg = 'Please enter the <b>Name</b> of the request'
+ kwd['messagetype'] = 'error'
+ kwd['msg'] = msg
+ kwd['show'] = 'True'
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='edit',
+ **kwd) )
+ request = self.__save_request(trans, request, **kwd)
+ msg = 'The changes made to the request named %s has been saved' % request.name
+ if params.get('save_changes_request_button', False) == 'Save changes':
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ message=msg ,
+ status='done') )
+ elif params.get('edit_samples_button', False) == 'Edit samples':
+ new_kwd = {}
+ new_kwd['request_id'] = request.id
+ new_kwd['edit_samples_button'] = 'Edit samples'
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='show_request',
+ msg=msg ,
+ messagetype='done',
+ **new_kwd) )
+ elif params.get('refresh', False) == 'true':
+ return self.__edit_request(trans, request.id, **kwd)
+
+ def __edit_request(self, trans, id, **kwd):
+ try:
+ request = trans.app.model.Request.get(id)
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message=msg) )
+ params = util.Params( kwd )
+ msg = util.restore_text( params.get( 'msg', '' ) )
+ messagetype = params.get( 'messagetype', 'done' )
+ select_request_type = self.__select_request_type(trans, request.type.id)
+ # list of widgets to be rendered on the request form
+ widgets = []
+ if util.restore_text( params.get( 'name', '' ) ):
+ name = util.restore_text( params.get( 'name', '' ) )
+ else:
+ name = request.name
+ widgets.append(dict(label='Name',
+ widget=TextField('name', 40, name),
+ helptext='(Required)'))
+ if util.restore_text( params.get( 'desc', '' ) ):
+ desc = util.restore_text( params.get( 'desc', '' ) )
+ else:
+ desc = request.desc
+ widgets.append(dict(label='Description',
+ widget=TextField('desc', 40, desc),
+ helptext='(Optional)'))
+
+ # libraries selectbox
+ libraries = self.get_authorized_libs(trans)
+ libui = self.__library_ui(libraries, request, **kwd)
+ widgets = widgets + libui
+ widgets = self.__create_form(trans, request.type.request_form_id, widgets,
+ request.values, **kwd)
+ return trans.fill_template( '/requests/edit_request.mako',
+ select_request_type=select_request_type,
+ request_type=request.type,
+ request=request,
+ widgets=widgets,
+ msg=msg,
+ messagetype=messagetype)
+ return self.__show_request_form(trans)
+ def __delete_request(self, trans, id):
+ try:
+ request = trans.app.model.Request.get(id)
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ # change request's submitted field
+ if not request.unsubmitted():
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message='This request cannot be deleted as it is already been submitted',
+ **kwd) )
+ request.deleted = True
+ request.flush()
+ kwd = {}
+ kwd['id'] = trans.security.encode_id(request.id)
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ **kwd) )
+ def __undelete_request(self, trans, id):
+ try:
+ request = trans.app.model.Request.get(id)
+ except:
+ msg = "Invalid request ID"
+ log.warn( msg )
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message=msg,
+ **kwd) )
+ # change request's submitted field
+ request.deleted = False
+ request.flush()
+ kwd = {}
+ kwd['id'] = trans.security.encode_id(request.id)
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ **kwd) )
def __submit(self, trans, id):
try:
request = trans.app.model.Request.get(id)
@@ -455,13 +768,21 @@
status='error',
message=msg,
**kwd) )
+ msg = self.__validate(trans, request)
+ if msg:
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='edit',
+ messagetype = 'error',
+ msg=msg,
+ request_id=request.id,
+ show='True') )
# get the new state
- new_state = request.type.states[1]
+ new_state = request.type.states[0]
for s in request.samples:
event = trans.app.model.SampleEvent(s, new_state, 'Samples submitted to the system')
event.flush()
# change request's submitted field
- request.submitted = True
+ request.state = request.states.SUBMITTED
request.flush()
kwd = {}
kwd['id'] = trans.security.encode_id(request.id)
@@ -482,54 +803,28 @@
status='error',
message=msg,
**kwd) )
+ msg = self.__validate(trans, request)
+ if msg:
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='edit',
+ messagetype = 'error',
+ msg=msg,
+ request_id=request.id,
+ show='True') )
# get the new state
- new_state = request.type.states[1]
+ new_state = request.type.states[0]
for s in request.samples:
event = trans.app.model.SampleEvent(s, new_state, 'Samples submitted to the system')
event.flush()
# change request's submitted field
- request.submitted = True
+ request.state = request.states.SUBMITTED
request.flush()
## TODO
kwd['id'] = trans.security.encode_id(request.id)
return trans.response.send_redirect( web.url_for( controller='requests',
action='list',
**kwd) )
- def __create_form(self, trans, form_id, widgets=[], form_values=None, **kwd):
- params = util.Params( kwd )
- form = trans.app.model.FormDefinition.get(form_id)
- # form fields
- for index, field in enumerate(form.fields):
- # value of the field
- if field['type'] == 'CheckboxField':
- value = util.restore_text( params.get( 'field_%i' % index, False ) )
- else:
- value = util.restore_text( params.get( 'field_%i' % index, '' ) )
- # create the field
- fw = eval(field['type'])('field_%i' % index)
- if field['type'] == 'TextField':
- fw.set_size(40)
- fw.value = value
- elif field['type'] == 'TextArea':
- fw.set_size(3, 40)
- fw.value = value
- elif field['type'] == 'SelectField':
- for option in field['selectlist']:
- if option == value:
- fw.add_option(option, option, selected=True)
- else:
- fw.add_option(option, option)
- elif field['type'] == 'CheckboxField':
- fw.checked = value
- # require/optional
- if field['required'] == 'required':
- req = 'Required'
- else:
- req = 'Optional'
- widgets.append(dict(label=field['label'],
- widget=fw,
- helptext=field['helptext']+' ('+req+')'))
- return widgets
+
@web.expose
def show_events(self, trans, **kwd):
params = util.Params( kwd )
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/requests_admin.py
--- a/lib/galaxy/web/controllers/requests_admin.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/requests_admin.py Thu Aug 06 15:25:18 2009 -0400
@@ -26,6 +26,7 @@
link=( lambda item: iff( item.deleted, None, dict( operation="show_request", id=item.id ) ) ), ),
grids.GridColumn( "Type", key="request_type_id", method='get_request_type'),
grids.GridColumn( "Last update", key="update_time", format=time_ago ),
+ grids.GridColumn( "State", key='state'),
grids.GridColumn( "User", key="user_id", method='get_user')
]
@@ -36,9 +37,10 @@
# grids.GridOperation( "Undelete", condition=( lambda item: item.deleted ) ),
]
standard_filters = [
- grids.GridColumnFilter( "Active", args=dict( deleted=False ) ),
- grids.GridColumnFilter( "Deleted", args=dict( deleted=True ) ),
- grids.GridColumnFilter( "All", args=dict( deleted='All' ) )
+ grids.GridColumnFilter( model.Request.states.SUBMITTED,
+ args=dict( state=model.Request.states.SUBMITTED, deleted=False ) ),
+ grids.GridColumnFilter( model.Request.states.COMPLETE, args=dict( state=model.Request.states.COMPLETE, deleted=False ) ),
+ grids.GridColumnFilter( "All", args=dict( deleted=False ) )
]
def get_user(self, trans, request):
return trans.app.model.User.get(request.user_id).email
@@ -48,7 +50,8 @@
request_type = trans.app.model.RequestType.get(request.request_type_id)
return request_type.name
def apply_default_filter( self, trans, query ):
- return query.filter_by(submitted=True)
+ return query.filter(or_(self.model_class.state==self.model_class.states.SUBMITTED,
+ self.model_class.state==self.model_class.states.COMPLETE))
def number_of_samples(self, trans, request):
return str(len(request.samples))
@@ -59,13 +62,6 @@
@web.require_admin
def index( self, trans ):
return trans.fill_template( "/admin/requests/index.mako" )
- def get_authorized_libs(self, trans):
- all_libraries = trans.app.model.Library.filter(trans.app.model.Library.table.c.deleted == False).order_by(trans.app.model.Library.name).all()
- authorized_libraries = []
- for library in all_libraries:
- if trans.app.security_agent.allow_action(trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=library) or trans.app.security_agent.allow_action(trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=library) or trans.app.security_agent.allow_action(trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MANAGE, library_item=library) or trans.app.security_agent.check_folder_contents(trans.user, library) or trans.app.security_agent.show_library_item(trans.user, library):
- authorized_libraries.append(library)
- return authorized_libraries
@web.expose
@web.require_admin
def list( self, trans, **kwargs ):
@@ -73,11 +69,19 @@
List all request made by the current user
'''
status = message = None
+ self.request_grid.default_filter = dict(state=trans.app.model.Request.states.SUBMITTED,
+ deleted=False)
if 'operation' in kwargs:
operation = kwargs['operation'].lower()
if operation == "show_request":
id = trans.security.decode_id(kwargs['id'])
return self.__show_request(trans, id)
+
+ if 'show_filter' in kwargs.keys():
+ if kwargs['show_filter'] == 'All':
+ self.request_grid.default_filter = dict(deleted=False)
+ else:
+ self.request_grid.default_filter = dict(state=kwargs['show_filter'], deleted=False)
# Render the list view
return self.request_grid( trans, template='/admin/requests/grid.mako', **kwargs )
def __show_request(self, trans, id):
@@ -122,7 +126,6 @@
Shows the request details
'''
request = trans.app.model.Request.get(id)
- libraries = self.get_authorized_libs(trans)
# list of widgets to be rendered on the request form
request_details = []
# main details
@@ -152,55 +155,124 @@
req = 'Required'
else:
req = 'Optional'
- request_details.append(dict(label=field['label'],
- value=request.values.content[index],
- helptext=field['helptext']+' ('+req+')'))
+ if field['type'] == 'AddressField':
+ if request.values.content[index]:
+ request_details.append(dict(label=field['label'],
+ value=trans.app.model.UserAddress.get(int(request.values.content[index])).get_html(),
+ helptext=field['helptext']+' ('+req+')'))
+ else:
+ request_details.append(dict(label=field['label'],
+ value=None,
+ helptext=field['helptext']+' ('+req+')'))
+ else:
+ request_details.append(dict(label=field['label'],
+ value=request.values.content[index],
+ helptext=field['helptext']+' ('+req+')'))
return request_details
@web.expose
@web.require_admin
def bar_codes(self, trans, **kwd):
params = util.Params( kwd )
- request_id = params.get('request_id', None)
- if request_id:
- request_id = int(request_id)
- request = trans.app.model.Request.get(request_id)
- return trans.fill_template( '/admin/samples/bar_codes.mako',
- samples_list=[s for s in request.samples],
- user=request.user,
- request=request)
+ try:
+ request = trans.app.model.Request.get(int(params.get('request_id', None)))
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message="Invalid request ID",
+ **kwd) )
+ widgets = []
+ for index, sample in enumerate(request.samples):
+ if sample.bar_code:
+ bc = sample.bar_code
+ else:
+ bc = util.restore_text(params.get('sample_%i_bar_code' % index, ''))
+ widgets.append(TextField('sample_%i_bar_code' % index,
+ 40,
+ bc))
+ return trans.fill_template( '/admin/samples/bar_codes.mako',
+ samples_list=[s for s in request.samples],
+ user=request.user, request=request, widgets=widgets)
@web.expose
@web.require_admin
def save_bar_codes(self, trans, **kwd):
params = util.Params( kwd )
- request_id = params.get('request_id', None)
- if request_id:
- request_id = int(request_id)
- request = trans.app.model.Request.get(request_id)
- # validate
- # bar codes need to be globally unique
- unique = True
- for index in range(len(request.samples)):
- bar_code = util.restore_text(params.get('sample_%i_bar_code' % index, ''))
- all_samples = trans.app.model.Sample.query.all()
- for sample in all_samples:
- if bar_code == sample.bar_code:
- unique = False
- if not unique:
- return trans.fill_template( '/admin/samples/bar_codes.mako',
- samples_list=[s for s in request.samples],
- user=request.user,
- request=request,
- messagetype='error',
- msg='Samples cannot have same bar code.')
+ try:
+ request = trans.app.model.Request.get(int(params.get('request_id', None)))
+ except:
+ return trans.response.send_redirect( web.url_for( controller='requests',
+ action='list',
+ status='error',
+ message="Invalid request ID",
+ **kwd) )
+ # validate
+ # bar codes need to be globally unique
+ msg = ''
+ for index in range(len(request.samples)):
+ bar_code = util.restore_text(params.get('sample_%i_bar_code' % index, ''))
+ # check for empty bar code
+ if not bar_code.strip():
+ msg = 'Please fill the bar code for sample <b>%s</b>.' % request.samples[index].name
+ break
+ # check all the unsaved bar codes
+ count = 0
+ for i in range(len(request.samples)):
+ if bar_code == util.restore_text(params.get('sample_%i_bar_code' % i, '')):
+ count = count + 1
+ if count > 1:
+ msg = '''The bar code <b>%s</b> of sample <b>%s</b> already belongs
+ another sample in this request. The sample bar codes must
+ be unique throughout the system''' % \
+ (bar_code, request.samples[index].name)
+ break
+ # check all the saved bar codes
+ all_samples = trans.app.model.Sample.query.all()
+ for sample in all_samples:
+ if bar_code == sample.bar_code:
+ msg = '''The bar code <b>%s</b> of sample <b>%s</b> already
+ belongs another sample. The sample bar codes must be
+ unique throughout the system''' % \
+ (bar_code, request.samples[index].name)
+ break
+ if msg:
+ break
+ if msg:
+ widgets = []
for index, sample in enumerate(request.samples):
- bar_code = util.restore_text(params.get('sample_%i_bar_code' % index, ''))
- sample.bar_code = bar_code
- sample.flush()
+ if sample.bar_code:
+ bc = sample.bar_code
+ else:
+ bc = util.restore_text(params.get('sample_%i_bar_code' % index, ''))
+ widgets.append(TextField('sample_%i_bar_code' % index,
+ 40,
+ util.restore_text(params.get('sample_%i_bar_code' % index, ''))))
+ return trans.fill_template( '/admin/samples/bar_codes.mako',
+ samples_list=[s for s in request.samples],
+ user=request.user, request=request, widgets=widgets, messagetype='error',
+ msg=msg)
+ # now save the bar codes
+ for index, sample in enumerate(request.samples):
+ bar_code = util.restore_text(params.get('sample_%i_bar_code' % index, ''))
+ sample.bar_code = bar_code
+ sample.flush()
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='list',
operation='show_request',
id=trans.security.encode_id(request.id)) )
+ def __set_request_state(self, request):
+ # check if all the samples of the current request are in the final state
+ complete = True
+ for s in request.samples:
+ if s.current_state().id != request.type.states[-1].id:
+ complete = False
+ if complete:
+ request.state = request.states.COMPLETE
+ else:
+ request.state = request.states.SUBMITTED
+ request.flush()
+
+
def change_state(self, trans, sample):
possible_states = sample.request.type.states
curr_state = sample.current_state()
@@ -236,6 +308,7 @@
and trans.app.model.SampleState.table.c.id == selected_state)[0]
event = trans.app.model.SampleEvent(sample, new_state, comments)
event.flush()
+ self.__set_request_state(sample.request)
return trans.response.send_redirect( web.url_for( controller='requests_admin',
action='show_events',
sample_id=sample.id))
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/root.py
--- a/lib/galaxy/web/controllers/root.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/root.py Thu Aug 06 15:25:18 2009 -0400
@@ -547,29 +547,29 @@
# return trans.fill_template( "/root/masthead.mako", brand=brand, wiki_url=wiki_url,
# blog_url=blog_url,bugs_email=bugs_email, screencasts_url=screencasts_url, admin_user=admin_user, active_view=active_view )
- @web.expose
- def dataset_errors( self, trans, id=None, **kwd ):
- """View/fix errors associated with dataset"""
- data = trans.app.model.HistoryDatasetAssociation.get( id )
- p = kwd
- if p.get("fix_errors", None):
- # launch tool to create new, (hopefully) error free dataset
- tool_params = {}
- tool_params["tool_id"] = 'fix_errors'
- tool_params["runtool_btn"] = 'T'
- tool_params["input"] = id
- tool_params["ext"] = data.ext
- # send methods selected
- repair_methods = data.datatype.repair_methods( data )
- methods = []
- for method, description in repair_methods:
- if method in p: methods.append(method)
- tool_params["methods"] = ",".join(methods)
- url = "/tool_runner/index?" + urllib.urlencode(tool_params)
- trans.response.send_redirect(url)
- else:
- history = trans.app.model.History.get( data.history_id )
- return trans.fill_template('dataset/validation.tmpl', data=data, history=history)
+ # @web.expose
+ # def dataset_errors( self, trans, id=None, **kwd ):
+ # """View/fix errors associated with dataset"""
+ # data = trans.app.model.HistoryDatasetAssociation.get( id )
+ # p = kwd
+ # if p.get("fix_errors", None):
+ # # launch tool to create new, (hopefully) error free dataset
+ # tool_params = {}
+ # tool_params["tool_id"] = 'fix_errors'
+ # tool_params["runtool_btn"] = 'T'
+ # tool_params["input"] = id
+ # tool_params["ext"] = data.ext
+ # # send methods selected
+ # repair_methods = data.datatype.repair_methods( data )
+ # methods = []
+ # for method, description in repair_methods:
+ # if method in p: methods.append(method)
+ # tool_params["methods"] = ",".join(methods)
+ # url = "/tool_runner/index?" + urllib.urlencode(tool_params)
+ # trans.response.send_redirect(url)
+ # else:
+ # history = trans.app.model.History.get( data.history_id )
+ # return trans.fill_template('dataset/validation.tmpl', data=data, history=history)
# ---- Debug methods ----------------------------------------------------
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/controllers/user.py
--- a/lib/galaxy/web/controllers/user.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/controllers/user.py Thu Aug 06 15:25:18 2009 -0400
@@ -21,7 +21,7 @@
require_login_creation_template = require_login_template % " If you don't already have an account, <a href='%s'>you may create one</a>."
class User( BaseController ):
-
+ edit_address_id = None
@web.expose
def index( self, trans, **kwd ):
return trans.fill_template( '/user/index.mako', user=trans.get_user() )
@@ -224,3 +224,186 @@
else:
# User not logged in, history group must be only public
return trans.show_error_message( "You must be logged in to change your default permitted actions." )
+
+ @web.expose
+ def manage_addresses(self, trans, **kwd):
+ if trans.user:
+ params = util.Params( kwd )
+ show_filter = util.restore_text( params.get( 'show_filter', 'Active' ) )
+ if show_filter == 'All':
+ addresses = [address for address in trans.user.addresses]
+ elif show_filter == 'Deleted':
+ addresses = [address for address in trans.user.addresses if address.deleted]
+ else:
+ addresses = [address for address in trans.user.addresses if not address.deleted]
+ return trans.fill_template( 'user/address.mako',
+ addresses=addresses,
+ show_filter=show_filter)
+ else:
+ # User not logged in, history group must be only public
+ return trans.show_error_message( "You must be logged in to change your default permitted actions." )
+
+ @web.expose
+ def new_address( self, trans, short_desc='', name='', institution='', address1='',
+ address2='', city='', state='', postal_code='', country='', phone='' ):
+ if trans.app.config.require_login:
+ refresh_frames = [ 'masthead', 'history', 'tools' ]
+ else:
+ refresh_frames = [ 'masthead', 'history' ]
+ if not trans.app.config.allow_user_creation and not trans.user_is_admin():
+ return trans.show_error_message( 'User registration is disabled. Please contact your Galaxy administrator for an account.' )
+ short_desc_error = name_error = institution_error = address1_error = city_error = None
+ address2_error = state_error = postal_code_error = country_error = phone_error = None
+ if short_desc:
+ if not len( short_desc ):
+ short_desc_error = 'Enter a short description for this address'
+ elif not len( name ):
+ name_error = 'Enter the full name'
+ elif not len( institution ):
+ institution_error = 'Enter the institution associated with the user'
+ elif not len ( address1 ):
+ address1_error = 'Enter the address'
+ elif not len( city ):
+ city_error = 'Enter the city'
+ elif not len( state ):
+ state_error = 'Enter the state/province/region'
+ elif not len( postal_code ):
+ postal_code_error = 'Enter the postal code'
+ elif not len( country ):
+ country_error = 'Enter the country'
+ else:
+ user_address = trans.app.model.UserAddress( user=trans.user, desc=short_desc,
+ name=name, institution=institution,
+ address=address1+' '+address2, city=city,
+ state=state, postal_code=postal_code,
+ country=country, phone=phone)
+ user_address.flush()
+ return trans.response.send_redirect( web.url_for( controller='user',
+ action='manage_addresses',
+ msg='Address <b>%s</b> has been added' % user_address.desc,
+ messagetype='done') )
+
+ return trans.show_form(
+ web.FormBuilder( web.url_for(), "New address", submit_text="Save" )
+ .add_text( "short_desc", "Short address description", value=short_desc, error=short_desc_error )
+ .add_text( "name", "Name", value=name, error=name_error )
+ .add_text( "institution", "Institution", value=institution, error=institution_error )
+ .add_text( "address1", "Address Line 1", value=address1, error=address1_error )
+ .add_text( "address2", "Address Line 2", value=address2, error=address2_error )
+ .add_text( "city", "City", value=city, error=city_error )
+ .add_text( "state", "State/Province/Region", value=state, error=state_error )
+ .add_text( "postal_code", "Postal Code", value=postal_code, error=postal_code_error )
+ .add_text( "country", "Country", value=country, error=country_error )
+ .add_text( "phone", "Phone", value=phone, error=phone_error ) )
+
+
+ @web.expose
+ def edit_address( self, trans, address_id=None, short_desc='', name='', institution='', address1='',
+ address2='', city='', state='', postal_code='', country='', phone='' ):
+ import sys
+
+ if trans.app.config.require_login:
+ refresh_frames = [ 'masthead', 'history', 'tools' ]
+ else:
+ refresh_frames = [ 'masthead', 'history' ]
+ if not trans.app.config.allow_user_creation and not trans.user_is_admin():
+ return trans.show_error_message( 'User registration is disabled. Please contact your Galaxy administrator for an account.' )
+ short_desc_error = name_error = institution_error = address1_error = city_error = None
+ address2_error = state_error = postal_code_error = country_error = phone_error = None
+ if short_desc:
+ if not len( short_desc ):
+ short_desc_error = 'Enter a short description for this address'
+ elif not len( name ):
+ name_error = 'Enter the full name'
+ elif not len( institution ):
+ institution_error = 'Enter the institution associated with the user'
+ elif not len ( address1 ):
+ address1_error = 'Enter the address'
+ elif not len( city ):
+ city_error = 'Enter the city'
+ elif not len( state ):
+ state_error = 'Enter the state/province/region'
+ elif not len( postal_code ):
+ postal_code_error = 'Enter the postal code'
+ elif not len( country ):
+ country_error = 'Enter the country'
+ else:
+ if self.edit_address_id:
+ try:
+ user_address = trans.app.model.UserAddress.get(int(self.edit_address_id))
+ except:
+ return trans.response.send_redirect( web.url_for( controller='user',
+ action='manage_addresses',
+ msg='Invalid address ID',
+ messagetype='error') )
+ user_address.desc = short_desc
+ user_address.name = name
+ user_address.institution = institution
+ user_address.address = address1+' '+address2
+ user_address.city = city
+ user_address.state = state
+ user_address.postal_code = postal_code
+ user_address.country = country
+ user_address.phone = phone
+ user_address.flush()
+ self.edit_address_id = None
+ return trans.response.send_redirect( web.url_for( controller='user',
+ action='manage_addresses',
+ msg='Changes made to address <b>%s</b> are saved.' % user_address.desc,
+ messagetype='done') )
+ self.edit_address_id = address_id
+ return trans.show_form(
+ web.FormBuilder( web.url_for(), "Edit address", submit_text="Save changes" )
+ .add_text( "short_desc", "Short address description", value=short_desc, error=short_desc_error )
+ .add_text( "name", "Name", value=name, error=name_error )
+ .add_text( "institution", "Institution", value=institution, error=institution_error )
+ .add_text( "address1", "Address Line 1", value=address1, error=address1_error )
+ .add_text( "address2", "Address Line 2", value=address2, error=address2_error )
+ .add_text( "city", "City", value=city, error=city_error )
+ .add_text( "state", "State/Province/Region", value=state, error=state_error )
+ .add_text( "postal_code", "Postal Code", value=postal_code, error=postal_code_error )
+ .add_text( "country", "Country", value=country, error=country_error )
+ .add_text( "phone", "Phone", value=phone, error=phone_error ) )
+
+ @web.expose
+ def delete_address( self, trans, address_id=None):
+ if trans.app.config.require_login:
+ refresh_frames = [ 'masthead', 'history', 'tools' ]
+ else:
+ refresh_frames = [ 'masthead', 'history' ]
+ if not trans.app.config.allow_user_creation and not trans.user_is_admin():
+ return trans.show_error_message( 'User registration is disabled. Please contact your Galaxy administrator for an account.' )
+ try:
+ user_address = trans.app.model.UserAddress.get(int(address_id))
+ except:
+ return trans.fill_template( 'user/address.mako',
+ msg='Invalid address ID',
+ messagetype='error' )
+ user_address.deleted = True
+ user_address.flush()
+ return trans.response.send_redirect( web.url_for( controller='user',
+ action='manage_addresses',
+ msg='Address <b>%s</b> deleted' % user_address.desc,
+ messagetype='done') )
+
+ @web.expose
+ def undelete_address( self, trans, address_id=None):
+ if trans.app.config.require_login:
+ refresh_frames = [ 'masthead', 'history', 'tools' ]
+ else:
+ refresh_frames = [ 'masthead', 'history' ]
+ if not trans.app.config.allow_user_creation and not trans.user_is_admin():
+ return trans.show_error_message( 'User registration is disabled. Please contact your Galaxy administrator for an account.' )
+ try:
+ user_address = trans.app.model.UserAddress.get(int(address_id))
+ except:
+ return trans.fill_template( 'user/address.mako',
+ msg='Invalid address ID',
+ messagetype='error' )
+ user_address.deleted = False
+ user_address.flush()
+ return trans.response.send_redirect( web.url_for( controller='user',
+ action='manage_addresses',
+ msg='Address <b>%s</b> is restored' % user_address.desc,
+ messagetype='done') )
+
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/form_builder.py
--- a/lib/galaxy/web/form_builder.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/form_builder.py Thu Aug 06 15:25:18 2009 -0400
@@ -11,7 +11,7 @@
raise TypeError( "Abstract Method" )
@staticmethod
def form_field_types():
- return ['TextField', 'TextArea', 'SelectField', 'CheckboxField']
+ return ['TextField', 'TextArea', 'SelectField', 'CheckboxField', 'AddressField']
class TextField(BaseField):
"""
@@ -340,6 +340,64 @@
recurse_options( rval, self.options, expanded_options )
rval.append( '</ul></div>' )
return '\n'.join( rval )
+
+class AddressField(BaseField):
+ @staticmethod
+ def fields():
+ return [ ( "short_desc", "Short address description"),
+ ( "name", "Name" ),
+ ( "institution", "Institution" ),
+ ( "address1", "Address Line 1" ),
+ ( "address2", "Address Line 2" ),
+ ( "city", "City" ),
+ ( "state", "State/Province/Region" ),
+ ( "postal_code", "Postal Code" ),
+ ( "country", "Country" ),
+ ( "phone", "Phone" ) ]
+ def __init__(self, name, user=None, value=None, params=None):
+ self.name = name
+ self.user = user
+ self.value = value
+ self.select_address = None
+ self.params = params
+ def get_html(self):
+ from galaxy import util
+ address_html = ''
+ add_ids = ['none']
+ for a in self.user.addresses:
+ add_ids.append(str(a.id))
+ add_ids.append('new')
+ self.select_address = SelectField(self.name,
+ refresh_on_change=True,
+ refresh_on_change_values=add_ids)
+ if self.value == 'none':
+ self.select_address.add_option('Select one', 'none', selected=True)
+ else:
+ self.select_address.add_option('Select one', 'none')
+ for a in self.user.addresses:
+ if not a.deleted:
+ if self.value == str(a.id):
+ self.select_address.add_option(a.desc, str(a.id), selected=True)
+ # display this address
+ address_html = '''<div class="form-row">
+ %s
+ </div>''' % a.get_html()
+ else:
+ self.select_address.add_option(a.desc, str(a.id))
+ if self.value == 'new':
+ self.select_address.add_option('Add a new address', 'new', selected=True)
+ for field_name, label in self.fields():
+ add_field = TextField(self.name+'_'+field_name,
+ 40,
+ util.restore_text( self.params.get( self.name+'_'+field_name, '' ) ))
+ address_html += ''' <div class="form-row">
+ <label>%s</label>
+ %s
+ </div>
+ ''' % (label, add_field.get_html())
+ else:
+ self.select_address.add_option('Add a new address', 'new')
+ return self.select_address.get_html()+address_html
def get_suite():
diff -r 2489f9da0d29 -r 397800eff312 lib/galaxy/web/framework/helpers/grids.py
--- a/lib/galaxy/web/framework/helpers/grids.py Thu Aug 06 15:19:02 2009 -0400
+++ b/lib/galaxy/web/framework/helpers/grids.py Thu Aug 06 15:25:18 2009 -0400
@@ -43,6 +43,8 @@
query = column.filter( query, column_filter, filter_args )
# Carry filter along to newly generated urls
extra_url_args[ "f-" + column.key ] = column_filter
+ if filter_args:
+ query = query.filter_by( **filter_args )
# Process sort arguments
sort_key = sort_order = None
if 'sort' in kwargs:
diff -r 2489f9da0d29 -r 397800eff312 static/june_2007_style/blue/library.css
--- a/static/june_2007_style/blue/library.css Thu Aug 06 15:19:02 2009 -0400
+++ b/static/june_2007_style/blue/library.css Thu Aug 06 15:25:18 2009 -0400
@@ -12,4 +12,6 @@
pre.peek{background:white;color:black;width:100%;overflow:auto;}
pre.peek th{color:white;background:#023858;}
a.expandLink{text-decoration:none;}
-span.expandLink{width:100%;height:100%;display:block;}
+span.expandLink{width:16px;height:16px;display:inline-block;vertical-align:middle;background:url(../images/silk/resultset_next.png);}
+.folderRow.expanded span.expandLink{background:url(../images/silk/resultset_bottom.png);}
+.folderRow span.rowIcon{width:16px;height:16px;display:inline-block;vertical-align:middle;background:url(../images/silk/folder.png);}
diff -r 2489f9da0d29 -r 397800eff312 static/june_2007_style/library.css.tmpl
--- a/static/june_2007_style/library.css.tmpl Thu Aug 06 15:19:02 2009 -0400
+++ b/static/june_2007_style/library.css.tmpl Thu Aug 06 15:25:18 2009 -0400
@@ -69,7 +69,22 @@
}
span.expandLink {
- width: 100%;
- height: 100%;
- display: block;
+ width: 16px;
+ height: 16px;
+ display: inline-block;
+ vertical-align: middle;
+ background: url(../images/silk/resultset_next.png);
}
+
+.folderRow.expanded span.expandLink {
+ background: url(../images/silk/resultset_bottom.png);
+}
+
+.folderRow span.rowIcon {
+ width: 16px;
+ height: 16px;
+ display: inline-block;
+ vertical-align: middle;
+ background: url(../images/silk/folder.png);
+}
+
diff -r 2489f9da0d29 -r 397800eff312 static/june_2007_style/process_css.py
--- a/static/june_2007_style/process_css.py Thu Aug 06 15:19:02 2009 -0400
+++ b/static/june_2007_style/process_css.py Thu Aug 06 15:25:18 2009 -0400
@@ -139,7 +139,7 @@
pad = 10
- class SpriteGroup():
+ class SpriteGroup( object ):
def __init__( self, name ):
self.name = name
self.offset = 0
@@ -152,7 +152,7 @@
self.offset += sprite.image.size[1] + pad
return sprite
- class Sprite():
+ class Sprite( object ):
def __init__( self, fname, offset ):
self.fname = fname
self.image = Image.open( os.path.join( image_dir, fname ) )
diff -r 2489f9da0d29 -r 397800eff312 templates/admin/forms/create_form.mako
--- a/templates/admin/forms/create_form.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/admin/forms/create_form.mako Thu Aug 06 15:25:18 2009 -0400
@@ -26,7 +26,7 @@
<div style="clear: both"></div>
</div>
<div class="form-row">
- <input type="submit" name="save_form" value="Save"/>
+ <input type="submit" name="save_form" value="Add fields"/>
</div>
</form>
</div>
diff -r 2489f9da0d29 -r 397800eff312 templates/admin/forms/edit_form.mako
--- a/templates/admin/forms/edit_form.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/admin/forms/edit_form.mako Thu Aug 06 15:25:18 2009 -0400
@@ -84,7 +84,7 @@
<div style="clear: both"></div>
</div>
%endfor
- <div class="toolFormTitle">Sample fields (${len(form.fields)})</div>
+ <div class="toolFormTitle">Fields (${len(form.fields)})</div>
%for ctr, field in enumerate(field_details):
${render_field( ctr, field )}
%endfor
diff -r 2489f9da0d29 -r 397800eff312 templates/admin/forms/manage_forms.mako
--- a/templates/admin/forms/manage_forms.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/admin/forms/manage_forms.mako Thu Aug 06 15:25:18 2009 -0400
@@ -3,6 +3,10 @@
<%def name="title()">Manage Form Definitions</%def>
+
+%if msg:
+ ${render_msg( msg, messagetype )}
+%endif
## Render a row
<%def name="render_row( form, ctr )">
@@ -12,11 +16,18 @@
<tr>
%endif
<td>
- <b><a href="${h.url_for( controller='forms', action='edit', form_id=form.id, read_only=True )}">${form.name}</a></b>
+ <a href="${h.url_for( controller='forms', action='edit', form_id=form.id, read_only=True )}">${form.name}</a>
<a id="form-${form.id}-popup" class="popup-arrow" style="display: none;">▼</a>
- <div popupmenu="form-${form.id}-popup">
- <a class="action-button" href="${h.url_for( action='edit', form_id=form.id, show_form=True )}">Edit form definition</a>
- </div>
+ %if form.form_definition_current.deleted:
+ <div popupmenu="form-${form.id}-popup">
+ <a class="action-button" href="${h.url_for( action='undelete', form_id=form.id )}">Undelete</a>
+ </div>
+ %else:
+ <div popupmenu="form-${form.id}-popup">
+ <a class="action-button" href="${h.url_for( action='edit', form_id=form.id, show_form=True )}">Edit form definition</a>
+ <a class="action-button" confirm="Click OK to delete the form ${form.name}." href="${h.url_for( action='delete', form_id=form.id )}">Delete</a>
+ </div>
+ %endif
</td>
<td><i>${form.desc}</i></td>
</tr>
@@ -24,36 +35,33 @@
<h2>
- %if deleted:
- Deleted
- %endif
Forms
</h2>
-
-
<ul class="manage-table-actions">
- %if not deleted:
- <li>
- <a class="action-button" href="${h.url_for( controller='forms', action='new', new=True )}">
- <img src="${h.url_for('/static/images/silk/add.png')}" />
- <span>Define a new form</span></a>
- </li>
- %endif
+ <li>
+ <a class="action-button" href="${h.url_for( controller='forms', action='new', new=True )}">
+ <img src="${h.url_for('/static/images/silk/add.png')}" />
+ <span>Define a new form</span></a>
+ </li>
</ul>
-
-%if msg:
- ${render_msg( msg, messagetype )}
-%endif
-
+<div class="grid-header">
+ ##<span class="title">Filter:</span>
+ %for i, filter in enumerate( ['Active', 'Deleted', 'All'] ):
+ %if i > 0:
+ <span>|</span>
+ %endif
+ %if show_filter == filter:
+ <span class="filter"><a href="${h.url_for( controller='forms', action='manage', show_filter=filter )}"><b>${filter}</b></a></span>
+ %else:
+ <span class="filter"><a href="${h.url_for( controller='forms', action='manage', show_filter=filter )}">${filter}</a></span>
+ %endif
+ %endfor
+</div>
%if not fdc_list:
- %if deleted:
- There are no deleted forms
- %else:
- There are no forms.
- %endif
+ There are no forms.
%else:
<table class="grid">
<thead>
@@ -70,4 +78,4 @@
%endfor
</tbody>
</table>
-%endif
+%endif
\ No newline at end of file
diff -r 2489f9da0d29 -r 397800eff312 templates/admin/requests/grid.mako
--- a/templates/admin/requests/grid.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/admin/requests/grid.mako Thu Aug 06 15:25:18 2009 -0400
@@ -76,15 +76,27 @@
<div class="grid-header">
<h2>${grid.title}</h2>
-## %if len(query.all()):
-## <span class="title">Filter:</span>
-## %for i, filter in enumerate( grid.standard_filters ):
-## %if i > 0:
-## <span>|</span>
-## %endif
-## <span class="filter"><a href="${url( filter.get_url_args() )}">${filter.label}</a></span>
-## %endfor
-## %endif
+ ##%if len(query.all()):
+ ##<span class="title">Filter:</span>
+ %for i, filter in enumerate( grid.standard_filters ):
+ %if i > 0:
+ <span>|</span>
+ %endif
+ %if 'state' in grid.default_filter:
+ %if grid.default_filter['state'] == filter.label:
+ <span class="filter"><a href="${h.url_for( controller='requests_admin', action='list', show_filter=filter.label )}"><b>${filter.label}</b></a></span>
+ %else:
+ <span class="filter"><a href="${h.url_for( controller='requests_admin', action='list', show_filter=filter.label )}">${filter.label}</a></span>
+ %endif
+ %else:
+ %if filter.label == 'All':
+ <span class="filter"><a href="${h.url_for( controller='requests_admin', action='list', show_filter=filter.label )}"><b>${filter.label}</b></a></span>
+ %else:
+ <span class="filter"><a href="${h.url_for( controller='requests_admin', action='list', show_filter=filter.label )}">${filter.label}</a></span>
+ %endif
+ %endif
+ %endfor
+ ##%endif
</div>
@@ -95,7 +107,7 @@
<table class="grid">
<thead>
<tr>
- <th></th>
+ ##<th></th>
%for column in grid.columns:
%if column.visible:
<%
@@ -137,9 +149,9 @@
%endif
>
## Item selection column
- <td style="width: 1.5em;">
- <input type="checkbox" name="id" value=${trans.security.encode_id( item.id )} class="grid-row-select-checkbox" />
- </td>
+ ##<td style="width: 1.5em;">
+ ## <input type="checkbox" name="id" value=${trans.security.encode_id( item.id )} class="grid-row-select-checkbox" />
+ ##</td>
## Data columns
%for column in grid.columns:
%if column.visible:
diff -r 2489f9da0d29 -r 397800eff312 templates/admin/requests/manage_request_types.mako
--- a/templates/admin/requests/manage_request_types.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/admin/requests/manage_request_types.mako Thu Aug 06 15:25:18 2009 -0400
@@ -3,10 +3,11 @@
<%def name="title()">request Types</%def>
+%if msg:
+ ${render_msg( msg, messagetype )}
+%endif
+
<h2>
- %if deleted:
- Deleted
- %endif
Request Types
</h2>
@@ -16,16 +17,21 @@
</li>
</ul>
-%if msg:
- ${render_msg( msg, messagetype )}
-%endif
-
+<div class="grid-header">
+ ##<span class="title">Filter:</span>
+ %for i, filter in enumerate( ['Active', 'Deleted', 'All'] ):
+ %if i > 0:
+ <span>|</span>
+ %endif
+ %if show_filter == filter:
+ <span class="filter"><a href="${h.url_for( controller='admin', action='manage_request_types', show_filter=filter )}"><b>${filter}</b></a></span>
+ %else:
+ <span class="filter"><a href="${h.url_for( controller='admin', action='manage_request_types', show_filter=filter )}">${filter}</a></span>
+ %endif
+ %endfor
+</div>
%if not request_types:
- %if deleted:
- There are no deleted request types
- %else:
- There are no request types.
- %endif
+ There are no request types.
%else:
<table class="grid">
<thead>
@@ -39,7 +45,19 @@
<tbody>
%for request_type in request_types:
<tr>
- <td><b><a href="${h.url_for( controller='admin', action='request_type', edit='True', id=request_type.id)}">${request_type.name}</a></b></td>
+ <td>
+ <a href="${h.url_for( controller='admin', action='request_type', edit='True', id=request_type.id)}">${request_type.name}</a>
+ <a id="request_type-${request_type.id}-popup" class="popup-arrow" style="display: none;">▼</a>
+ %if request_type.deleted:
+ <div popupmenu="request_type-${request_type.id}-popup">
+ <a class="action-button" href="${h.url_for( action='undelete_request_type', request_type_id=request_type.id )}">Undelete</a>
+ </div>
+ %else:
+ <div popupmenu="request_type-${request_type.id}-popup">
+ <a class="action-button" confirm="Click OK to delete the request type ${request_type.name}." href="${h.url_for( action='delete_request_type', request_type_id=request_type.id )}">Delete</a>
+ </div>
+ %endif
+ </td>
<td><i>${request_type.desc}</i></td>
<td><a href="${h.url_for( controller='forms', action='edit', form_id=request_type.request_form.id, read_only=True)}">${request_type.request_form.name}</a></td>
<td><a href="${h.url_for( controller='forms', action='edit', form_id=request_type.sample_form.id, read_only=True)}">${request_type.sample_form.name}</a></td>
diff -r 2489f9da0d29 -r 397800eff312 templates/admin/samples/bar_codes.mako
--- a/templates/admin/samples/bar_codes.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/admin/samples/bar_codes.mako Thu Aug 06 15:25:18 2009 -0400
@@ -1,12 +1,14 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
-<h2>Bar codes for Samples of Request "${request.name}"</h2>
-<h3>User: ${user.email}</h3>
%if msg:
${render_msg( msg, messagetype )}
%endif
+
+
+<h2>Bar codes for Samples of Request "${request.name}"</h2>
+<h3>User: ${user.email}</h3>
<ul class="manage-table-actions">
<li>
@@ -31,7 +33,7 @@
<td><b><a>${sample.name}</a></b></td>
<td><a>${sample.desc}</a></td>
<td>
- <input type="text" name="sample_${index}_bar_code" value=${sample.bar_code} size="40"/>
+ ${widgets[index].get_html()}
</td>
</tr>
%endfor
diff -r 2489f9da0d29 -r 397800eff312 templates/base_panels.mako
--- a/templates/base_panels.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/base_panels.mako Thu Aug 06 15:25:18 2009 -0400
@@ -149,15 +149,17 @@
${tab( "workflow", "Workflow", h.url_for( controller='workflow', action='index' ))}
${tab( "libraries", "Libraries", h.url_for( controller='library', action='index' ))}
-
- <td class="tab">
- <a>Lab</a>
- <div class="submenu">
- <ul>
- <li><a target="requests" href="${h.url_for( controller='requests', action='index' )}">Sequencing Requests</a></li>
- </ul>
- </div>
- </td>
+
+ %if trans.request_types():
+ <td class="tab">
+ <a>Lab</a>
+ <div class="submenu">
+ <ul>
+ <li><a target="requests" href="${h.url_for( controller='requests', action='index' )}">Sequencing Requests</a></li>
+ </ul>
+ </div>
+ </td>
+ %endif
%if app.config.get_bool( 'enable_tracks', False ):
<td class="tab">
diff -r 2489f9da0d29 -r 397800eff312 templates/dataset/errors.mako
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/dataset/errors.mako Thu Aug 06 15:25:18 2009 -0400
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>Dataset generation errors</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <link href="/static/style/base.css" rel="stylesheet" type="text/css" />
+ <style>
+ pre
+ {
+ background: white;
+ color: black;
+ border: dotted black 1px;
+ overflow: auto;
+ padding: 10px;
+ }
+ </style>
+ </head>
+
+ <body>
+ <h2>Dataset generation errors</h2>
+ <p><b>Dataset ${dataset.hid}: ${dataset.display_name()}</b></p>
+
+ %if dataset.creating_job_associations:
+ <% job = dataset.creating_job_associations[0].job %>
+ %if job.traceback:
+ The Galaxy framework encountered the following error while attempting to run the tool:
+ <pre>${job.traceback}</pre>
+ %endif
+ %if job.stderr or job.info:
+ Tool execution generated the following error message:
+ %if job.stderr:
+ <pre>${job.stderr}</pre>
+ %elif job.info:
+ <pre>${job.info}</pre>
+ %endif
+ %else:
+ Tool execution did not generate any error messages.
+ %endif
+ %if job.stdout:
+ The tool produced the following additional output:
+ <pre>${job.stdout}</pre>
+ %endif
+ %else:
+ The tool did not create any additional job / error info.
+ %endif
+
+ <h2>Report this error to the Galaxy Team</h2>
+ <p>
+ The Galaxy team regularly reviews errors that occur in the application.
+ However, if you would like to provide additional information (such as
+ what you were trying to do when the error occurred) and a contact e-mail
+ address, we will be better able to investigate your problem and get back
+ to you.
+ </p>
+ <div class="toolForm">
+ <div class="toolFormTitle">Error Report</div>
+ <div class="toolFormBody">
+ <form name="report_error" action="${h.url_for( action='report_error')}" method="post" >
+ <input type="hidden" name="id" value="${dataset.id}" />
+ <div class="form-row">
+ <label>Your email</label>
+ <input type="text" name="email" size="40" />
+ </div>
+ <div class="form-row">
+ <label>Message</label>
+ <textarea name="message", rows="10" cols="40" />
+ </div>
+ </form>
+ </div>
+ </div>
+ </body>
+</html>
diff -r 2489f9da0d29 -r 397800eff312 templates/dataset/errors.tmpl
--- a/templates/dataset/errors.tmpl Thu Aug 06 15:19:02 2009 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
- <head>
- <title>Dataset generation errors</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link href="/static/style/base.css" rel="stylesheet" type="text/css" />
- <style>
- pre
- {
- background: white;
- color: black;
- border: dotted black 1px;
- overflow: auto;
- padding: 10px;
- }
- </style>
- </head>
-
- <body>
- <h2>Dataset generation errors</h2>
- <p><b>Dataset $dataset.hid: $dataset.display_name</b></p>
-
- #if $dataset.creating_job_associations
- #set job = $dataset.creating_job_associations[0].job
- #if job.traceback
- The Galaxy framework encountered the following error while attempting to run the tool:
- <pre>${job.traceback}</pre>
- #end if
- #if $job.stderr or $job.info
- Tool execution generated the following error message:
- #if $job.stderr
- <pre>${job.stderr}</pre>
- #elif $job.info
- <pre>${job.info}</pre>
- #end if
- #else
- Tool execution did not generate any error messages.
- #end if
- #if $job.stdout
- The tool produced the following additional output:
- <pre>${job.stdout}</pre>
- #end if
- #else
- The tool did not create any additional job / error info.
- #end if
-
- <h2>Report this error to the Galaxy Team</h2>
- <p>
- The Galaxy team regularly reviews errors that occur in the application.
- However, if you would like to provide additional information (such as
- what you were trying to do when the error occurred) and a contact e-mail
- address, we will be better able to investigate your problem and get back
- to you.
- </p>
- <div class="toolForm">
- <div class="toolFormTitle">Error Report</div>
- <div class="toolFormBody">
- <form name="report_error" action="${h.url_for( action='report_error')}" method="post" >
- <input type="hidden" name="id" value="$dataset.id" />
- <table>
- <tr valign="top"><td>Your Email:</td><td><input type="text" name="email" size="40" /></td></tr>
- <tr valign="top"><td>Message:</td><td><textarea name="message", rows="10" cols="40" /></textarea></td></tr>
- <tr><td></td><td><input type="submit" value="Report">
- </table>
- </form>
- </div>
- </div>
- </body>
-</html>
diff -r 2489f9da0d29 -r 397800eff312 templates/dataset/validation.tmpl
--- a/templates/dataset/validation.tmpl Thu Aug 06 15:19:02 2009 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-
-<head>
-<title>Galaxy</title>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link href="/static/style/base.css" rel="stylesheet" type="text/css" />
-<script type="text/javascript" src="/static/universe.js">var dummy1=0;</script>
-</head>
-
-<body onLoad="frame_dw();">
-
-<div class="toolForm">
- <div class="toolFormTitle">Dataset Errors: $data.name</div>
- <div class="toolFormBody">
- <form action="/dataset_errors" method="post" >
-
- <table>
- <tr><td>Name:</td><td>$data.name</td></tr>
- <tr><td>Info:</td><td>$data.info<input type="hidden" name="id" value="$data.id"></td></tr>
- <tr><td>Errors:</td><td>$len($data.validation_errors)</td></tr>
- </table>
- #if len($data.validation_errors) > 0:
- <table>
- <tr><td>Displaying the first 10 errors:</td></tr>
- #for count in range(min(len($data.validation_errors),10)):
- <tr><td>$data.validation_errors[count].message</td></tr>
- #end for
- #if $data.datatype.repair_methods($data):
- #for $option, $description in $data.datatype.repair_methods($data):
- <tr><td><input type="checkbox" name="$option" value="true" />$description</td></tr>
- #end for
- <tr><td><input type="submit" name="fix_errors" value="Submit"></td></tr>
- #end if
- </table>
- #end if
- </form>
- </div>
-</div>
-
-
-</body>
-
-</html>
\ No newline at end of file
diff -r 2489f9da0d29 -r 397800eff312 templates/library/browse_library.mako
--- a/templates/library/browse_library.mako Thu Aug 06 15:19:02 2009 -0400
+++ b/templates/library/browse_library.mako Thu Aug 06 15:25:18 2009 -0400
@@ -1,5 +1,5 @@
<%inherit file="/base.mako"/>
-<%namespace file="common.mako" import="render_dataset" />
+## <%namespace file="common.mako" import="render_dataset" />
<%namespace file="/message.mako" import="render_msg" />
<% from galaxy import util %>
@@ -10,102 +10,144 @@
</%def>
<%
+
def name_sorted( l ):
return sorted( l, lambda a, b: cmp( a.name.lower(), b.name.lower() ) )
+
+class RowCounter( object ):
+ def __init__( self ):
+ self.count = 0
+ def increment( self ):
+ self.count += 1
+ def __str__( self ):
+ return str( self.count )
+
%>
<script type="text/javascript">
$( document ).ready( function () {
- // Check/uncheck boxes in subfolders.
- $("input.folderCheckbox").click( function() {
- if ( $(this).is(":checked") ) {
- //$(this).parent().children().find("input[type=checkbox]").each( function() { this.checked = true; });
- $(this).parent().next("ul").find("input[type=checkbox]").each( function() { this.checked = true; });
- } else {
- //$(this).parent().children().find("input[type=checkbox]").each( function() { this.checked = false; });
- $(this).parent().next("ul").find("input[type=checkbox]").each( function() { this.checked = false; });
- }
- });
- // If you uncheck a lower level checkbox, uncheck the boxes above it
- // (since deselecting a child means the parent is not fully selected any
- // more).
- $("input[type=checkbox]").click( function() {
- if ( ! $(this).is(":checked") ) {
- //var folder_rows = $(this).parents("ul").next("li.folderRow");
- //var folder_rows = $(this).parents("ul").children("li.folderRow");
- var folder_rows = $(this).parents("ul").prev("li.folderRow");
- //$(folder_rows).children("input[type=checkbox]").not(this).each( function() {
- $(folder_rows).find("input[type=checkbox]").each( function() {
- this.checked = false;
+ $("#library-grid").each( function() {
+ // Recursively fill in children and descendents of each row
+ var process_row = function( q, parents ) {
+ // Find my index
+ var index = $(q).parent().children().index( $(q) );
+ // Find my immediate children
+ var children = $(q).siblings().filter( "[parent='" + index + "']" );
+ // Recursively handle them
+ var descendents = children;
+ children.each( function() {
+ child_descendents = process_row( $(this), parents.add( q ) );
+ descendents = descendents.add( child_descendents );
});
- }
- });
- // Handle the hide/show triangles
- $("span.expandLink").wrap( "<a href='#' class='expandLink'></a>" ).click( function() {
- var contents = $(this).parents("li:first").next("ul");
- if ( this.id == "libraryRow" ) {
- var icon_open = "${h.url_for( '/static/images/silk/book_open.png' )}";
- var icon_closed = "${h.url_for( '/static/images/silk/book.png' )}";
- } else {
- var icon_open = "${h.url_for( '/static/images/silk/folder_page.png' )}";
- var icon_closed = "${h.url_for( '/static/images/silk/folder.png' )}";
- }
- if ( contents.is(":visible") ) {
- contents.slideUp("fast");
- $(this).find("img.expanderIcon").each( function() { this.src = "${h.url_for( '/static/images/silk/resultset_next.png' )}"; });
- $(this).find("img.rowIcon").each( function() { this.src = icon_closed; });
- } else {
- contents.slideDown("fast");
- $(this).find("img.expanderIcon").each( function() { this.src = "${h.url_for( '/static/images/silk/resultset_bottom.png' )}"; });
- $(this).find("img.rowIcon").each( function() { this.src = icon_open; });
- }
- });
- // Hide all dataset bodies
- $("div.historyItemBody").hide();
- // Handle the dataset body hide/show link.
- $("div.historyItemWrapper").each( function() {
- var id = this.id;
- var li = $(this).parent();
- var body = $(this).children( "div.historyItemBody" );
- var peek = body.find( "pre.peek" )
- $(this).children( ".historyItemTitleBar" ).find( ".historyItemTitle" ).wrap( "<a href='#'></a>" ).click( function() {
- if ( body.is(":visible") ) {
- if ( $.browser.mozilla ) { peek.css( "overflow", "hidden" ) }
- body.slideUp( "fast" );
- li.removeClass( "datasetHighlighted" );
- }
- else {
- body.slideDown( "fast", function() {
- if ( $.browser.mozilla ) { peek.css( "overflow", "auto" ); }
- });
- li.addClass( "datasetHighlighted" );
- }
- return false;
- });
+ // Set up expand / hide link
+ $(q).find( "span.expandLink").wrap( "<a href='#' class='expandLink'></a>" ).click( function() {
+ if ( children.is( ":visible" ) ) {
+ descendents.hide();
+ descendents.removeClass( "expanded" );
+ q.removeClass( "expanded" );
+ // expanded = false;
+ } else {
+ children.show();
+ q.addClass( "expanded" );
+ // expanded = true;
+ }
+ });
+ // Check/uncheck boxes in subfolders.
+ q.children( "td" ).children( "input[type=checkbox]" ).click( function() {
+ if ( $(this).is(":checked") ) {
+ descendents.find( "input[type=checkbox]").attr( 'checked', true );
+ } else {
+ descendents.find( "input[type=checkbox]").attr( 'checked', false );
+ // If you uncheck a lower level checkbox, uncheck the boxes above it
+ // (since deselecting a child means the parent is not fully selected any
+ // more).
+ parents.children( "td" ).children( "input[type=checkbox]" ).attr( "checked", false );
+ }
+ });
+ // return descendents for use by parent
+ return descendents;
+ }
+ $(this).find( "tbody tr" ).not( "[parent]").each( function() {
+ descendents = process_row( $(this), $([]) );
+ descendents.hide();
+ });
});
});
</script>
-<![if gte IE 7]>
-<script type="text/javascript">
- $( document ).ready( function() {
- // Add rollover effect to any image with a 'rollover' attribute
- preload_images = {}
- $( "img[rollover]" ).each( function() {
- var r = $(this).attr('rollover');
- var s = $(this).attr('src');
- preload_images[r] = true;
- $(this).hover(
- function() { $(this).attr( 'src', r ) },
- function() { $(this).attr( 'src', s ) }
- )
- })
- for ( r in preload_images ) { $( "<img>" ).attr( "src", r ) }
- })
-</script>
-<![endif]>
+<%def name="render_dataset( library_dataset, selected, library, pad, parent, row_conter )">
+ <%
+ ## The received data must always be a LibraryDataset object, but the object id passed to methods from the drop down menu
+ ## should be the underlying ldda id to prevent id collision ( which could happen when displaying children, which are always
+ ## lddas ). We also need to make sure we're displaying the latest version of this library_dataset, so we display the attributes
+ ## from the ldda.
+ ldda = library_dataset.library_dataset_dataset_association
+ if ldda.user:
+ uploaded_by = ldda.user.email
+ else:
+ uploaded_by = 'anonymous'
+ if ldda == ldda.library_dataset.library_dataset_dataset_association:
+ current_version = True
+ else:
+ current_version = False
+ %>
-<%def name="render_folder( folder, folder_pad, created_ldda_ids, library_id )">
+ <tr class="datasetRow"
+ %if parent is not None:
+ parent="${parent}"
+ style="display: none;"
+ %endif
+ >
+ <td style="padding-left: ${pad+20}px;">
+
+
+ %if selected:
+ <input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/>
+ %else:
+ <input type="checkbox" name="ldda_ids" value="${ldda.id}"/>
+ %endif
+
+ <a href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=library_dataset.folder.id, id=ldda.id, info=True )}"><b>${ldda.name[:60]}</b></a>
+ <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a>
+
+ <div popupmenu="dataset-${ldda.id}-popup">
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=ldda.library_dataset ):
+ <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=library_dataset.folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a>
+ %else:
+ <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=library_dataset.folder.id, id=ldda.id, information=True )}">View this dataset's information</a>
+ %endif
+ ## We're disabling the ability to add templates at the LDDA and LibraryDataset level, but will leave this here for possible future use
+ ##%if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=ldda.library_dataset ):
+ ## <a class="action-button" href="${h.url_for( controller='library', action='info_template', library_id=library.id, library_dataset_id=library_dataset.id, new_template=True )}">Add an information template to this dataset</a>
+ ##%endif
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.DATASET_MANAGE_PERMISSIONS, dataset=ldda.dataset ) and trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MANAGE, library_item=ldda.library_dataset ):
+ <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=library_dataset.folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a>
+ %if current_version and trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=ldda.library_dataset ):
+ <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=library_dataset.folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a>
+ %endif
+ %endif
+ %if ldda.has_data:
+ <a class="action-button" href="${h.url_for( controller='library', action='datasets', library_id=library.id, ldda_ids=str( ldda.id ), do_action='add' )}">Import this dataset into your current history</a>
+ <a class="action-button" href="${h.url_for( controller='library', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a>
+ %endif
+ </div>
+
+ </td>
+ <td>${ldda.message}</td>
+ <td>${uploaded_by}</td>
+ <td>${ldda.create_time.strftime( "%Y-%m-%d" )}</td>
+ </tr>
+
+ <%
+ my_row = row_counter.count
+ row_counter.increment()
+ %>
+
+
+</%def>
+
+
+<%def name="render_folder( folder, folder_pad, created_ldda_ids, library_id, parent=None, row_counter=None )">
<%
def show_folder():
if trans.app.security_agent.check_folder_contents( trans.user, folder ) or trans.app.security_agent.show_library_item( trans.user, folder ):
@@ -119,27 +161,36 @@
else:
pad = folder_pad + 20
if folder_pad == 0:
- expander = "/static/images/silk/resultset_bottom.png"
- folder_img = "/static/images/silk/folder_page.png"
subfolder = False
else:
- expander = "/static/images/silk/resultset_next.png"
- folder_img = "/static/images/silk/folder.png"
subfolder = True
created_ldda_id_list = util.listify( created_ldda_ids )
if created_ldda_id_list:
created_ldda_ids = [ int( ldda_id ) for ldda_id in created_ldda_id_list ]
+ my_row = None
%>
%if not root_folder:
- <li class="folderRow libraryOrFolderRow" style="padding-left: ${pad}px;">
- <input type="checkbox" class="folderCheckbox" style="float: left;"/>
- <div class="rowTitle">
- <span class="expandLink"><img src="${h.url_for( expander )}" class="expanderIcon"/><img src="${h.url_for( folder_img )}" class="rowIcon"/>
+ <tr class="folderRow libraryOrFolderRow"
+ %if parent is not None:
+ parent="${parent}"
+ style="display: none;"
+ %endif
+ >
+ <td style="padding-left: ${folder_pad}px;">
+
+ <span class="expandLink"></span>
+
+ <input type="checkbox" class="folderCheckbox"/>
+
+ <span class="rowIcon"></span>
+
${folder.name}
%if folder.description:
<i>- ${folder.description}</i>
%endif
+
<a id="folder_img-${folder.id}-popup" class="popup-arrow" style="display: none;">▼</a>
+
<div popupmenu="folder_img-${folder.id}-popup">
%if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=folder ):
<a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder.id )}">Add datasets to this folder</a>
@@ -167,125 +218,135 @@
%endif
</div>
</div>
- </li>
+ <td colspan="3"></td>
+ </tr>
+ <%
+ my_row = row_counter.count
+ row_counter.increment()
+ %>
%endif
- %if subfolder:
- <ul id="subFolder" style="display: none;">
- %else:
- <ul>
- %endif
- %for child_folder in name_sorted( folder.active_folders ):
- ${render_folder( child_folder, pad, created_ldda_ids, library_id )}
- %endfor
- %for library_dataset in name_sorted( folder.active_datasets ):
- <%
- selected = created_ldda_ids and library_dataset.library_dataset_dataset_association.id in created_ldda_ids
- %>
- %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.DATASET_ACCESS, dataset=library_dataset.library_dataset_dataset_association.dataset ):
- <li class="datasetRow" style="padding-left: ${pad + 20}px;">${render_dataset( library_dataset, selected, library )}</li>
- %endif
- %endfor
- </ul>
+
1
0
details: http://www.bx.psu.edu/hg/galaxy/rev/73ac2b7cad26
changeset: 2544:73ac2b7cad26
user: Kanwei Li <kanwei(a)gmail.com>
date: Thu Aug 06 14:43:51 2009 -0400
description:
Overview improvements:
- Open/close arrows
- Resizable icon
- Max and min size for overview
3 file(s) affected in this change:
static/images/overview_arrows.png
static/images/resizable.png
templates/workflow/editor.mako
diffs (44 lines):
diff -r db619431fa8f -r 73ac2b7cad26 static/images/overview_arrows.png
Binary file static/images/overview_arrows.png has changed
diff -r db619431fa8f -r 73ac2b7cad26 static/images/resizable.png
Binary file static/images/resizable.png has changed
diff -r db619431fa8f -r 73ac2b7cad26 templates/workflow/editor.mako
--- a/templates/workflow/editor.mako Thu Aug 06 11:32:14 2009 -0400
+++ b/templates/workflow/editor.mako Thu Aug 06 14:43:51 2009 -0400
@@ -119,6 +119,19 @@
workflow.fit_canvas_to_nodes();
scroll_to_nodes();
canvas_manager.draw_overview();
+ });
+
+ /* Lets the viewport be toggled visible and invisible, adjusting the arrows accordingly */
+ $("#close-viewport").click( function() {
+ if ( $("#overview-border").css("right") == "0px" ) {
+ $("#overview-border").css("right", "20000px");
+ $("#close-viewport").css("background-position", "12px 0px");
+
+ } else {
+ $("#overview-border").css("right", "0px");
+ $("#close-viewport").css("background-position", "0px 0px");
+ }
+
});
// Unload handler
@@ -629,7 +642,7 @@
<div id="canvas-viewport" style="width: 100%; height: 100%; position: absolute; overflow: hidden; background: #EEEEEE; background: white url(${h.url_for('/static/images/light_gray_grid.gif')}) repeat;">
<div id="canvas-container" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
- <div id="overview-border" style="position: absolute; width: 150px; height: 150px; right: 0; bottom: 0; border-top: solid gray 1px; border-left: solid grey 1px; padding: 7px 0 0 7px; background: #EEEEEE; z-index: 50000; overflow: hidden;">
+ <div id="overview-border" style="position: absolute; width: 150px; height: 150px; right: 0px; bottom: 0px; border-top: solid gray 1px; border-left: solid grey 1px; padding: 7px 0 0 7px; background: #EEEEEE no-repeat url(${h.url_for('/static/images/resizable.png')}); z-index: 20000; overflow: hidden; max-width: 300px; max-height: 300px; min-width: 50px; min-height: 50px">
<div style="position: relative; overflow: hidden; width: 100%; height: 100%; border-top: solid gray 1px; border-left: solid grey 1px;">
<div id="overview" style="position: absolute;">
<canvas width="0" height="0" style="background: white; width: 100%; height: 100%;" id="overview-canvas"></canvas>
@@ -637,6 +650,7 @@
</div>
</div>
</div>
+ <div id="close-viewport" style="border-left: 1px solid #999; border-top: 1px solid #999; background: #ddd url(${h.url_for('/static/images/overview_arrows.png')}); position: absolute; right: 0px; bottom: 0px; width: 12px; height: 12px; z-index: 25000;"></div>
</div>
</%def>
1
0
details: http://www.bx.psu.edu/hg/galaxy/rev/db619431fa8f
changeset: 2543:db619431fa8f
user: Kanwei Li <kanwei(a)gmail.com>
date: Thu Aug 06 11:32:14 2009 -0400
description:
Remove redundant icon
1 file(s) affected in this change:
static/june_2007_style/blue/tiny_arror_right.png
diffs (2 lines):
diff -r 5e608f42dc88 -r db619431fa8f static/june_2007_style/blue/tiny_arror_right.png
Binary file static/june_2007_style/blue/tiny_arror_right.png has changed
1
0
10 Aug '09
details: http://www.bx.psu.edu/hg/galaxy/rev/5e608f42dc88
changeset: 2542:5e608f42dc88
user: Kanwei Li <kanwei(a)gmail.com>
date: Mon Aug 03 18:57:13 2009 -0400
description:
Grid: Age -> Created, for dates further than a week ago, display actual date
2 file(s) affected in this change:
lib/galaxy/web/controllers/history.py
lib/galaxy/web/framework/helpers/__init__.py
diffs (36 lines):
diff -r 5003b7d10ff5 -r 5e608f42dc88 lib/galaxy/web/controllers/history.py
--- a/lib/galaxy/web/controllers/history.py Mon Aug 03 17:35:44 2009 -0400
+++ b/lib/galaxy/web/controllers/history.py Mon Aug 03 18:57:13 2009 -0400
@@ -47,8 +47,8 @@
attach_popup=True ),
DatasetsByStateColumn( "Datasets (by state)", ncells=4 ),
StatusColumn( "Status", attach_popup=False ),
- grids.GridColumn( "Age", key="create_time", format=time_ago ),
- grids.GridColumn( "Last update", key="update_time", format=time_ago ),
+ grids.GridColumn( "Created", key="create_time", format=time_ago ),
+ grids.GridColumn( "Last Updated", key="update_time", format=time_ago ),
# Valid for filtering but invisible
grids.GridColumn( "Deleted", key="deleted", visible=False )
]
diff -r 5003b7d10ff5 -r 5e608f42dc88 lib/galaxy/web/framework/helpers/__init__.py
--- a/lib/galaxy/web/framework/helpers/__init__.py Mon Aug 03 17:35:44 2009 -0400
+++ b/lib/galaxy/web/framework/helpers/__init__.py Mon Aug 03 18:57:13 2009 -0400
@@ -3,10 +3,16 @@
pkg_resources.require( "WebHelpers" )
from webhelpers import *
-from datetime import datetime
+from datetime import datetime, timedelta
+# If the date is more than one week ago, then display the actual date instead of in words
def time_ago( x ):
- return date.distance_of_time_in_words( x, datetime.utcnow() )
+ delta = timedelta(weeks=1)
+
+ if (datetime.utcnow() - x) > delta: # Greater than a week difference
+ return x.strftime("%b %d, %Y")
+ else:
+ return date.distance_of_time_in_words( x, datetime.utcnow() ) + " ago"
def iff( a, b, c ):
if a:
1
0
details: http://www.bx.psu.edu/hg/galaxy/rev/c819c7c0c1a6
changeset: 2540:c819c7c0c1a6
user: rc
date: Thu Aug 06 10:34:01 2009 -0400
description:
Cleaned up unwanted code
2 file(s) affected in this change:
lib/galaxy/model/mapping.py
lib/galaxy/model/migrate/versions/0012_user_address.py
diffs (72 lines):
diff -r 24ccfa887fcd -r c819c7c0c1a6 lib/galaxy/model/mapping.py
--- a/lib/galaxy/model/mapping.py Thu Aug 06 09:52:59 2009 -0400
+++ b/lib/galaxy/model/mapping.py Thu Aug 06 10:34:01 2009 -0400
@@ -598,13 +598,6 @@
Column( "state", TrimmedString( 255 ), index=True ),
Column( "deleted", Boolean, index=True, default=False ) )
-RequestState_table = Table('request_state', metadata,
- Column( "id", Integer, primary_key=True),
- Column( "create_time", DateTime, default=now ),
- Column( "update_time", DateTime, default=now, onupdate=now ),
- Column( "name", TrimmedString( 255 ), nullable=False ),
- Column( "desc", TEXT ))
-
Sample.table = Table('sample', metadata,
Column( "id", Integer, primary_key=True),
Column( "create_time", DateTime, default=now ),
diff -r 24ccfa887fcd -r c819c7c0c1a6 lib/galaxy/model/migrate/versions/0012_user_address.py
--- a/lib/galaxy/model/migrate/versions/0012_user_address.py Thu Aug 06 09:52:59 2009 -0400
+++ b/lib/galaxy/model/migrate/versions/0012_user_address.py Thu Aug 06 10:34:01 2009 -0400
@@ -40,13 +40,6 @@
Column( "deleted", Boolean, index=True, default=False ),
Column( "purged", Boolean, index=True, default=False ) )
-#RequestState_table = Table('request_state', metadata,
-# Column( "id", Integer, primary_key=True),
-# Column( "create_time", DateTime, default=now ),
-# Column( "update_time", DateTime, default=now, onupdate=now ),
-# Column( "name", TrimmedString( 255 ), nullable=False ),
-# Column( "desc", TEXT ))
-
def upgrade():
# Load existing tables
metadata.reflect()
@@ -56,10 +49,6 @@
UserAddress_table.create()
except Exception, e:
log.debug( "Creating user_address table failed: %s" % str( e ) )
-# try:
-# RequestState_table.create()
-# except Exception, e:
-# log.debug( "Creating request_state table failed: %s" % str( e ) )
# Add 1 column to the request_type table
try:
@@ -92,25 +81,7 @@
assert col is Request_table.c.state
except Exception, e:
log.debug( "Adding column 'state' to request table failed: %s" % ( str( e ) ) )
-#
-# # new column which points to the current state in the request_state table
-# try:
-# col = Column( "request_state_id", Integer, index=True )
-# col.create( Request_table )
-# assert col is Request_table.c.request_state_id
-# except Exception, e:
-# log.debug( "Adding column 'request_state_id' to request table failed: %s" % ( str( e ) ) )
-# # Add 1 foreign key constraint to the form_definition_current table
-# if RequestState_table and Request_table:
-# try:
-# cons = ForeignKeyConstraint( [Request_table.c.request_state_id],
-# [RequestState_table.c.id],
-# name='request_request_state_id_fk' )
-# # Create the constraint
-# cons.create()
-# except Exception, e:
-# log.debug( "Adding foreign key constraint 'request_request_state_id_fk' to table 'request' failed: %s" % ( str( e ) ) )
-
+
def downgrade():
pass
1
0