From 5b11e90fea41e9c9b62cbd7c349808fc77e0d2cd Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Thu, 11 Jun 2009 16:44:19 -0400 Subject: [PATCH] - allow filtering by enabled/disabled on the hosts page (default to showing only enabled hosts) --- hub/kojihub.py | 10 ++++++++-- www/kojiweb/hosts.chtml | 41 +++++++++++++++++++++++++++++------------ www/kojiweb/index.py | 14 ++++++++++++-- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/hub/kojihub.py b/hub/kojihub.py index a8531851..45e6973e 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -6239,9 +6239,15 @@ class RootExports(object): joins.append('host_channels on host.id = host_channels.host_id') clauses.append('host_channels.channel_id = %(channelID)i') if ready != None: - clauses.append('ready is %s' % ready) + if ready: + clauses.append('ready is true') + else: + clauses.append('ready is false') if enabled != None: - clauses.append('enabled is %s' % enabled) + if enabled: + clauses.append('enabled is true') + else: + clauses.append('enabled is false') if userID != None: clauses.append('user_id = %(userID)i') diff --git a/www/kojiweb/hosts.chtml b/www/kojiweb/hosts.chtml index 3466cd6b..0750f777 100644 --- a/www/kojiweb/hosts.chtml +++ b/www/kojiweb/hosts.chtml @@ -1,15 +1,32 @@ #from kojiweb import util +#attr _PASSTHROUGH = ['state', 'order'] + #include "includes/header.chtml"

Hosts

+ + + - - - - - - + + + + + + #if $len($hosts) > 0 #for $host in $hosts @@ -56,7 +73,7 @@ #if $len($hostPages) > 1 Page: - #for $pageNum in $hostPages #end for @@ -64,13 +81,13 @@ #end if #if $hostStart > 0 - <<< + <<< #end if #if $totalHosts != 0 Hosts #echo $hostStart + 1 # through #echo $hostStart + $hostCount # of $totalHosts #end if #if $hostStart + $hostCount < $totalHosts - >>> + >>> #end if diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 9aab8c51..b050481d 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -1238,13 +1238,23 @@ def cancelbuild(req, buildID): mod_python.util.redirect(req, 'buildinfo?buildID=%i' % build['id']) -def hosts(req, start=None, order='name'): +def hosts(req, state='enabled', start=None, order='name'): values = _initValues(req, 'Hosts', 'hosts') server = _getServer(req) values['order'] = order - hosts = server.listHosts() + args = {} + + if state == 'enabled': + args['enabled'] = True + elif state == 'disabled': + args['enabled'] = False + else: + state = 'all' + values['state'] = state + + hosts = server.listHosts(**args) server.multicall = True for host in hosts:
+ + +
+ State: + + +
+
#if $len($hostPages) > 1
Page: - #for $pageNum in $hostPages #end for @@ -17,23 +34,23 @@
#end if #if $hostStart > 0 - <<< + <<< #end if #if $totalHosts != 0 Hosts #echo $hostStart + 1 # through #echo $hostStart + $hostCount # of $totalHosts #end if #if $hostStart + $hostCount < $totalHosts - >>> + >>> #end if
ID $util.sortImage($self, 'id')Name $util.sortImage($self, 'name')Arches $util.sortImage($self, 'arches')Enabled? $util.sortImage($self, 'enabled')Ready? $util.sortImage($self, 'ready')Last Update $util.sortImage($self, 'last_update')ID $util.sortImage($self, 'id')Name $util.sortImage($self, 'name')Arches $util.sortImage($self, 'arches')Enabled? $util.sortImage($self, 'enabled')Ready? $util.sortImage($self, 'ready')Last Update $util.sortImage($self, 'last_update')