enable displaying of only the latest builds in a tag

This commit is contained in:
Mike Bonnet 2009-02-09 13:47:07 -05:00
parent e71e348b1f
commit a864d8ef4d
2 changed files with 22 additions and 6 deletions

View file

@ -1,17 +1,25 @@
#import koji
#from kojiweb import util
#attr _PASSTHROUGH = ['userID', 'tagID', 'packageID', 'order', 'prefix', 'state', 'inherited']
#attr _PASSTHROUGH = ['userID', 'tagID', 'packageID', 'order', 'prefix', 'state', 'inherited', 'latest']
#include "includes/header.chtml"
<h4>#if $state != None then $util.stateName($state).capitalize() else ''# Builds#if $package then ' of <a href="packageinfo?packageID=%i">%s</a>' % ($package.id, $package.name) else ''##if $prefix then ' starting with "%s"' % $prefix else ''##if $user then ' by <a href="userinfo?userID=%i">%s</a>' % ($user.id, $user.name) else ''##if $tag then ' in tag <a href="taginfo?tagID=%i">%s</a>' % ($tag.id, $tag.name) else ''#</h4>
<h4>#if $latest then 'Latest ' else ''##if $state != None then $util.stateName($state).capitalize() + ' ' else ''#Builds#if $package then ' of <a href="packageinfo?packageID=%i">%s</a>' % ($package.id, $package.name) else ''##if $prefix then ' starting with "%s"' % $prefix else ''##if $user then ' by <a href="userinfo?userID=%i">%s</a>' % ($user.id, $user.name) else ''##if $tag then ' in tag <a href="taginfo?tagID=%i">%s</a>' % ($tag.id, $tag.name) else ''#</h4>
<table class="data-list">
<tr>
<td colspan="#if $tag then '6' else '5'#">
<table class="nested">
<tr><td>
#if $tag
<strong>Latest</strong>:
</td><td>
<select name="latest" class="filterlist" onchange="javascript: window.location = 'builds?latest=' + this.value + '$util.passthrough_except($self, 'latest')';">
<option value="1" #if $latest then 'selected="selected"' else ''#>yes</option>
<option value="0" #if not $latest then 'selected="selected"' else ''#>no</option>
</select>
#else
<strong>State</strong>:
</td><td>
<select name="state" class="filterlist" onchange="javascript: window.location = 'builds?state=' + this.value + '$util.passthrough_except($self, 'state')';">
@ -20,6 +28,7 @@
<option value="$koji.BUILD_STATES[$stateOpt]" #if $state == $koji.BUILD_STATES[$stateOpt] then 'selected="selected"' else ''#>$stateOpt.lower()</option>
#end for
</select>
#end if
</td><td>
<strong>Built by</strong>:
</td><td>

View file

@ -1070,7 +1070,7 @@ def buildinfo(req, buildID):
return _genHTML(req, 'buildinfo.chtml')
def builds(req, userID=None, tagID=None, packageID=None, state=None, order='-completion_time', start=None, prefix=None, inherited='1'):
def builds(req, userID=None, tagID=None, packageID=None, state=None, order='-completion_time', start=None, prefix=None, inherited='1', latest='1'):
values = _initValues(req, 'Builds', 'builds')
server = _getServer(req)
@ -1114,14 +1114,21 @@ def builds(req, userID=None, tagID=None, packageID=None, state=None, order='-com
values['prefix'] = prefix
values['order'] = order
inherited = int(inherited)
values['inherited'] = inherited
if tag:
inherited = int(inherited)
values['inherited'] = inherited
latest = int(latest)
values['latest'] = latest
else:
values['inherited'] = None
values['latest'] = None
if tag:
# don't need to consider 'state' here, since only completed builds would be tagged
builds = kojiweb.util.paginateResults(server, values, 'listTagged', kw={'tag': tag['id'], 'package': (package and package['name'] or None),
'owner': (user and user['name'] or None),
'inherit': bool(inherited), 'prefix': prefix},
'inherit': bool(inherited), 'latest': bool(latest), 'prefix': prefix},
start=start, dataName='builds', prefix='build', order=order)
else:
builds = kojiweb.util.paginateMethod(server, values, 'listBuilds', kw={'userID': (user and user['id'] or None), 'packageID': (package and package['id'] or None),