Skip to content

Commit

Permalink
Remove form util helper from use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Dec 6, 2017
1 parent 4fd9635 commit c20277d
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 28 deletions.
3 changes: 2 additions & 1 deletion lib/galaxy/web/form_builder.py
Expand Up @@ -87,10 +87,11 @@ class SelectField(BaseField):
A select field.
"""

def __init__(self, name, multiple=None, display=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.field_id = field_id
self.multiple = multiple or False
self.refresh_on_change = refresh_on_change
self.selectlist = selectlist or []
self.options = list()
if display == "checkboxes":
Expand Down
15 changes: 14 additions & 1 deletion lib/galaxy/webapps/tool_shed/controllers/repository.py
Expand Up @@ -1932,7 +1932,20 @@ def manage_repository(self, trans, id, **kwd):
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_push_list:
options.append(user)
allow_push_select_field = SelectField(name='allow_push',
multiple=True,
display=display,
value=selected_value)
for obj in objs:
label = getattr(obj, 'username')
if str(selected_value) == str(obj.id) or str(selected_value) == trans.security.encode_id(obj.id):
allow_push_select_field.add_option(label, trans.security.encode_id(obj.id), selected=True)
else:
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', value=checked)
changeset_revision_select_field = grids_util.build_changeset_revision_select_field(trans,
Expand Down
Expand Up @@ -5,13 +5,13 @@

from galaxy import util
from galaxy.util import inflector
from galaxy.web.form_builder import SelectField
from tool_shed.galaxy_install.tools import tool_panel_manager
from tool_shed.metadata import metadata_generator
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
from tool_shed.util.form_util import SelectField
log = logging.getLogger(__name__)


Expand Down
6 changes: 2 additions & 4 deletions lib/tool_shed/grids/util.py
@@ -1,7 +1,7 @@
import logging

from galaxy.web.form_builder import SelectField
from tool_shed.util import hg_util, metadata_util
from tool_shed.util.form_util import SelectField

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/metadata/repository_metadata_manager.py
Expand Up @@ -5,12 +5,12 @@

from galaxy import util
from galaxy.util import inflector
from galaxy.web.form_builder import SelectField
from tool_shed.metadata import metadata_generator
from tool_shed.repository_types import util as rt_util
from tool_shed.repository_types.metadata import TipOnly
from tool_shed.util import (basic_util, common_util, hg_util, metadata_util,
repository_util, shed_util_common as suc, tool_util)
from tool_shed.util.form_util import SelectField

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/repository_types/util.py
@@ -1,6 +1,6 @@
import logging

from tool_shed.util.form_util import SelectField
from galaxy.web.form_builder import SelectField

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/util/admin_util.py
Expand Up @@ -4,7 +4,7 @@

from galaxy import util, web
from galaxy.util import inflector
from tool_shed.util.form_util import CheckboxField
from galaxy.web.form_builder import CheckboxField
from tool_shed.util.web_util import escape


Expand Down
16 changes: 1 addition & 15 deletions lib/tool_shed/util/repository_util.py
Expand Up @@ -11,28 +11,14 @@
import tool_shed.util.metadata_util as metadata_util
from galaxy import util
from galaxy import web
from tool_shed.util import basic_util, common_util, encoding_util, form_util, hg_util
from tool_shed.util import basic_util, common_util, encoding_util, hg_util
from tool_shed.util.web_util import escape

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 form_util.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)
Expand Down
4 changes: 2 additions & 2 deletions lib/tool_shed/util/tool_dependency_util.py
Expand Up @@ -5,8 +5,8 @@
from sqlalchemy import and_

from galaxy import util
from galaxy.web.form_builder import SelectField
from tool_shed.util import (
form_util,
hg_util,
xml_util
)
Expand All @@ -20,7 +20,7 @@ def build_tool_dependencies_select_field(app, tool_shed_repository, name, multip
Generate a SelectField consisting of the current list of tool dependency ids
for an installed tool shed repository.
"""
tool_dependencies_select_field = form_util.SelectField(name=name, multiple=multiple, display=display)
tool_dependencies_select_field = SelectField(name=name, multiple=multiple, display=display)
for tool_dependency in tool_shed_repository.tool_dependencies:
if uninstalled_only:
if tool_dependency.status not in [app.install_model.ToolDependency.installation_status.NEVER_INSTALLED,
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/util/tool_util.py
Expand Up @@ -7,8 +7,8 @@
from galaxy.datatypes.sniff import is_column_based
from galaxy.util import checkers
from galaxy.util.expressions import ExpressionContext
from galaxy.web.form_builder import SelectField
from tool_shed.util import basic_util
from tool_shed.util.form_util import SelectField

log = logging.getLogger(__name__)

Expand Down

0 comments on commit c20277d

Please sign in to comment.