Skip to content

Commit 13ec521

Browse files
committed
issue685275 - show retired/unretired items in roundup-admin
add pragma display_header to print headers for display command. Header displays designator and retired/active status. Add doc of pragma to affected commands. Add test for code paths.
1 parent bd6a7b9 commit 13ec521

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

roundup/admin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def __init__(self):
104104
self.db_uncommitted = False
105105
self.force = None
106106
self.settings = {
107+
'display_header': False,
107108
'display_protected': False,
108109
'indexer_backend': "as set in config.ini",
109110
'_reopen_tracker': False,
@@ -114,6 +115,10 @@ def __init__(self):
114115
'_floattest': 3.5,
115116
}
116117
self.settings_help = {
118+
'display_header':
119+
_("Have 'display designator[,designator*]' show header inside "
120+
" []'s before items. Includes retired/active status."),
121+
117122
'display_protected':
118123
_("Have 'display designator' and 'specification class' show "
119124
"protected fields: creator, id etc."),
@@ -533,6 +538,9 @@ def do_display(self, args):
533538
else:
534539
keys = normal_props
535540

541+
if self.settings['display_header']:
542+
status = "retired" if cl.is_retired(nodeid) else "active"
543+
print('\n[%s (%s)]' % (designator, status))
536544
for key in keys:
537545
value = cl.get(nodeid, key)
538546
# prepend * for protected properties else just indent

share/man/man1/roundup-admin.1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ command.
7676
.TP
7777
\fBdisplay\fP \fIdesignator[,designator]*\fP
7878
This lists the properties and their associated values for the given
79-
node.
79+
node. The pragma \fBdisplay_header\fP can be used to add a header
80+
between designators that includes the active/retired status of
81+
the item.
8082
.TP
8183
\fBexport\fP \fI[[-]class[,class]] export_dir\fP
8284
Export the database to colon-separated-value files.
@@ -182,6 +184,10 @@ property, alphabetically.
182184
With \fB-c\fP, \fB-S\fP or \fB-s\fP print a list of item id's if no
183185
property specified. If property specified, print list of that
184186
property for every class instance.
187+
188+
The pragma \fBshow_retired\fP can be used to print only retired items
189+
or to print retired and active items. The default is to print only
190+
active items.
185191
.TP
186192
\fBmigrate\fP
187193
Update a tracker's database to be compatible with the Roundup
@@ -272,6 +278,10 @@ Lists the names, location and description of all known templates.
272278
Lists all instances of the given class. If the properties are not
273279
specified, all properties are displayed. By default, the column
274280
widths are the width of the largest value.
281+
282+
The pragma \fBshow_retired\fP can be used to print only retired items
283+
or to print retired and active items. The default is to print only
284+
active items.
275285
.TP
276286
\fBupdateconfig\fP \fI<filename>\fP
277287
This is used when updating software. It merges the \fBconfig.ini\fP

test/test_admin.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,8 +1639,7 @@ def testRetireRestore(self):
16391639
expected_list=sorted("1: admin\n 2: anonymous\n 3: user1\n 4: user1".split("\n"))
16401640
self.assertEqual(out_list, expected_list)
16411641

1642-
1643-
# verify that active users
1642+
# verify that active users are shown
16441643
self.admin=AdminTool()
16451644
with captured_output() as (out, err):
16461645
sys.argv=['main', '-i', self.dirname, '-P',
@@ -1651,6 +1650,26 @@ def testRetireRestore(self):
16511650
expected="1: admin\n 2: anonymous\n 3: user1"
16521651
self.assertEqual(out, expected)
16531652

1653+
# test display headers for retired/active
1654+
self.admin=AdminTool()
1655+
with captured_output() as (out, err):
1656+
sys.argv=['main', '-i', self.dirname, '-P',
1657+
'display_header=yes', 'display', 'user3,user4']
1658+
ret = self.admin.main()
1659+
out = out.getvalue().strip()
1660+
print(out)
1661+
self.assertIn("[user3 (active)]\n", out)
1662+
self.assertIn( "[user4 (retired)]\n", out)
1663+
1664+
# test that there are no headers
1665+
self.admin=AdminTool()
1666+
with captured_output() as (out, err):
1667+
sys.argv=['main', '-i', self.dirname, 'display', 'user3,user4']
1668+
ret = self.admin.main()
1669+
out = out.getvalue().strip()
1670+
print(out)
1671+
self.assertNotIn("user3", out)
1672+
self.assertNotIn("user4", out)
16541673

16551674
def testTable(self):
16561675
''' Note the tests will fail if you run this under pdb.

0 commit comments

Comments
 (0)