Add blocked option to packages page

Fixes: https://pagure.io/koji/issue/3330
This commit is contained in:
Jana Cupova 2022-04-19 14:40:00 +02:00 committed by Tomas Kopecek
parent c1b45d3d91
commit 0faf0d8409
3 changed files with 28 additions and 17 deletions

View file

@ -915,7 +915,7 @@ _PREFIX_CHARS = [chr(char) for char in list(range(48, 58)) + list(range(97, 123)
def packages(environ, tagID=None, userID=None, order='package_name', start=None, prefix=None,
inherited='1'):
inherited='1', blocked='1'):
values = _initValues(environ, 'Packages', 'packages')
server = _getServer(environ)
tag = None
@ -938,12 +938,15 @@ def packages(environ, tagID=None, userID=None, order='package_name', start=None,
values['prefix'] = prefix
inherited = int(inherited)
values['inherited'] = inherited
blocked = int(blocked)
values['blocked'] = blocked
kojiweb.util.paginateMethod(server, values, 'listPackages',
kw={'tagID': tagID,
'userID': userID,
'prefix': prefix,
'inherited': bool(inherited)},
'inherited': bool(inherited),
'with_blocked': bool(blocked)},
start=start, dataName='packages', prefix='package', order=order)
values['chars'] = _PREFIX_CHARS

View file

@ -1,6 +1,6 @@
#from kojiweb import util
#attr _PASSTHROUGH = ['userID', 'tagID', 'order', 'prefix', 'inherited']
#attr _PASSTHROUGH = ['userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked']
#include "includes/header.chtml"
@ -19,6 +19,14 @@
<option value="0" #if not $inherited then 'selected="selected"' else ''#>no</option>
</select>
</td></tr>
<tr><td>
<strong>With blocked</strong>:
</td><td>
<select name="blocked" class="filterlist" onchange="javascript: window.location = 'packages?blocked=' + this.value + '$util.passthrough_except($self, 'blocked')';">
<option value="1" #if $blocked then 'selected="selected"' else ''#>yes</option>
<option value="0" #if not $blocked then 'selected="selected"' else ''#>no</option>
</select>
</td></tr>
</table>
</tr>
#end if
@ -28,12 +36,12 @@
#if $prefix == $char
<strong>$char</strong>
#else
<a href="packages?prefix=$char$util.passthrough($self, 'userID', 'tagID', 'order', 'inherited')">$char</a>
<a href="packages?prefix=$char$util.passthrough($self, 'userID', 'tagID', 'order', 'inherited', 'blocked')">$char</a>
#end if
|
#end for
#if $prefix
<a href="packages?${util.passthrough($self, 'userID', 'tagID', 'order', 'inherited')[1:]}">all</a>
<a href="packages?${util.passthrough($self, 'userID', 'tagID', 'order', 'inherited', 'blocked')[1:]}">all</a>
#else
<strong>all</strong>
#end if
@ -44,7 +52,7 @@
#if $len($packagePages) > 1
<form class="pageJump" action="">
Page:
<select onchange="javascript: window.location = 'packages?start=' + this.value * $packageRange + '$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited')';">
<select onchange="javascript: window.location = 'packages?start=' + this.value * $packageRange + '$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked')';">
#for $pageNum in $packagePages
<option value="$pageNum"#if $pageNum == $packageCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
#end for
@ -52,23 +60,23 @@
</form>
#end if
#if $packageStart > 0
<a href="packages?start=#echo $packageStart - $packageRange #$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited')">&lt;&lt;&lt;</a>
<a href="packages?start=#echo $packageStart - $packageRange #$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked')">&lt;&lt;&lt;</a>
#end if
#if $totalPackages != 0
<strong>Packages #echo $packageStart + 1 # through #echo $packageStart + $packageCount # of $totalPackages</strong>
#end if
#if $packageStart + $packageCount < $totalPackages
<a href="packages?start=#echo $packageStart + $packageRange#$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited')">&gt;&gt;&gt;</a>
<a href="packages?start=#echo $packageStart + $packageRange#$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked')">&gt;&gt;&gt;</a>
#end if
</td>
</tr>
<tr class="list-header">
<th><a href="packages?order=$util.toggleOrder($self, 'package_id')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited')">ID</a> $util.sortImage($self, 'package_id')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'package_name')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited')">Name</a> $util.sortImage($self, 'package_name')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'package_id')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited', 'blocked')">ID</a> $util.sortImage($self, 'package_id')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'package_name')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited', 'blocked')">Name</a> $util.sortImage($self, 'package_name')</th>
#if $tag or $user
<th><a href="packages?order=$util.toggleOrder($self, 'tag_name')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited')">Tag</a> $util.sortImage($self, 'tag_name')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'owner_name')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited')">Owner</a> $util.sortImage($self, 'owner_name')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'blocked')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited')">Included?</a> $util.sortImage($self, 'blocked')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'tag_name')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited', 'blocked')">Tag</a> $util.sortImage($self, 'tag_name')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'owner_name')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited', 'blocked')">Owner</a> $util.sortImage($self, 'owner_name')</th>
<th><a href="packages?order=$util.toggleOrder($self, 'blocked')$util.passthrough($self, 'userID', 'tagID', 'prefix', 'inherited', 'blocked')">Included?</a> $util.sortImage($self, 'blocked')</th>
#end if
</tr>
#if $len($packages) > 0
@ -93,7 +101,7 @@
#if $len($packagePages) > 1
<form class="pageJump" action="">
Page:
<select onchange="javascript: window.location = 'packages?start=' + this.value * $packageRange + '$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited')';">
<select onchange="javascript: window.location = 'packages?start=' + this.value * $packageRange + '$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked')';">
#for $pageNum in $packagePages
<option value="$pageNum"#if $pageNum == $packageCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
#end for
@ -101,13 +109,13 @@
</form>
#end if
#if $packageStart > 0
<a href="packages?start=#echo $packageStart - $packageRange #$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited')">&lt;&lt;&lt;</a>
<a href="packages?start=#echo $packageStart - $packageRange #$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked')">&lt;&lt;&lt;</a>
#end if
#if $totalPackages != 0
<strong>Packages #echo $packageStart + 1 # through #echo $packageStart + $packageCount # of $totalPackages</strong>
#end if
#if $packageStart + $packageCount < $totalPackages
<a href="packages?start=#echo $packageStart + $packageRange#$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited')">&gt;&gt;&gt;</a>
<a href="packages?start=#echo $packageStart + $packageRange#$util.passthrough($self, 'userID', 'tagID', 'order', 'prefix', 'inherited', 'blocked')">&gt;&gt;&gt;</a>
#end if
</td>
</tr>

View file

@ -122,7 +122,7 @@
</tr>
<tr>
<th>Packages</th>
<td><a href="packages?tagID=$tag.id">$numPackages</a></td>
<td><a href="packages?blocked=0&tagID=$tag.id">$numPackages</a></td>
</tr>
<tr>
<th>Packages (blocked packages included)</th>