Merge pull request #5114 from guerler/remove_formbuilder

Remove html formbuilder from backend
This commit is contained in:
Dannon Baker
2017-12-11 16:53:46 -05:00
committed by GitHub
50 changed files with 161 additions and 1276 deletions
@@ -48,7 +48,7 @@ var ToolShedRepositoryView = Backbone.View.extend({
this.options.tps_select_options = this.templatePanelSelectOptions;
this.options.tool_dependencies = models.get("tool_dependencies");
this.options.shed_tool_conf = this.templateShedToolConf({
stc_html: models.get("shed_conf")
shed_tool_confs: models.get("shed_conf")
});
this.options.panel_section_dict = models.get("panel_section_dict");
this.options.api_url = `${Galaxy.root}api/tool_shed_repositories/install?async=True`;
@@ -474,7 +474,11 @@ var ToolShedRepositoryView = Backbone.View.extend({
'<div class="toolFormTitle">Shed tool configuration file:</div>',
'<div class="toolFormBody">',
'<div class="form-row">',
"<%= stc_html %>",
'<select name="shed_tool_conf">',
"<% _.each(shed_tool_confs.options, function(conf) { %>",
'<option value="<%= conf.value %>"><%= conf.label %></option>',
"<% }); %>",
'</select>',
'<div class="toolParamHelp" style="clear: both;">Select the file whose <b>tool_path</b> setting you want used for installing repositories.</div>',
"</div>",
"</div>"
+3 -270
View File
@@ -5,7 +5,6 @@ Naming: try to use class names that have a distinct plural form so that
the relationship cardinalities are obvious (e.g. prefer Dataset to Data)
"""
import errno
import json
import logging
import numbers
import operator
@@ -30,8 +29,8 @@ from galaxy.managers import tags
from galaxy.model.item_attrs import UsesAnnotations
from galaxy.model.util import pgcalc
from galaxy.security import get_permitted_actions
from galaxy.util import (directory_hash_id, Params, ready_name_for_url,
restore_text, unicodify, unique_id)
from galaxy.util import (directory_hash_id, ready_name_for_url,
unicodify, unique_id)
from galaxy.util.bunch import Bunch
from galaxy.util.dictifiable import Dictifiable
from galaxy.util.hash_util import new_secure_hash
@@ -2667,32 +2666,6 @@ class Library(object, Dictifiable, HasName):
active_folders.extend(self.get_active_folders(active_folder, folders))
return sort_by_attr(active_folders, 'id')
def get_info_association(self, restrict=False, inherited=False):
if self.info_association:
if not inherited or self.info_association[0].inheritable:
return self.info_association[0], inherited
else:
return None, inherited
return None, inherited
def get_template_widgets(self, trans, get_contents=True):
# See if we have any associated templates - the returned value for
# inherited is not applicable at the library level. The get_contents
# param is passed by callers that are inheriting a template - these
# are usually new library datsets for which we want to include template
# fields on the upload form, but not necessarily the contents of the
# inherited template saved for the parent.
info_association, inherited = self.get_info_association()
if info_association:
template = info_association.template
if get_contents:
# See if we have any field contents
info = info_association.info
if info:
return template.get_widgets(trans.user, contents=info.content)
return template.get_widgets(trans.user)
return []
def get_access_roles(self, trans):
roles = []
for lp in self.actions:
@@ -2723,51 +2696,6 @@ class LibraryFolder(object, Dictifiable, HasName):
folder.order_id = self.item_count
self.item_count += 1
def get_info_association(self, restrict=False, inherited=False):
# If restrict is True, we will return this folder's info_association, not inheriting.
# If restrict is False, we'll return the next available info_association in the
# inheritable hierarchy if it is "inheritable". True is also returned if the
# info_association was inherited and False if not. This enables us to eliminate
# displaying any contents of the inherited template.
if self.info_association:
if not inherited or self.info_association[0].inheritable:
return self.info_association[0], inherited
else:
return None, inherited
if restrict:
return None, inherited
if self.parent:
return self.parent.get_info_association(inherited=True)
if self.library_root:
return self.library_root[0].get_info_association(inherited=True)
return None, inherited
def get_template_widgets(self, trans, get_contents=True):
# See if we have any associated templates. The get_contents
# param is passed by callers that are inheriting a template - these
# are usually new library datsets for which we want to include template
# fields on the upload form.
info_association, inherited = self.get_info_association()
if info_association:
if inherited:
template = info_association.template.current.latest_form
else:
template = info_association.template
# See if we have any field contents, but only if the info_association was
# not inherited ( we do not want to display the inherited contents ).
# (gvk: 8/30/10) Based on conversations with Dan, we agreed to ALWAYS inherit
# contents. We'll use this behavior until we hear from the community that
# contents should not be inherited. If we don't hear anything for a while,
# eliminate the old commented out behavior.
# if not inherited and get_contents:
if get_contents:
info = info_association.info
if info:
return template.get_widgets(trans.user, info.content)
else:
return template.get_widgets(trans.user)
return []
@property
def activatable_library_datasets(self):
# This needs to be a list
@@ -2775,13 +2703,6 @@ class LibraryFolder(object, Dictifiable, HasName):
def to_dict(self, view='collection', value_mapper=None):
rval = super(LibraryFolder, self).to_dict(view=view, value_mapper=value_mapper)
info_association, inherited = self.get_info_association()
if info_association:
if inherited:
template = info_association.template.current.latest_form
else:
template = info_association.template
rval['data_template'] = template.name
rval['library_path'] = self.library_path
rval['parent_library_id'] = self.parent_library.id
return rval
@@ -2855,15 +2776,6 @@ class LibraryDataset(object):
# display in other objects, we can't use the simpler method used by
# other model classes.
ldda = self.library_dataset_dataset_association
template_data = {}
for temp_info in ldda.info_association:
template = temp_info.template
content = temp_info.info.content
tmp_dict = {}
for field in template.fields:
tmp_dict[field['label']] = content[field['name']]
template_data[template.name] = tmp_dict
rval = dict(id=self.id,
ldda_id=ldda.id,
parent_library_id=self.folder.parent_library.id,
@@ -2881,8 +2793,7 @@ class LibraryDataset(object):
genome_build=ldda.dbkey,
misc_info=ldda.info,
misc_blurb=ldda.blurb,
peek=(lambda ldda: ldda.display_peek() if ldda.peek and ldda.peek != 'no peek' else None)(ldda),
template_data=template_data)
peek=(lambda ldda: ldda.display_peek() if ldda.peek and ldda.peek != 'no peek' else None)(ldda))
if ldda.dataset.uuid is None:
rval['uuid'] = None
else:
@@ -2987,19 +2898,6 @@ class LibraryDatasetDatasetAssociation(DatasetInstance, HasName):
def has_manage_permissions_roles(self, trans):
return self.dataset.has_manage_permissions_roles(trans)
def get_info_association(self, restrict=False, inherited=False):
# If restrict is True, we will return this ldda's info_association whether it
# exists or not ( in which case None will be returned ). If restrict is False,
# we'll return the next available info_association in the inheritable hierarchy.
# True is also returned if the info_association was inherited, and False if not.
# This enables us to eliminate displaying any contents of the inherited template.
# SM: Accessing self.info_association can cause a query to be emitted
if self.info_association:
return self.info_association[0], inherited
if restrict:
return None, inherited
return self.library_dataset.folder.get_info_association(inherited=True)
def to_dict(self, view='collection'):
# Since this class is a proxy to rather complex attributes we want to
# display in other objects, we can't use the simpler method used by
@@ -3044,55 +2942,6 @@ class LibraryDatasetDatasetAssociation(DatasetInstance, HasName):
rval['metadata_' + name] = val
return rval
def get_template_widgets(self, trans, get_contents=True):
# See if we have any associated templatesThe get_contents
# param is passed by callers that are inheriting a template - these
# are usually new library datsets for which we want to include template
# fields on the upload form, but not necessarily the contents of the
# inherited template saved for the parent.
info_association, inherited = self.get_info_association()
if info_association:
if inherited:
template = info_association.template.current.latest_form
else:
template = info_association.template
# See if we have any field contents, but only if the info_association was
# not inherited ( we do not want to display the inherited contents ).
# (gvk: 8/30/10) Based on conversations with Dan, we agreed to ALWAYS inherit
# contents. We'll use this behavior until we hear from the community that
# contents should not be inherited. If we don't hear anything for a while,
# eliminate the old commented out behavior.
# if not inherited and get_contents:
if get_contents:
info = info_association.info
if info:
return template.get_widgets(trans.user, info.content)
else:
return template.get_widgets(trans.user)
return []
def templates_dict(self, use_name=False):
"""
Returns a dict of template info
"""
# TODO: Should have a method that allows names and labels to be returned together in a structured way
template_data = {}
for temp_info in self.info_association:
template = temp_info.template
content = temp_info.info.content
tmp_dict = {}
for field in template.fields:
if use_name:
name = field['name']
else:
name = field['label']
tmp_dict[name] = content.get(field['name'])
template_data[template.name] = tmp_dict
return template_data
def templates_json(self, use_name=False):
return json.dumps(self.templates_dict(use_name=use_name))
class ExtendedMetadata(object):
def __init__(self, data):
@@ -4450,98 +4299,6 @@ class FormDefinition(object, Dictifiable):
gridfields[i] = f
return gridfields
def get_widgets(self, user, contents={}, **kwd):
'''
Return the list of widgets that comprise a form definition,
including field contents if any.
'''
params = Params(kwd)
widgets = []
for index, field in enumerate(self.fields):
field_type = field['type']
if 'name' in field:
field_name = field['name']
else:
# Default to names like field_0, field_1, etc for backward compatibility
# (not sure this is necessary)...
field_name = 'field_%i' % index
# Determine the value of the field
if field_name in kwd:
# The form was submitted via refresh_on_change
if field_type == 'CheckboxField':
value = CheckboxField.is_checked(params.get(field_name, False))
else:
value = restore_text(params.get(field_name, ''))
elif contents:
try:
# This field has a saved value.
value = str(contents[field['name']])
except Exception:
# If there was an error getting the saved value, we'll still
# display the widget, but it will be empty.
if field_type == 'AddressField':
value = 'none'
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 = ''
else:
# If none of the above, then leave the field empty
if field_type == 'AddressField':
value = 'none'
elif field_type == 'CheckboxField':
# Since we do not have contents, set checkbox value to False
value = False
else:
# Set other field types to the default value of the field
value = field.get('default', '')
# Create the field widget
field_widget = eval(field_type)(field_name)
if field_type in ['TextField', 'PasswordField']:
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 in ['AddressField', 'WorkflowField', 'WorkflowMappingField', 'HistoryField']:
field_widget.user = user
field_widget.value = value
field_widget.params = params
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.set_checked(value)
if field['required'] == 'required':
req = 'Required'
else:
req = 'Optional'
if field['helptext']:
helptext = '%s (%s)' % (field['helptext'], req)
else:
helptext = '(%s)' % req
widgets.append(dict(label=field['label'], widget=field_widget, helptext=helptext))
return widgets
def field_as_html(self, field):
"""Generates disabled html for a field"""
type = field['type']
form_field = None
for field_type in self.supported_field_types:
if type == field_type.__name__:
# Name it AddressField, CheckboxField, etc.
form_field = field_type(type)
break
if form_field:
return form_field.get_html(disabled=True)
# Return None if unsupported field type
return None
class FormDefinitionCurrent(object):
def __init__(self, form_definition=None):
@@ -4581,30 +4338,6 @@ class UserAddress(object):
'country' : sanitize_html(self.country),
'phone' : sanitize_html(self.phone)}
def get_html(self):
# This should probably be deprecated eventually. It should currently
# sanitize.
# TODO Find out where else uses this and replace with
# templates
html = ''
if self.name:
html = html + sanitize_html(self.name)
if self.institution:
html = html + '<br/>' + sanitize_html(self.institution)
if self.address:
html = html + '<br/>' + sanitize_html(self.address)
if self.city:
html = html + '<br/>' + sanitize_html(self.city)
if self.state:
html = html + ' ' + sanitize_html(self.state)
if self.postal_code:
html = html + ' ' + sanitize_html(self.postal_code)
if self.country:
html = html + '<br/>' + sanitize_html(self.country)
if self.phone:
html = html + '<br/>' + 'phone: ' + sanitize_html(self.phone)
return html
class UserOpenID(object):
def __init__(self, user=None, session=None, openid=None):
-69
View File
@@ -227,29 +227,6 @@ class MetadataParameter(object):
other_values = other_values or {}
return form_builder.TextField(self.spec.name, value=value)
def get_html(self, value, context=None, other_values=None, **kwd):
"""
The "context" is simply the metadata collection/bunch holding
this piece of metadata. This is passed in to allow for
metadata to validate against each other (note: this could turn
into a huge, recursive mess if not done with care). For
example, a column assignment should validate against the
number of columns in the dataset.
"""
context = context or {}
other_values = other_values or {}
if self.spec.get("readonly"):
return value
if self.spec.get("optional"):
checked = False
if value:
checked = "true"
checkbox = form_builder.CheckboxField("is_" + self.spec.name, checked=checked)
return checkbox.get_html() + self.get_field(value=value, context=context, other_values=other_values, **kwd).get_html()
else:
return self.get_field(value=value, context=context, other_values=other_values, **kwd).get_html()
def to_string(self, value):
return str(value)
@@ -390,16 +367,6 @@ class SelectParameter(MetadataParameter):
field.add_option(val, label, selected=False)
return field
def get_html(self, value, context=None, other_values=None, values=None, **kwd):
context = context or {}
other_values = other_values or {}
if self.spec.get("readonly"):
if value in [None, []]:
return str(self.spec.no_value)
return ", ".join(map(str, value))
return MetadataParameter.get_html(self, value, context=context, other_values=other_values, values=values, **kwd)
def wrap(self, value, session):
# do we really need this (wasteful)? - yes because we are not sure that
# all existing selects have been stored previously as lists. Also this
@@ -433,15 +400,6 @@ class DBKeyParameter(SelectParameter):
pass
return super(DBKeyParameter, self).get_field(value, context, other_values, values, **kwd)
def get_html(self, value=None, context=None, other_values=None, values=None, **kwd):
context = context or {}
other_values = other_values or {}
try:
values = kwd['trans'].app.genome_builds.get_genome_build_names(kwd['trans'])
except KeyError:
pass
return super(DBKeyParameter, self).get_html(value, context, other_values, values, **kwd)
class RangeParameter(SelectParameter):
@@ -460,14 +418,6 @@ class RangeParameter(SelectParameter):
values = list(zip(range(self.min, self.max, self.step), range(self.min, self.max, self.step)))
return SelectParameter.get_field(self, value=value, context=context, other_values=other_values, values=values, **kwd)
def get_html(self, value, context=None, other_values=None, values=None, **kwd):
context = context or {}
other_values = other_values or {}
if values is None:
values = list(zip(range(self.min, self.max, self.step), range(self.min, self.max, self.step)))
return SelectParameter.get_html(self, value, context=context, other_values=other_values, values=values, **kwd)
@classmethod
def marshal(cls, value):
value = SelectParameter.marshal(value)
@@ -486,15 +436,6 @@ class ColumnParameter(RangeParameter):
values = list(zip(column_range, column_range))
return RangeParameter.get_field(self, value=value, context=context, other_values=other_values, values=values, **kwd)
def get_html(self, value, context=None, other_values=None, values=None, **kwd):
context = context or {}
other_values = other_values or {}
if values is None and context:
column_range = range(1, (context.columns or 0) + 1, 1)
values = list(zip(column_range, column_range))
return RangeParameter.get_html(self, value, context=context, other_values=other_values, values=values, **kwd)
class ColumnTypesParameter(MetadataParameter):
@@ -530,11 +471,6 @@ class PythonObjectParameter(MetadataParameter):
other_values = other_values or {}
return form_builder.TextField(self.spec.name, value=self._to_string(value))
def get_html(self, value=None, context=None, other_values=None, **kwd):
context = context or {}
other_values = other_values or {}
return str(self)
@classmethod
def marshal(cls, value):
return value
@@ -556,11 +492,6 @@ class FileParameter(MetadataParameter):
other_values = other_values or {}
return form_builder.TextField(self.spec.name, value=str(value.id))
def get_html(self, value=None, context=None, other_values=None, **kwd):
context = context or {}
other_values = other_values or {}
return "<div>No display available for Metadata Files</div>"
def wrap(self, value, session):
if value is None:
return None
+1 -5
View File
@@ -309,11 +309,9 @@ class ToolBox(BaseGalaxyToolBox):
def __build_tool_version_select_field(self, tools, tool_id, set_selected):
"""Build a SelectField whose options are the ids for the received list of tools."""
options = []
refresh_on_change_values = []
for tool in tools:
options.insert(0, (tool.version, tool.id))
refresh_on_change_values.append(tool.id)
select_field = SelectField(name='tool_id', refresh_on_change=True, refresh_on_change_values=refresh_on_change_values)
select_field = SelectField(name='tool_id')
for option_tup in options:
selected = set_selected and option_tup[1] == tool_id
if selected:
@@ -1042,8 +1040,6 @@ class Tool(object, Dictifiable):
group.default_file_type = elem.get('default_file_type', group.default_file_type)
group.metadata_ref = elem.get('metadata_ref', group.metadata_ref)
rval[group.file_type_name].refresh_on_change = True
rval[group.file_type_name].refresh_on_change_values = \
self.app.datatypes_registry.get_composite_extensions()
group_page_source = XmlPageSource(elem)
group.inputs = self.parse_input_elem(group_page_source, enctypes, context)
rval[group.name] = group
-1
View File
@@ -75,7 +75,6 @@ class ToolParameter(object, Dictifiable):
def __init__(self, tool, input_source, context=None):
input_source = ensure_input_source(input_source)
self.tool = tool
self.refresh_on_change_values = []
self.argument = input_source.get("argument")
self.name = self.__class__.parse_name(input_source)
self.type = input_source.get("type")
-4
View File
@@ -23,10 +23,6 @@ from .framework.decorators import (
require_admin,
require_login
)
from .framework.formbuilder import (
form,
FormBuilder
)
__all__ = ('url_for', 'error', 'expose', 'json', 'json_pretty',
'require_admin', 'require_login', 'expose_api', 'expose_api_anonymous',
+10 -527
View File
@@ -4,14 +4,9 @@ Classes for generating HTML forms
from __future__ import print_function
import logging
from cgi import escape
from six import string_types
from galaxy.util import (
asbool,
restore_text,
unicodify
asbool
)
log = logging.getLogger(__name__)
@@ -29,16 +24,6 @@ class BaseField(object):
self.optional = kwds.get('required', 'optional') == 'optional'
self.help = kwds.get('helptext')
def get_html(self, prefix=""):
"""Returns the html widget corresponding to the parameter"""
raise TypeError("Abstract Method")
def get_disabled_str(self, disabled=False):
if disabled:
return ' disabled="disabled"'
else:
return ''
def to_dict(self):
return {
'name' : self.name,
@@ -53,25 +38,7 @@ class BaseField(object):
class TextField(BaseField):
"""
A standard text input box.
>>> print(TextField( "foo" ).get_html())
<input type="text" name="foo" size="10" value="">
>>> print(TextField( "bins", size=4, value="default" ).get_html())
<input type="text" name="bins" size="4" value="default">
"""
def __init__(self, name, size=None, value=None, **kwds):
super(TextField, self).__init__(name, value, **kwds)
self.size = int(size or 10)
def get_html(self, prefix="", disabled=False):
value = unicodify(self.value or "")
return unicodify('<input type="text" name="%s%s" size="%d" value="%s"%s>'
% (prefix, self.name, self.size, escape(value, quote=True), self.get_disabled_str(disabled)))
def set_size(self, size):
self.size = int(size)
def to_dict(self):
d = super(TextField, self).to_dict()
d['type'] = 'text'
@@ -81,26 +48,7 @@ class TextField(BaseField):
class PasswordField(BaseField):
"""
A password input box. text appears as "******"
>>> print(PasswordField( "foo" ).get_html())
<input type="password" name="foo" size="10" value="">
>>> print(PasswordField( "bins", size=4, value="default" ).get_html())
<input type="password" name="bins" size="4" value="default">
"""
def __init__(self, name, size=None, value=None, **kwds):
super(PasswordField, self).__init__(name, value, **kwds)
self.name = name
self.size = int(size or 10)
self.value = value or ""
def get_html(self, prefix="", disabled=False):
return unicodify('<input type="password" name="%s%s" size="%d" value="%s"%s>'
% (prefix, self.name, self.size, escape(str(self.value), quote=True), self.get_disabled_str(disabled)))
def set_size(self, size):
self.size = int(size)
def to_dict(self):
d = super(PasswordField, self).to_dict()
d['type'] = 'password'
@@ -110,31 +58,7 @@ class PasswordField(BaseField):
class TextArea(BaseField):
"""
A standard text area box.
>>> print(TextArea( "foo" ).get_html())
<textarea name="foo" rows="5" cols="25"></textarea>
>>> print(TextArea( "bins", size="4x5", value="default" ).get_html())
<textarea name="bins" rows="4" cols="5">default</textarea>
"""
_DEFAULT_SIZE = "5x25"
def __init__(self, name, size=None, value=None, **kwds):
super(TextArea, self).__init__(name, value, **kwds)
self.name = name
size = size or self._DEFAULT_SIZE
self.size = size.split("x")
self.rows = int(self.size[0])
self.cols = int(self.size[-1])
self.value = value or ""
def get_html(self, prefix="", disabled=False):
return unicodify('<textarea name="%s%s" rows="%d" cols="%d"%s>%s</textarea>'
% (prefix, self.name, self.rows, self.cols, self.get_disabled_str(disabled), escape(str(self.value), quote=True)))
def set_size(self, rows, cols):
self.rows = rows
self.cols = cols
def to_dict(self):
d = super(TextArea, self).to_dict()
d['type'] = 'text'
@@ -145,46 +69,12 @@ class TextArea(BaseField):
class CheckboxField(BaseField):
"""
A checkbox (boolean input)
>>> print(CheckboxField( "foo" ).get_html())
<input type="checkbox" id="foo" name="foo" value="__CHECKED__"><input type="hidden" name="foo" value="__NOTHING__">
>>> print(CheckboxField( "bar", checked="yes" ).get_html())
<input type="checkbox" id="bar" name="bar" value="__CHECKED__" checked="checked"><input type="hidden" name="bar" value="__NOTHING__">
"""
def __init__(self, name, checked=None, refresh_on_change=False, refresh_on_change_values=None, value=None, **kwds):
super(CheckboxField, self).__init__(name, value, **kwds)
self.name = name
self.checked = (checked is True) or (isinstance(checked, string_types) and (checked.lower() in ("yes", "true", "on")))
self.refresh_on_change = refresh_on_change
self.refresh_on_change_values = refresh_on_change_values or []
if self.refresh_on_change:
self.refresh_on_change_text = ' refresh_on_change="true" '
if self.refresh_on_change_values:
self.refresh_on_change_text = '%s refresh_on_change_values="%s" ' % (self.refresh_on_change_text, ",".join(self.refresh_on_change_values))
else:
self.refresh_on_change_text = ''
def get_html(self, prefix="", disabled=False):
if self.checked:
checked_text = ' checked="checked"'
else:
checked_text = ''
id_name = prefix + self.name
return unicodify('<input type="checkbox" id="%s" name="%s" value="__CHECKED__"%s%s%s><input type="hidden" name="%s" value="__NOTHING__"%s>'
% (id_name, id_name, checked_text, self.get_disabled_str(disabled), self.refresh_on_change_text, id_name, self.get_disabled_str(disabled)))
@staticmethod
def is_checked(value):
if value in [True, "true"]:
if value in [True, "True", "true"]:
return True
return isinstance(value, list) and ('__CHECKED__' in value or len(value) == 2)
def set_checked(self, value):
if isinstance(value, string_types):
self.checked = value.lower() in ["yes", "true", "on"]
else:
self.checked = value
return False
def to_dict(self):
d = super(CheckboxField, self).to_dict()
@@ -192,122 +82,17 @@ class CheckboxField(BaseField):
return d
class FileField(BaseField):
"""
A file upload input.
>>> print(FileField( "foo" ).get_html())
<input type="file" name="foo">
>>> print(FileField( "foo", ajax = True ).get_html())
<input type="file" name="foo" galaxy-ajax-upload="true">
"""
def __init__(self, name, value=None, ajax=False, **kwds):
super(FileField, self).__init__(name, value, **kwds)
self.name = name
self.ajax = ajax
self.value = value
def get_html(self, prefix=""):
value_text = ""
if self.value:
value_text = ' value="%s"' % escape(str(self.value), quote=True)
ajax_text = ""
if self.ajax:
ajax_text = ' galaxy-ajax-upload="true"'
return unicodify('<input type="file" name="%s%s"%s%s>' % (prefix, self.name, ajax_text, value_text))
class GenomespaceFileField(BaseField):
"""
A genomspace file browser field.
"""
def __init__(self, name, value=None):
self.name = name
self.value = value or ""
def get_html(self, prefix=""):
return unicodify('<script src="https://gsui.genomespace.org/jsui/upload/gsuploadwindow.js"></script>'
'<input type="text" name="{0}{1}" value="{2}">&nbsp;'
'<a href="javascript:gsLocationByGet({{ successCallback: function(config)'
' {{ selector_name = \'{0}{1}\'; selector = \'input[name=\' + selector_name.replace(\'|\', \'\\\\|\') + \']\';'
' $(selector).val(config.destination + \'^\' + config.token); }} }});">'
'Browse</a>'.format(prefix, self.name, escape(str(self.value), quote=True)))
def to_dict(self):
return dict(name=self.name,
token_field=self.token_field)
class HiddenField(BaseField):
"""
A hidden field.
>>> print(HiddenField( "foo", 100 ).get_html())
<input type="hidden" name="foo" value="100">
"""
def __init__(self, name, value=None, **kwds):
super(HiddenField, self).__init__(name, value, **kwds)
self.name = name
self.value = value or ""
def get_html(self, prefix=""):
return unicodify('<input type="hidden" name="%s%s" value="%s">' % (prefix, self.name, escape(str(self.value), quote=True)))
def to_dict(self):
d = super(HiddenField, self).to_dict()
d['type'] = 'hidden'
d['hidden'] = True
return d
class SelectField(BaseField):
"""
A select field.
>>> t = SelectField( "foo", multiple=True )
>>> t.add_option( "tuti", 1 )
>>> t.add_option( "fruity", "x" )
>>> print(t.get_html())
<select name="foo" multiple>
<option value="1">tuti</option>
<option value="x">fruity</option>
</select>
>>> t = SelectField( "bar" )
>>> t.add_option( "automatic", 3 )
>>> t.add_option( "bazooty", 4, selected=True )
>>> print(t.get_html())
<select name="bar" last_selected_value="4">
<option value="3">automatic</option>
<option value="4" selected>bazooty</option>
</select>
>>> t = SelectField( "foo", display="radio" )
>>> t.add_option( "tuti", 1 )
>>> t.add_option( "fruity", "x" )
>>> print(t.get_html())
<div><input type="radio" name="foo" value="1" id="foo|1"><label class="inline" for="foo|1">tuti</label></div>
<div><input type="radio" name="foo" value="x" id="foo|x"><label class="inline" for="foo|x">fruity</label></div>
>>> t = SelectField( "bar", multiple=True, display="checkboxes" )
>>> t.add_option( "automatic", 3 )
>>> t.add_option( "bazooty", 4, selected=True )
>>> print(t.get_html())
<div class="checkUncheckAllPlaceholder" checkbox_name="bar"></div>
<div><input type="checkbox" name="bar" value="3" id="bar|3"><label class="inline" for="bar|3">automatic</label></div>
<div><input type="checkbox" name="bar" value="4" id="bar|4" checked='checked'><label class="inline" for="bar|4">bazooty</label></div>
"""
def __init__(self, name, multiple=None, display=None, refresh_on_change=False, refresh_on_change_values=None, size=None, field_id=None, value=None, selectlist=None, **kwds):
def __init__(self, name, multiple=None, display=None, field_id=None, value=None, selectlist=None, refresh_on_change=False, **kwds):
super(SelectField, self).__init__(name, value, **kwds)
self.name = name
self.field_id = field_id
self.multiple = multiple or False
self.refresh_on_change = refresh_on_change
self.selectlist = selectlist or []
self.value = value
self.size = size
self.options = list()
if display == "checkboxes":
assert multiple, "Checkbox display only supported for multiple select"
@@ -316,136 +101,10 @@ class SelectField(BaseField):
elif display is not None:
raise Exception("Unknown display type: %s" % display)
self.display = display
self.refresh_on_change = refresh_on_change
self.refresh_on_change_values = refresh_on_change_values or []
if self.refresh_on_change:
self.refresh_on_change_text = ' refresh_on_change="true"'
if self.refresh_on_change_values:
self.refresh_on_change_text = '%s refresh_on_change_values="%s"' % (self.refresh_on_change_text, escape(",".join(self.refresh_on_change_values), quote=True))
else:
self.refresh_on_change_text = ''
def add_option(self, text, value, selected=False):
self.options.append((text, value, selected))
def get_html(self, prefix="", disabled=False, extra_attr=None):
if extra_attr is not None:
self.extra_attributes = ' %s' % ' '.join(['%s="%s"' % (k, escape(v)) for k, v in extra_attr.items()])
else:
self.extra_attributes = ''
if self.display == "checkboxes":
return self.get_html_checkboxes(prefix, disabled)
elif self.display == "radio":
return self.get_html_radio(prefix, disabled)
else:
return self.get_html_default(prefix, disabled)
def get_html_checkboxes(self, prefix="", disabled=False):
rval = []
ctr = 0
if len(self.options) > 1:
rval.append('<div class="checkUncheckAllPlaceholder" checkbox_name="%s%s"></div>' % (prefix, self.name)) # placeholder for the insertion of the Select All/Unselect All buttons
for text, value, selected in self.options:
style = ""
text = unicodify(text)
escaped_value = escape(unicodify(value), quote=True)
uniq_id = "%s%s|%s" % (prefix, self.name, escaped_value)
if len(self.options) > 2 and ctr % 2 == 1:
style = " class=\"odd_row\""
selected_text = ""
if selected:
selected_text = " checked='checked'"
rval.append('<div%s><input type="checkbox" name="%s%s" value="%s" id="%s"%s%s%s><label class="inline" for="%s">%s</label></div>'
% (style, prefix, self.name, escaped_value, uniq_id, selected_text, self.get_disabled_str(disabled), self.extra_attributes, uniq_id, escape(text, quote=True)))
ctr += 1
return unicodify("\n".join(rval))
def get_html_radio(self, prefix="", disabled=False):
rval = []
ctr = 0
for text, value, selected in self.options:
style = ""
escaped_value = escape(str(value), quote=True)
uniq_id = "%s%s|%s" % (prefix, self.name, escaped_value)
if len(self.options) > 2 and ctr % 2 == 1:
style = " class=\"odd_row\""
selected_text = ""
if selected:
selected_text = " checked='checked'"
rval.append('<div%s><input type="radio" name="%s%s"%s value="%s" id="%s"%s%s%s><label class="inline" for="%s">%s</label></div>'
% (style,
prefix,
self.name,
self.refresh_on_change_text,
escaped_value,
uniq_id,
selected_text,
self.get_disabled_str(disabled),
self.extra_attributes,
uniq_id,
text))
ctr += 1
return unicodify("\n".join(rval))
def get_html_default(self, prefix="", disabled=False):
if self.multiple:
multiple = " multiple"
else:
multiple = ""
if self.size:
size = ' size="%s"' % str(self.size)
else:
size = ''
rval = []
last_selected_value = ""
for text, value, selected in self.options:
if selected:
selected_text = " selected"
last_selected_value = value
if not isinstance(last_selected_value, string_types):
last_selected_value = str(last_selected_value)
else:
selected_text = ""
rval.append('<option value="%s"%s>%s</option>' % (escape(unicodify(value), quote=True), selected_text, escape(unicodify(text), quote=True)))
if last_selected_value:
last_selected_value = ' last_selected_value="%s"' % escape(unicodify(last_selected_value), quote=True)
if self.field_id is not None:
id_string = ' id="%s"' % self.field_id
else:
id_string = ''
rval.insert(0, '<select name="%s%s"%s%s%s%s%s%s%s>'
% (prefix, self.name, multiple, size, self.refresh_on_change_text, last_selected_value, self.get_disabled_str(disabled), id_string, self.extra_attributes))
rval.append('</select>')
return unicodify("\n".join(rval))
def get_selected(self, return_label=False, return_value=False, multi=False):
'''
Return the currently selected option's label, value or both as a tuple. For
multi-select lists, a list is returned.
'''
if multi:
selected_options = []
for label, value, selected in self.options:
if selected:
if return_label and return_value:
if multi:
selected_options.append((label, value))
else:
return (label, value)
elif return_label:
if multi:
selected_options.append(label)
else:
return label
elif return_value:
if multi:
selected_options.append(value)
else:
return value
if multi:
return selected_options
return None
def to_dict(self):
d = super(SelectField, self).to_dict()
d['type'] = 'select'
@@ -470,63 +129,10 @@ class AddressField(BaseField):
("country", "Country", ""),
("phone", "Phone", "")]
def __init__(self, name, user=None, value=None, params=None, security=None, **kwds):
def __init__(self, name, user=None, value=None, security=None, **kwds):
super(AddressField, self).__init__(name, value, **kwds)
self.user = user
self.security = security
self.select_address = None
self.params = params
def get_html(self, disabled=False):
address_html = ''
add_ids = ['none']
if self.user:
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')
if self.user:
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, help_text in self.fields():
add_field = TextField(self.name + '_' + field_name,
40,
restore_text(self.params.get(self.name + '_' + field_name, '')))
address_html += '''
<div class="form-row">
<label>%s</label>
%s
''' % (label, add_field.get_html(disabled=disabled))
if help_text:
address_html += '''
<div class="toolParamHelp" style="clear: both;">
%s
</div>
''' % help_text
address_html += '''
</div>
'''
else:
self.select_address.add_option('Add a new address', 'new')
return self.select_address.get_html(disabled=disabled) + address_html
def to_dict(self):
d = super(AddressField, self).to_dict()
@@ -540,29 +146,11 @@ class AddressField(BaseField):
class WorkflowField(BaseField):
def __init__(self, name, user=None, value=None, params=None, security=None, **kwds):
def __init__(self, name, user=None, value=None, security=None, **kwds):
super(WorkflowField, self).__init__(name, value, **kwds)
self.name = name
self.user = user
self.value = value
self.security = security
self.select_workflow = None
self.params = params
def get_html(self, disabled=False):
self.select_workflow = SelectField(self.name)
if self.value == 'none':
self.select_workflow.add_option('Select one', 'none', selected=True)
else:
self.select_workflow.add_option('Select one', 'none')
if self.user:
for a in self.user.stored_workflows:
if not a.deleted:
if str(self.value) == str(a.id):
self.select_workflow.add_option(a.name, str(a.id), selected=True)
else:
self.select_workflow.add_option(a.name, str(a.id))
return self.select_workflow.get_html(disabled=disabled)
def to_dict(self):
d = super(WorkflowField, self).to_dict()
@@ -576,70 +164,17 @@ class WorkflowField(BaseField):
class WorkflowMappingField(BaseField):
def __init__(self, name, user=None, value=None, params=None, **kwd):
# DBTODO integrate this with the new __build_workflow approach in requests_common. As it is, not particularly useful.
self.name = name
def __init__(self, name, user=None, value=None, **kwds):
super(WorkflowMappingField, self).__init__(name, value, **kwds)
self.user = user
self.value = value
self.select_workflow = None
self.params = params
self.workflow_inputs = []
def get_html(self, disabled=False):
self.select_workflow = SelectField(self.name, refresh_on_change=True)
workflow_inputs = []
if self.value == 'none':
self.select_workflow.add_option('Select one', 'none', selected=True)
else:
self.select_workflow.add_option('Select one', 'none')
if self.user:
for a in self.user.stored_workflows:
if not a.deleted:
if str(self.value) == str(a.id):
self.select_workflow.add_option(a.name, str(a.id), selected=True)
else:
self.select_workflow.add_option(a.name, str(a.id))
if self.value and self.value != 'none':
# Workflow selected. Find all inputs.
for workflow in self.user.stored_workflows:
if workflow.id == int(self.value):
for step in workflow.latest_workflow.steps:
if step.type == 'data_input':
if step.tool_inputs and "name" in step.tool_inputs:
workflow_inputs.append((step.tool_inputs['name'], TextField('%s_%s' % (self.name, step.id), 20)))
# Do something more appropriate here and allow selection of inputs
return self.select_workflow.get_html(disabled=disabled) + ''.join(['<div class="form-row"><label>%s</label>%s</div>' % (s[0], s[1].get_html()) for s in workflow_inputs])
class HistoryField(BaseField):
def __init__(self, name, user=None, value=None, params=None, security=None, **kwds):
def __init__(self, name, user=None, value=None, security=None, **kwds):
super(HistoryField, self).__init__(name, value, **kwds)
self.name = name
self.user = user
self.value = value
self.security = security
self.select_history = None
self.params = params
def get_html(self, disabled=False):
self.select_history = SelectField(self.name)
if self.value == 'none':
self.select_history.add_option('No Import', 'none', selected=True)
self.select_history.add_option('New History', 'new')
else:
self.select_history.add_option('No Import', 'none')
if self.value == 'new':
self.select_history.add_option('New History', 'new', selected=True)
else:
self.select_history.add_option('New History', 'new')
if self.user:
for a in self.user.histories:
if not a.deleted:
if str(self.value) == str(a.id):
self.select_history.add_option(a.name, str(a.id), selected=True)
else:
self.select_history.add_option(a.name, str(a.id))
return self.select_history.get_html(disabled=disabled)
def to_dict(self):
d = super(HistoryField, self).to_dict()
@@ -657,55 +192,3 @@ def get_suite():
import doctest
import sys
return doctest.DocTestSuite(sys.modules[__name__])
# --------- Utility methods -----------------------------
def build_select_field(trans, objs, label_attr, select_field_name, initial_value='none',
selected_value='none', refresh_on_change=False, multiple=False, display=None, size=None):
"""
Build a SelectField given a set of objects. The received params are:
- objs: the set of objects used to populate the option list
- label_attr: the attribute of each obj (e.g., name, email, etc ) whose value is used to populate each option label.
- If the string 'self' is passed as label_attr, each obj in objs is assumed to be a string, so the obj itself is used
- select_field_name: the name of the SelectField
- initial_value: the value of the first option in the SelectField - allows for an option telling the user to select something
- selected_value: the value of the currently selected option
- refresh_on_change: True if the SelectField should perform a refresh_on_change
"""
if initial_value == 'none':
values = [initial_value]
else:
values = []
for obj in objs:
if label_attr == 'self':
# Each obj is a string
values.append(obj)
else:
values.append(trans.security.encode_id(obj.id))
if refresh_on_change:
refresh_on_change_values = values
else:
refresh_on_change_values = []
select_field = SelectField(name=select_field_name,
multiple=multiple,
display=display,
refresh_on_change=refresh_on_change,
refresh_on_change_values=refresh_on_change_values,
size=size)
for obj in objs:
if label_attr == 'self':
# Each obj is a string
if str(selected_value) == str(obj):
select_field.add_option(obj, obj, selected=True)
else:
select_field.add_option(obj, obj)
else:
label = getattr(obj, label_attr)
if str(selected_value) == str(obj.id) or str(selected_value) == trans.security.encode_id(obj.id):
select_field.add_option(label, trans.security.encode_id(obj.id), selected=True)
else:
select_field.add_option(label, trans.security.encode_id(obj.id))
return select_field
-91
View File
@@ -1,91 +0,0 @@
import logging
from galaxy.util import bunch
log = logging.getLogger(__name__)
def form(*args, **kwargs):
return FormBuilder(*args, **kwargs)
class FormBuilder(object):
"""
Simple class describing an HTML form
"""
def __init__(self, action="", title="", name="form", submit_text="submit", use_panels=False):
self.title = title
self.name = name
self.action = action
self.submit_text = submit_text
self.inputs = []
self.use_panels = use_panels
def add_input(self, type, name, label, value=None, error=None, help=None, use_label=True):
self.inputs.append(FormInput(type, label, name, value, error, help, use_label))
return self
def add_checkbox(self, name, label, value=None, error=None, help=None):
return self.add_input('checkbox', label, name, value, error, help)
def add_text(self, name, label, value=None, error=None, help=None):
return self.add_input('text', label, name, value, error, help)
def add_password(self, name, label, value=None, error=None, help=None):
return self.add_input('password', label, name, value, error, help)
def add_select(self, name, label, value=None, options=[], error=None, help=None, use_label=True):
self.inputs.append(SelectInput(name, label, value=value, options=options, error=error, help=help, use_label=use_label))
return self
class FormInput(object):
"""
Simple class describing a form input element
"""
def __init__(self, type, name, label, value=None, error=None, help=None, use_label=True, extra_attributes={}, **kwargs):
self.type = type
self.name = name
self.label = label
self.value = value
self.error = error
self.help = help
self.use_label = use_label
self.extra_attributes = extra_attributes
class DatalistInput(FormInput):
""" Data list input """
def __init__(self, name, *args, **kwargs):
if 'extra_attributes' not in kwargs:
kwargs['extra_attributes'] = {}
kwargs['extra_attributes']['list'] = name
FormInput.__init__(self, None, name, *args, **kwargs)
self.options = kwargs.get('options', {})
def body_html(self):
options = "".join(["<option value='%s'>%s</option>" % (key, value) for key, value in self.options.iteritems()])
return """<datalist id="%s">%s</datalist>""" % (self.name, options)
class SelectInput(FormInput):
""" A select form input. """
def __init__(self, name, label, value=None, options=[], error=None, help=None, use_label=True):
FormInput.__init__(self, "select", name, label, value=value, error=error, help=help, use_label=use_label)
self.options = options
class FormData(object):
"""
Class for passing data about a form to a template, very rudimentary, could
be combined with the tool form handling to build something more general.
"""
def __init__(self):
# TODO: galaxy's two Bunchs are defined differently. Is this right?
self.values = bunch.Bunch()
self.errors = bunch.Bunch()
-12
View File
@@ -33,7 +33,6 @@ from galaxy.util import (
from galaxy.util.sanitize_html import sanitize_html
from galaxy.web.framework import (
base,
formbuilder,
helpers,
url_for
)
@@ -103,8 +102,6 @@ class WebApplication(base.WebApplication):
return trans.show_message(sanitize_html(e.err_msg), e.type)
def make_body_iterable(self, trans, body):
if isinstance(body, formbuilder.FormBuilder):
body = trans.show_form(body)
return base.WebApplication.make_body_iterable(self, trans, body)
def transaction_chooser(self, environ, galaxy_app, session_cookie):
@@ -875,15 +872,6 @@ class GalaxyWebTransaction(base.DefaultWebTransaction,
"""
return self.show_message(message, 'warning', refresh_frames, use_panels=use_panels, active_view=active_view)
def show_form(self, form, header=None, template="form.mako", use_panels=False, active_view=""):
"""
Convenience method for displaying a simple page with a single HTML
form.
"""
return self.fill_template(template, form=form, header=header,
use_panels=(form.use_panels or use_panels),
active_view=active_view)
@property
def session_csrf_token(self):
token = ''
@@ -32,10 +32,6 @@ from galaxy.web.base.controller import (
UsesLibraryMixin,
UsesLibraryMixinItems
)
from galaxy.web.form_builder import (
AddressField,
CheckboxField,
)
log = logging.getLogger(__name__)
@@ -300,18 +296,12 @@ class LibraryContentsController(BaseAPIController, UsesLibraryMixin, UsesLibrary
roles = kwd.get('roles', '')
is_admin = trans.user_is_admin()
current_user_roles = trans.get_current_user_roles()
widgets = []
info_association, inherited = None, None
template_id = "None"
if replace_id not in ['', None, 'None']:
replace_dataset = trans.sa_session.query(trans.app.model.LibraryDataset).get(trans.security.decode_id(replace_id))
self._check_access(trans, is_admin, replace_dataset, current_user_roles)
self._check_modify(trans, is_admin, replace_dataset, current_user_roles)
library = replace_dataset.folder.parent_library
folder = replace_dataset.folder
info_association, inherited = replace_dataset.library_dataset_dataset_association.get_info_association()
if info_association and (not(inherited) or info_association.inheritable):
widgets = replace_dataset.library_dataset_dataset_association.get_template_widgets(trans)
# The name is stored - by the time the new ldda is created, replace_dataset.name
# will point to the new ldda, not the one it's replacing.
if not last_used_build:
@@ -342,56 +332,9 @@ class LibraryContentsController(BaseAPIController, UsesLibraryMixin, UsesLibrary
if error:
return 400, message
else:
# See if we have any inherited templates.
if not info_association:
info_association, inherited = folder.get_info_association(inherited=True)
if info_association and info_association.inheritable:
template_id = str(info_association.template.id)
widgets = folder.get_template_widgets(trans, get_contents=True)
processed_widgets = []
# The list of widgets may include an AddressField which we need to save if it is new
for index, widget_dict in enumerate(widgets):
widget = widget_dict['widget']
if isinstance(widget, AddressField):
value = kwd.get(widget.name, '')
if value == 'new':
if self.field_param_values_ok(widget.name, 'AddressField', **kwd):
# Save the new address
address = trans.app.model.UserAddress(user=trans.user)
self.save_widget_field(trans, address, widget.name, **kwd)
widget.value = str(address.id)
widget_dict['widget'] = widget
processed_widgets.append(widget_dict)
# It is now critical to update the value of 'field_%i', replacing the string
# 'new' with the new address id. This is necessary because the upload_dataset()
# method below calls the handle_library_params() method, which does not parse the
# widget fields, it instead pulls form values from kwd. See the FIXME comments in the
# handle_library_params() method, and the CheckboxField code in the next conditional.
kwd[widget.name] = str(address.id)
else:
# The invalid address won't be saved, but we cannot display error
# messages on the upload form due to the ajax upload already occurring.
# When we re-engineer the upload process ( currently under way ), we
# will be able to check the form values before the ajax upload occurs
# in the background. For now, we'll do nothing...
pass
elif isinstance(widget, CheckboxField):
# We need to check the value from kwd since util.Params would have munged the list if
# the checkbox is checked.
value = kwd.get(widget.name, '')
if CheckboxField.is_checked(value):
widget.value = 'true'
widget_dict['widget'] = widget
processed_widgets.append(widget_dict)
kwd[widget.name] = 'true'
else:
processed_widgets.append(widget_dict)
widgets = processed_widgets
created_outputs_dict = self._upload_dataset(trans,
library_id=trans.security.encode_id(library.id),
folder_id=trans.security.encode_id(folder.id),
template_id=template_id,
widgets=widgets,
replace_dataset=replace_dataset,
**kwd)
if created_outputs_dict:
@@ -263,8 +263,7 @@ class ToolShedRepositoriesController(BaseAPIController):
else:
repository_data['repository'] = json.loads(util.url_get(tool_shed_url, pathspec=['api', 'repositories', tsr_id]))
repository_data['repository']['metadata'] = json.loads(util.url_get(tool_shed_url, pathspec=['api', 'repositories', tsr_id, 'metadata']))
repository_data['shed_conf'] = tool_util.build_shed_tool_conf_select_field(trans.app).get_html().replace('\n', '')
repository_data['panel_section_html'] = tool_panel_section_select_field.get_html(extra_attr={'style': 'width: 30em;'}).replace('\n', '')
repository_data['shed_conf'] = tool_util.build_shed_tool_conf_select_field(trans.app).to_dict()
repository_data['panel_section_dict'] = tool_panel_section_dict
for changeset, metadata in repository_data['repository']['metadata'].items():
if changeset not in tool_dependencies:
+1 -2
View File
@@ -252,8 +252,7 @@ class ToolShedController(BaseAPIController):
else:
repository_data['repository'] = json.loads(util.url_get(tool_shed_url, pathspec=['api', 'repositories', repository_id]))
repository_data['repository']['metadata'] = json.loads(util.url_get(tool_shed_url, pathspec=['api', 'repositories', repository_id, 'metadata']))
repository_data['shed_conf'] = tool_util.build_shed_tool_conf_select_field(trans.app).get_html().replace('\n', '')
repository_data['panel_section_html'] = tool_panel_section_select_field.get_html(extra_attr={'style': 'width: 30em;'}).replace('\n', '')
repository_data['shed_conf'] = tool_util.build_shed_tool_conf_select_field(trans.app).to_dict()
repository_data['panel_section_dict'] = tool_panel_section_dict
for changeset, metadata in repository_data['repository']['metadata'].items():
if changeset not in tool_dependencies:
@@ -239,7 +239,7 @@ class AdminToolshed(AdminGalaxy):
message += 'Attempting to uninstall tool dependencies resulted in errors: %s' % errors
status = max(status, statuses.index('error'))
status = statuses[status]
remove_from_disk_check_box = CheckboxField('remove_from_disk', checked=remove_from_disk_checked)
remove_from_disk_check_box = CheckboxField('remove_from_disk', value=remove_from_disk_checked)
return trans.fill_template('/admin/tool_shed_repository/deactivate_or_uninstall_repository.mako',
repository=tool_shed_repositories,
remove_from_disk_check_box=remove_from_disk_check_box,
@@ -535,10 +535,10 @@ class AdminToolshed(AdminGalaxy):
else:
install_tool_dependencies_check_box_checked = True
install_tool_dependencies_check_box = CheckboxField('install_tool_dependencies',
checked=install_tool_dependencies_check_box_checked)
value=install_tool_dependencies_check_box_checked)
view = views.DependencyResolversView(self.app)
if view.installable_resolvers:
install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', checked=True)
install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', value=True)
else:
install_resolver_dependencies_check_box = None
return trans.fill_template('/admin/tool_shed_repository/install_tool_dependencies_with_update.mako',
@@ -1054,12 +1054,12 @@ class AdminToolshed(AdminGalaxy):
else:
install_tool_dependencies_check_box_checked = True
install_tool_dependencies_check_box = CheckboxField('install_tool_dependencies',
checked=install_tool_dependencies_check_box_checked)
value=install_tool_dependencies_check_box_checked)
# Handle repository dependencies check box.
install_repository_dependencies_check_box = CheckboxField('install_repository_dependencies', checked=True)
install_repository_dependencies_check_box = CheckboxField('install_repository_dependencies', value=True)
view = views.DependencyResolversView(self.app)
if view.installable_resolvers:
install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', checked=True)
install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', value=True)
else:
install_resolver_dependencies_check_box = None
encoded_repo_info_dicts = encoding_util.encoding_sep.join(encoded_repo_info_dicts)
@@ -1392,7 +1392,7 @@ class AdminToolshed(AdminGalaxy):
else:
original_section_name = ''
tool_panel_section_select_field = tool_util.build_tool_panel_section_select_field(trans.app)
no_changes_check_box = CheckboxField('no_changes', checked=True)
no_changes_check_box = CheckboxField('no_changes', value=True)
if original_section_name:
message += "The tools contained in your <b>%s</b> repository were last loaded into the tool panel section <b>%s</b>. " \
% (escape(tool_shed_repository.name), original_section_name)
@@ -1423,7 +1423,7 @@ class AdminToolshed(AdminGalaxy):
# whether installed or missing.
containers_dict = dd.merge_missing_repository_dependencies_to_installed_container(containers_dict)
# Handle repository dependencies check box.
install_repository_dependencies_check_box = CheckboxField('install_repository_dependencies', checked=True)
install_repository_dependencies_check_box = CheckboxField('install_repository_dependencies', value=True)
# Handle tool dependencies check box.
if trans.app.config.tool_dependency_dir is None:
if includes_tool_dependencies:
@@ -1433,10 +1433,10 @@ class AdminToolshed(AdminGalaxy):
install_tool_dependencies_check_box_checked = False
else:
install_tool_dependencies_check_box_checked = True
install_tool_dependencies_check_box = CheckboxField('install_tool_dependencies', checked=install_tool_dependencies_check_box_checked)
install_tool_dependencies_check_box = CheckboxField('install_tool_dependencies', value=install_tool_dependencies_check_box_checked)
view = views.DependencyResolversView(self.app)
if view.installable_resolvers:
install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', checked=True)
install_resolver_dependencies_check_box = CheckboxField('install_resolver_dependencies', value=True)
else:
install_resolver_dependencies_check_box = None
return trans.fill_template('/admin/tool_shed_repository/reselect_tool_panel_section.mako',
@@ -20,7 +20,7 @@ from galaxy import (
)
from galaxy.tools.repositories import ValidationContext
from galaxy.web.base.controller import BaseUIController
from galaxy.web.form_builder import CheckboxField
from galaxy.web.form_builder import CheckboxField, SelectField
from galaxy.web.framework.helpers import grids
from galaxy.webapps.tool_shed.util import ratings_util
from tool_shed.capsule import capsule_manager
@@ -974,7 +974,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
repository_dependencies,
repository_metadata,
exclude=exclude)
export_repository_dependencies_check_box = CheckboxField('export_repository_dependencies', checked=True)
export_repository_dependencies_check_box = CheckboxField('export_repository_dependencies', value=True)
else:
containers_dict = None
export_repository_dependencies_check_box = None
@@ -1084,7 +1084,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
else:
message = "No search performed - each field must contain the same number of comma-separated items."
status = "error"
exact_matches_check_box = CheckboxField('exact_matches', checked=exact_matches_checked)
exact_matches_check_box = CheckboxField('exact_matches', value=exact_matches_checked)
return trans.fill_template('/webapps/tool_shed/repository/find_tools.mako',
tool_id=basic_util.stringify(tool_ids),
tool_name=basic_util.stringify(tool_names),
@@ -1176,7 +1176,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
else:
exact_matches_checked = False
workflow_names = []
exact_matches_check_box = CheckboxField('exact_matches', checked=exact_matches_checked)
exact_matches_check_box = CheckboxField('exact_matches', value=exact_matches_checked)
return trans.fill_template('/webapps/tool_shed/repository/find_workflows.mako',
workflow_name=basic_util.stringify(workflow_names),
exact_matches_check_box=exact_matches_check_box,
@@ -1824,7 +1824,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
else:
message = 'You will not receive any email alerts for new valid tool shed repositories.'
checked = new_repo_alert_checked or (user and user.new_repo_alert)
new_repo_alert_check_box = CheckboxField('new_repo_alert', checked=checked)
new_repo_alert_check_box = CheckboxField('new_repo_alert', value=checked)
email_alert_repositories = []
for repository in trans.sa_session.query(trans.model.Repository) \
.filter(and_(trans.model.Repository.table.c.deleted == false(),
@@ -1931,14 +1931,22 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
message = "The repository information has been updated."
if error:
status = 'error'
allow_push_select_field = SelectField(name='allow_push',
multiple=True)
current_allow_push = repository.allow_push(trans.app)
if current_allow_push:
current_allow_push_list = current_allow_push.split(',')
else:
current_allow_push_list = []
allow_push_select_field = repository_util.build_allow_push_select_field(trans, current_allow_push_list)
options = []
for user in trans.sa_session.query(trans.model.User):
if user.username not in current_allow_push_list:
options.append(user)
for obj in options:
label = getattr(obj, 'username')
allow_push_select_field.add_option(label, trans.security.encode_id(obj.id))
checked = alerts_checked or user.email in email_alerts
alerts_check_box = CheckboxField('alerts', checked=checked)
alerts_check_box = CheckboxField('alerts', value=checked)
changeset_revision_select_field = grids_util.build_changeset_revision_select_field(trans,
repository,
selected_value=changeset_revision,
@@ -2001,7 +2009,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
message += malicious_error
status = 'error'
repository_type_select_field = rt_util.build_repository_type_select_field(trans, repository=repository)
malicious_check_box = CheckboxField('malicious', checked=is_malicious)
malicious_check_box = CheckboxField('malicious', value=is_malicious)
categories = suc.get_categories(trans.app)
selected_categories = [_rca.category_id for _rca in repository.categories]
tsucm = ToolShedUtilityContainerManager(trans.app)
@@ -2821,7 +2829,7 @@ class RepositoryController(BaseUIController, ratings_util.ItemRatings):
trans.sa_session.add(repository)
trans.sa_session.flush()
checked = alerts_checked or (user and user.email in email_alerts)
alerts_check_box = CheckboxField('alerts', checked=checked)
alerts_check_box = CheckboxField('alerts', value=checked)
changeset_revision_select_field = grids_util.build_changeset_revision_select_field(trans,
repository,
selected_value=changeset_revision,
@@ -278,6 +278,7 @@ class RepositoryReviewController(BaseUIController, ratings_util.ItemRatings):
# The star rating form field is a radio button list, so it will not be received if it was not clicked in the form.
# Due to this behavior, default the value to 0.
rating = 0
private = False
for k, v in kwd.items():
if k.startswith('%s%s' % (component_name, STRSEP)):
component_review_attr = k.replace('%s%s' % (component_name, STRSEP), '')
@@ -12,7 +12,6 @@ from tool_shed.util import common_util
from tool_shed.util import repository_util
from tool_shed.util import tool_util
from tool_shed.util import xml_util
log = logging.getLogger(__name__)
+10 -2
View File
@@ -110,7 +110,11 @@ class RepositoryGrid(grids.Grid):
# A repository's metadata revisions may not all be installable, as some may contain only invalid tools.
select_field = grids_util.build_changeset_revision_select_field(trans, repository, downloadable=False)
if len(select_field.options) > 1:
return select_field.get_html()
tmpl = "<select name='%s'>" % select_field.name
for o in select_field.options:
tmpl += "<option value='%s'>%s</option>" % (o[1], o[0])
tmpl += "</select>"
return tmpl
elif len(select_field.options) == 1:
option_items = select_field.options[0][0]
rev_label, rev_date = option_items.split(' ')
@@ -1331,7 +1335,11 @@ class ValidRepositoryGrid(RepositoryGrid):
"""Display a SelectField whose options are the changeset_revision strings of all download-able revisions of this repository."""
select_field = grids_util.build_changeset_revision_select_field(trans, repository, downloadable=True)
if len(select_field.options) > 1:
return select_field.get_html()
tmpl = "<select name='%s'>" % select_field.name
for o in select_field.options:
tmpl += "<option value='%s'>%s</option>" % (o[1], o[0])
tmpl += "</select>"
return tmpl
elif len(select_field.options) == 1:
return select_field.options[0][0]
return ''
+1 -3
View File
@@ -71,9 +71,7 @@ def build_changeset_revision_select_field(trans, repository, selected_value=None
name = 'changeset_revision_%d' % repository.id
else:
name = 'changeset_revision'
select_field = SelectField(name=name,
refresh_on_change=True,
refresh_on_change_values=refresh_on_change_values)
select_field = SelectField(name=name, refresh_on_change=True)
for option_tup in options:
selected = selected_value and option_tup[1] == selected_value
select_field.add_option(option_tup[0], option_tup[1], selected=selected)
+1
View File
@@ -54,6 +54,7 @@ def clone_repository(repository_clone_url, repository_file_dir, ctx_rev):
Clone the repository up to the specified changeset_revision. No subsequent revisions will be
present in the cloned repository.
"""
stdouterr = None
try:
stdouterr = subprocess.check_output(['hg', 'clone', '-r', ctx_rev, repository_clone_url, repository_file_dir], stderr=subprocess.STDOUT)
return True, None
-15
View File
@@ -11,7 +11,6 @@ import tool_shed.dependencies.repository
import tool_shed.util.metadata_util as metadata_util
from galaxy import util
from galaxy import web
from galaxy.web.form_builder import build_select_field
from tool_shed.util import basic_util, common_util, encoding_util, hg_util
from tool_shed.util.web_util import escape
@@ -20,20 +19,6 @@ log = logging.getLogger(__name__)
VALID_REPOSITORYNAME_RE = re.compile("^[a-z0-9\_]+$")
def build_allow_push_select_field(trans, current_push_list, selected_value='none'):
options = []
for user in trans.sa_session.query(trans.model.User):
if user.username not in current_push_list:
options.append(user)
return build_select_field(trans,
objs=options,
label_attr='username',
select_field_name='allow_push',
selected_value=selected_value,
refresh_on_change=False,
multiple=True)
def change_repository_name_in_hgrc_file(hgrc_file, new_name):
config = configparser.ConfigParser()
config.read(hgrc_file)
+4 -2
View File
@@ -6,8 +6,10 @@ from sqlalchemy import and_
from galaxy import util
from galaxy.web.form_builder import SelectField
from tool_shed.util import hg_util
from tool_shed.util import xml_util
from tool_shed.util import (
hg_util,
xml_util
)
log = logging.getLogger(__name__)
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,3 +1,4 @@
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%def name="browse_files(title_text, directory_path)">
@@ -148,7 +149,7 @@
%else:
<label>Handle repository dependencies?</label>
%endif
${repository_dependencies_check_box.get_html()}
${render_checkbox(repository_dependencies_check_box)}
<div class="toolParamHelp" style="clear: both;">
%if export:
Select to export the following additional repositories that are required by this repository.
@@ -185,7 +186,7 @@
<div class="form-row">
<label>When available, install Tool Shed managed tool dependencies?</label>
<% disabled = trans.app.config.tool_dependency_dir is None %>
${install_tool_dependencies_check_box.get_html( disabled=disabled )}
${render_checkbox(install_tool_dependencies_check_box, disabled=disabled)}
<div class="toolParamHelp" style="clear: both;">
%if disabled:
Set the tool_dependency_dir configuration value in your Galaxy config to automatically handle tool dependencies.
@@ -221,7 +222,7 @@
%if requirements_status and install_resolver_dependencies_check_box:
<div class="form-row">
<label>When available, install <a href="https://docs.galaxyproject.org/en/master/admin/conda_faq.html" target="_blank">Conda</a> managed tool dependencies?</label>
${install_resolver_dependencies_check_box.get_html()}
${render_checkbox(install_resolver_dependencies_check_box)}
<div class="toolParamHelp" style="clear: both;">
Select to automatically install tool dependencies via Conda.
</div>
@@ -2,6 +2,7 @@
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="*" />
<%namespace file="/admin/tool_shed_repository/repository_actions_menu.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%
repository = context.get( 'repository', None )
@@ -190,7 +191,7 @@ else:
%>
%if can_deactivate_repository and can_uninstall_repository:
<% deactivate_uninstall_button_text = "Deactivate or Uninstall" %>
${remove_from_disk_check_box.get_html()}
${render_checkbox(remove_from_disk_check_box)}
<label for="remove_from_disk" style="display: inline;font-weight:normal;">Check to uninstall or leave blank to deactivate</label>
<br/><br/>
%elif can_deactivate_repository:
@@ -1,6 +1,7 @@
<%inherit file="/base.mako"/>
<%namespace file="/admin/tool_shed_repository/repository_actions_menu.mako" import="*" />
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<% import os %>
@@ -31,7 +32,7 @@ ${render_galaxy_repository_actions( repository )}
<div class="form-row">
<label>Handle tool dependencies?</label>
<% disabled = trans.app.config.tool_dependency_dir is None %>
${install_tool_dependencies_check_box.get_html( disabled=disabled )}
${render_checkbox(install_tool_dependencies_check_box, disabled=disabled)}
<div class="toolParamHelp" style="clear: both;">
%if disabled:
Set the tool_dependency_dir configuration value in your Galaxy config to automatically handle tool dependencies.
@@ -1,7 +1,7 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/admin/tool_shed_repository/repository_actions_menu.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="common_misc_javascripts" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="stylesheets()">
${parent.stylesheets()}
@@ -73,7 +73,7 @@ ${render_galaxy_repository_actions( repository )}
</div>
<div style="clear: both"></div>
<div class="form-row">
${uninstalled_tool_dependencies_select_field.get_html()}
${render_select(uninstalled_tool_dependencies_select_field)}
</div>
<div style="clear: both"></div>
<div class="form-row">
@@ -94,7 +94,7 @@ ${render_galaxy_repository_actions( repository )}
</div>
<div style="clear: both"></div>
<div class="form-row">
${installed_tool_dependencies_select_field.get_html()}
${render_select(installed_tool_dependencies_select_field)}
</div>
<div style="clear: both"></div>
<div class="form-row">
@@ -3,6 +3,7 @@
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_dependencies_section" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_readme_section" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="stylesheets()">
${parent.stylesheets()}
@@ -60,7 +61,7 @@
%>
<div class="form-row">
<label>Shed tool configuration file:</label>
${shed_tool_conf_select_field.get_html()}
${render_select(shed_tool_conf_select_field)}
<div class="toolParamHelp" style="clear: both;">
${select_help|h}
</div>
@@ -72,7 +73,7 @@
%if includes_tools_for_display_in_tool_panel:
<div style="clear: both"></div>
<div class="form-row">
${no_changes_check_box.get_html()}
${render_checkbox(no_changes_check_box)}
<label style="display: inline;">No changes</label>
<div class="toolParamHelp" style="clear: both;">
Uncheck and select a different tool panel section to load the tools into a different section in the tool panel.
@@ -87,7 +88,7 @@
</div>
<div class="form-row">
<label>Select existing tool panel section:</label>
${tool_panel_section_select_field.get_html()}
${render_select(tool_panel_section_select_field)}
<div class="toolParamHelp" style="clear: both;">
Choose an existing section in your tool panel to contain the installed tools (optional).
</div>
@@ -1,6 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="common_misc_javascripts" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="javascripts()">
${parent.javascripts()}
@@ -28,7 +28,7 @@
</div>
<div style="clear: both"></div>
<div class="form-row">
${repositories_select_field.get_html()}
${render_select(repositories_select_field)}
</div>
<div style="clear: both"></div>
<div class="form-row">
@@ -3,6 +3,7 @@
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_dependencies_section" />
<%namespace file="/admin/tool_shed_repository/common.mako" import="render_readme_section" />
<%namespace file="/webapps/tool_shed/repository/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="stylesheets()">
${parent.stylesheets()}
@@ -149,7 +150,7 @@ or manually satisfy the dependencies listed below.</p>
%>
<div class="form-row">
<label>Shed tool configuration file:</label>
${shed_tool_conf_select_field.get_html()}
${render_select(shed_tool_conf_select_field)}
<div class="toolParamHelp" style="clear: both;">
${select_help|h}
</div>
@@ -169,7 +170,7 @@ or manually satisfy the dependencies listed below.</p>
</div>
<div class="form-row">
<label>Select existing tool panel section:</label>
${tool_panel_section_select_field.get_html()}
${render_select(tool_panel_section_select_field)}
<div class="toolParamHelp" style="clear: both;">
Choose an existing section in your tool panel to contain the installed tools (optional).
</div>
-112
View File
@@ -1,112 +0,0 @@
<%!
def inherit(context):
if context.get('use_panels'):
if context.get('webapp'):
app_name = context.get('webapp')
elif context.get('app'):
app_name = context.get('app').name
else:
app_name = 'galaxy'
return '/webapps/%s/base_panels.mako' % app_name
else:
return '/base.mako'
%>
<%inherit file="${inherit(context)}"/>
<% _=n_ %>
<%def name="init()">
<%
self.has_left_panel=False
self.has_right_panel=False
self.active_view=active_view
self.message_box_visible=False
%>
</%def>
<%def name="title()">${form.title | h}</%def>
<%def name="javascripts()">
${parent.javascripts()}
${h.js("libs/jquery/jquery.autocomplete")}
<script type="text/javascript">
$(function(){
$("input:text:first").focus();
})
</script>
</%def>
<%def name="stylesheets()">
${parent.stylesheets()}
${h.css("autocomplete_tagging")}
</%def>
<%def name="center_panel()">
${render_form( )}
</%def>
<%def name="body()">
${render_form( )}
</%def>
<%def name="render_form()">
%if header:
${header}
%endif
<div class="form" style="margin: 1em">
<div class="form-title">${util.unicodify( form.title ) | h }</div>
<div class="form-body">
<%
has_file_input = False
for input in form.inputs:
if input.type == 'file':
has_file_input = True
break
%>
<form name="${form.name | h }" action="${form.action}" method="post"
%if has_file_input:
enctype="multipart/form-data"
%endif
>
%for input in form.inputs:
<%
cls = "form-row"
if input.error:
cls += " form-row-error"
%>
<div class="${cls}">
%if input.use_label:
<label>
${_(input.label) | h }:
</label>
%endif
<div class="form-row-input">
%if input.type == 'textarea':
<textarea name="${input.name | h }">${input.value | h }</textarea>
%elif input.type == 'select':
<select name="${input.name | h}">
%for (name, value) in input.options:
<option value="${value | h }">${name | h }</option>
%endfor
</select>
%else:
<input type="${input.type}" name="${input.name | h }" value="${input.value | h }">
%endif
</div>
%if input.error:
<div class="form-row-error-message">${input.error | h }</div>
%endif
%if input.help:
<div class="toolParamHelp" style="clear: both;">
${input.help | h}
</div>
%endif
<div style="clear: both"></div>
</div>
%endfor
<div class="form-row"><input type="submit" value="${form.submit_text}"></div>
</form>
</div>
</div>
</%def>
+2 -4
View File
@@ -7,6 +7,7 @@ def inherit(context):
return '/base.mako'
%>
<%inherit file="${inherit(context)}"/>
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="init()">
<%
@@ -169,10 +170,7 @@ def inherit(context):
%if trans.app.config.smtp_server and trans.app.config.mailing_join_addr:
<div class="form-row">
<label>Subscribe to mailing list:</label>
%if subscribe_checked:
<% subscribe_check_box.checked = True %>
%endif
${subscribe_check_box.get_html()}
${render_checkbox(subscribe_check_box)}
<p>See <a href="https://galaxyproject.org/mailing-lists/" target="_blank">
all Galaxy project mailing lists</a>.</p>
</div>
@@ -1,5 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="javascripts()">
${parent.javascripts()}
@@ -90,7 +91,7 @@ $().ready(function() {
%if create_role_for_group_checked:
<% create_role_for_group_checkbox.checked = True %>
%endif
${create_role_for_group_checkbox.get_html()} Create a new role of the same name for this group
${render_checkbox(create_role_for_group_checkbox)} Create a new role of the same name for this group
</div>
<div class="form-row">
<input type="submit" name="create_group_button" value="Save"/>
@@ -1,5 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="javascripts()">
${parent.javascripts()}
@@ -94,7 +95,7 @@
%if create_group_for_role_checked:
<% create_group_for_role_checkbox.checked = True %>
%endif
${create_group_for_role_checkbox.get_html()} Create a new group of the same name for this role
${render_checkbox(create_group_for_role_checkbox)} Create a new group of the same name for this role
</div>
<div class="form-row">
<input type="submit" name="create_role_button" value="Save"/>
@@ -1,3 +1,37 @@
<%def name="render_checkbox(checkbox, disabled=False, refresh_on_change=False)">
<% from galaxy.web.form_builder import CheckboxField %>
<input type="checkbox" id="${checkbox.name}" name="${checkbox.name}" value="true"
${"refresh_on_change='true'" if refresh_on_change else ""}
${"checked" if CheckboxField.is_checked(checkbox.value) else ""}
${"disabled" if disabled else ""}
>
</%def>
<%def name="render_select(select)">
<% from markupsafe import escape %>
<% from galaxy.util import listify %>
%if select.display == "checkboxes":
%for o in select.options:
<div>
<% selected = o[1] in listify(select.value) or o[2] %>
<input type="checkbox" name="${select.name}" value="${escape(o[1])}"
${"refresh_on_change='true'" if select.refresh_on_change else ""}"
${"checked" if selected else ""} ${"disabled" if disabled else ""}>
${escape(o[0])}
</div>
%endfor
%else:
<select id="${select.field_id}" name="${select.name}"
${"multiple" if select.multiple else ""}
${"refresh_on_change='true'" if select.refresh_on_change else ""}">
%for o in select.options:
<% selected = o[1] in listify(select.value) or o[2] %>
<option value="${escape(o[1])}" ${"selected" if selected else ""}>${escape(o[0])}</option>
%endfor
</select>
%endif
</%def>
<%def name="common_misc_javascripts()">
<script type="text/javascript">
function checkAllFields( chkAll, name )
@@ -1,6 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="common_misc_javascripts" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="javascripts()">
${parent.javascripts()}
@@ -51,7 +51,7 @@
</div>
<div style="clear: both"></div>
<div class="form-row">
${repositories_select_field.get_html()}
${render_select(repositories_select_field)}
</div>
<div style="clear: both"></div>
<div class="form-row">
@@ -1,3 +1,4 @@
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%def name="common_javascripts(repository)">
<script type="text/javascript">
$(function(){
@@ -195,7 +196,7 @@
</div>
%endif
%else:
${repository_type_select_field.get_html()}
${render_select(repository_type_select_field)}
%if render_help:
<div class="toolParamHelp" style="clear: both;">
Select the repository type based on the following criteria.
@@ -1,5 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/repository_actions_menu.mako" import="render_galaxy_repository_actions" />
<%!
@@ -47,7 +48,7 @@
<div style="clear: both"></div>
<div class="form-row">
<label>Exact matches only:</label>
${exact_matches_check_box.get_html()}
${render_checkbox(exact_matches_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box to match text exactly (text case doesn't matter as all strings are forced to lower case).
</div>
@@ -1,5 +1,6 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<%namespace file="/webapps/tool_shed/common/common.mako" import="*" />
<%namespace file="/webapps/tool_shed/common/repository_actions_menu.mako" import="render_galaxy_repository_actions" />
<%!
@@ -36,7 +37,7 @@
<div style="clear: both"></div>
<div class="form-row">
<label>Exact matches only:</label>
${exact_matches_check_box.get_html()}
${render_checkbox(exact_matches_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box to match text exactly (text case doesn't matter as all strings are forced to lower case).
</div>
@@ -125,14 +125,13 @@ ${render_tool_shed_repository_actions( repository, metadata=metadata, changeset_
%if deprecated_repository_dependency_tups:
${render_deprecated_repository_dependencies_message( deprecated_repository_dependency_tups )}
%endif
%if len( changeset_revision_select_field.options ) > 1:
<div class="toolForm">
<div class="toolFormTitle">Repository revision</div>
<div class="toolFormBody">
<form name="change_revision" id="change_revision" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
<div class="form-row">
${changeset_revision_select_field.get_html()} <i>${tip_str}</i>
${render_select(changeset_revision_select_field)} <i>${tip_str}</i>
<div class="toolParamHelp" style="clear: both;">
%if can_review_repository:
Select a revision to inspect for adding or managing a review or for download or installation.
@@ -279,7 +278,7 @@ ${render_repository_items( metadata, containers_dict, can_set_metadata=True, ren
<form name="receive_email_alerts" id="receive_email_alerts" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
<div class="form-row">
<label>Receive email alerts:</label>
${alerts_check_box.get_html()}
${render_checkbox(alerts_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box and click <b>Save</b> to receive email alerts when updates to this repository occur.
</div>
@@ -315,7 +314,7 @@ ${render_repository_items( metadata, containers_dict, can_set_metadata=True, ren
<form name="user_access" id="user_access" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
<div class="form-row">
<label>Username:</label>
${allow_push_select_field.get_html()}
${render_select(allow_push_select_field)}
<div class="toolParamHelp" style="clear: both;">
Multi-select usernames to grant permission to make changes to this repository
</div>
@@ -396,7 +395,7 @@ ${render_repository_items( metadata, containers_dict, can_set_metadata=True, ren
<form name="malicious" id="malicious" action="${h.url_for( controller='repository', action='set_malicious', id=trans.security.encode_id( repository.id ), ctx_str=changeset_revision )}" method="post">
<div class="form-row">
<label>Define repository tip as malicious:</label>
${malicious_check_box.get_html()}
${render_checkbox(malicious_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box and click <b>Save</b> to define this repository's tip as malicious, restricting it from being download-able.
</div>
@@ -42,7 +42,7 @@ ${render_galaxy_repository_actions( repository=repository )}
else:
tip_str = ''
%>
${changeset_revision_select_field.get_html()} <i>${tip_str | h}</i>
${render_select(changeset_revision_select_field)} <i>${tip_str | h}</i>
<div class="toolParamHelp" style="clear: both;">
Select a revision to inspect and download versions of Galaxy utilities from this repository.
</div>
@@ -75,40 +75,8 @@
</%def>
<%def name="row_for_param( prefix, param, parent_state, other_values )">
<%
# Disable refresh_on_change for select lists displayed in the tool shed.
param.refresh_on_change = False
label = param.get_label()
if isinstance( param, DataToolParameter ) or isinstance( param, ColumnListParameter ) or isinstance( param, GenomeBuildParameter ):
field = SelectField( param.name )
field.add_option( param.name, param.name )
field_html = field.get_html()
elif isinstance( param, SelectToolParameter ) and hasattr( param, 'data_ref' ):
field = SelectField( param.name, display=param.display, multiple=param.multiple )
field.add_option( param.data_ref, param.data_ref )
field_html = field.get_html( prefix )
elif isinstance( param, SelectToolParameter ) and param.is_dynamic:
field = SelectField( param.name, display=param.display, multiple=param.multiple )
dynamic_options = param.options
if dynamic_options is not None:
if dynamic_options.index_file:
option_label = "Dynamically generated from entries in file %s" % str( dynamic_options.index_file )
field.add_option( option_label, "none" )
elif dynamic_options.missing_index_file:
option_label = "Dynamically generated from entries in missing file %s" % str( dynamic_options.missing_index_file )
field.add_option( option_label, "none" )
else:
field.add_option( "Dynamically generated from old-style Dynamic Options.", "none" )
field_html = field.get_html( prefix )
else:
field = TextField( param.name, value="Parameter type: %s" % param.type )
field_html = field.get_html( prefix, disabled=True )
%>
<div class="form-row">
%if label:
<label for="${param.name}">${label}:</label>
%endif
<div class="form-row-input">${field_html}</div>
<label >${param.label or param.name}:</label>
%if param.help:
<div class="toolParamHelp" style="clear: both;">
${param.help}
@@ -88,7 +88,7 @@
<div class="toolFormBody">
<form name="change_revision" id="change_revision" action="${h.url_for( controller='repository', action='view_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
<div class="form-row">
${changeset_revision_select_field.get_html()} <i>${tip_str}</i>
${render_select(changeset_revision_select_field)} <i>${tip_str}</i>
<div class="toolParamHelp" style="clear: both;">
Select a revision to inspect and download versions of Galaxy utilities from this repository.
</div>
@@ -202,7 +202,7 @@ ${render_repository_items( metadata, containers_dict, can_set_metadata=False, re
<form name="receive_email_alerts" id="receive_email_alerts" action="${h.url_for( controller='repository', action='view_repository', id=trans.security.encode_id( repository.id ) )}" method="post" >
<div class="form-row">
<label>Receive email alerts:</label>
${alerts_check_box.get_html()}
${render_checkbox(alerts_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box and click <b>Save</b> to receive email alerts when updates to this repository occur.
</div>
@@ -57,7 +57,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
if can_browse:
# Initialize Private check box.
private_check_box_name = '%s%sprivate' % ( component.name, STRSEP )
private_check_box = CheckboxField( name=private_check_box_name, checked=component_review.private )
private_check_box = CheckboxField( name=private_check_box_name, value=component_review.private )
# Initialize star rating.
rating_name = '%s%srating' % ( component.name, STRSEP )
@@ -73,7 +73,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
<tr>
<td>
<label>Private:</label>
${private_check_box.get_html( disabled=True )}
${render_checkbox(private_check_box, disabled=True)}
<div class="toolParamHelp" style="clear: both;">
A private review can be accessed only by the owner of the repository and authorized repository reviewers.
</div>
@@ -45,7 +45,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
</div>
<div class="form-row">
<label>Approve this repository revision?</label>
${revision_approved_select_field.get_html()}
${render_select(revision_approved_select_field)}
<div class="toolParamHelp" style="clear: both;">
Individual components below may be approved without approving the repository revision.
</div>
@@ -83,7 +83,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
# Initialize Private check box.
private_check_box_name = '%s%sprivate' % ( component_name, STRSEP )
private_check_box = CheckboxField( name=private_check_box_name, checked=private )
private_check_box = CheckboxField( name=private_check_box_name, value=private )
# Initialize star rating.
rating_name = '%s%srating' % ( component_name, STRSEP )
@@ -107,7 +107,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
<tr>
<td>
<label>Mark private:</label>
${private_check_box.get_html()}
${render_checkbox(private_check_box)}
<div class="toolParamHelp" style="clear: both;">
A private review can be accessed only by the owner of the repository and authorized repository reviewers.
</div>
@@ -128,7 +128,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
<tr>
<td>
<label>Approved:</label>
${approved_select_field.get_html()}
${render_select(approved_select_field)}
<div style="clear: both"></div>
</td>
</tr>
@@ -90,7 +90,7 @@ ${render_tool_shed_repository_actions( repository=repository, changeset_revision
<td>${render_star_rating( repository_rating_name, review.rating, disabled=True )}</td>
%if review.user == trans.user:
<form name="approve_repository_review" action="${h.url_for( controller='repository_review', action='approve_repository_review', id=encoded_review_id ) }" method="post" >
<td>${approved_select_field.get_html()}</td>
<td>${render_select(approved_select_field)}</td>
<td><input type="submit" name="approve_repository_review_button" value="Save"/></td>
</form>
%else:
@@ -20,7 +20,7 @@
<form name="new_repo_alert" id="new_repo_alert" action="${h.url_for( controller='repository', action='manage_email_alerts' )}" method="post" >
<div class="form-row">
<label>New repository alert:</label>
${new_repo_alert_check_box.get_html()}
${render_checkbox(new_repo_alert_check_box)}
<div class="toolParamHelp" style="clear: both;">
Check the box and click <b>Save</b> to receive email when the first change set is created for a new repository.
</div>
+2 -2
View File
@@ -1111,12 +1111,12 @@ class ShedTwillTestCase(TwillTestCase):
params = dict(id=encoded_repository_id, no_changes=no_changes, new_tool_panel_section_label=new_tool_panel_section_label)
doseq = False
if install_repository_dependencies:
params['install_repository_dependencies'] = ['True', 'True']
params['install_repository_dependencies'] = True
doseq = True
else:
params['install_repository_dependencies'] = False
if install_tool_dependencies:
params['install_tool_dependencies'] = ['True', 'True']
params['install_tool_dependencies'] = True
doseq = True
else:
params['install_tool_dependencies'] = False