changeset 7549:73dfa9df9fb0

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.
author John Rouillard <rouilj@ieee.org>
date Fri, 14 Jul 2023 22:07:23 -0400
parents 793f4b63c538
children 706f3be6ffbb
files roundup/admin.py share/man/man1/roundup-admin.1 test/test_admin.py
diffstat 3 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/admin.py	Fri Jul 14 21:56:27 2023 -0400
+++ b/roundup/admin.py	Fri Jul 14 22:07:23 2023 -0400
@@ -104,6 +104,7 @@
         self.db_uncommitted = False
         self.force = None
         self.settings = {
+            'display_header': False,
             'display_protected': False,
             'indexer_backend': "as set in config.ini",
             '_reopen_tracker': False,
@@ -114,6 +115,10 @@
             '_floattest': 3.5,
         }
         self.settings_help = {
+            'display_header':
+            _("Have 'display designator[,designator*]' show header inside "
+              "         []'s before items. Includes retired/active status."),
+
             'display_protected':
             _("Have 'display designator' and 'specification class' show "
               "protected fields: creator, id etc."),
@@ -533,6 +538,9 @@
             else:
                 keys = normal_props
 
+            if self.settings['display_header']:
+                status = "retired" if cl.is_retired(nodeid) else "active"
+                print('\n[%s (%s)]' % (designator, status))
             for key in keys:
                 value = cl.get(nodeid, key)
                 # prepend * for protected properties else just indent
--- a/share/man/man1/roundup-admin.1	Fri Jul 14 21:56:27 2023 -0400
+++ b/share/man/man1/roundup-admin.1	Fri Jul 14 22:07:23 2023 -0400
@@ -76,7 +76,9 @@
 .TP
 \fBdisplay\fP \fIdesignator[,designator]*\fP
 This lists the properties and their associated values for the given
-node.
+node. The pragma \fBdisplay_header\fP can be used to add a header
+between designators that includes the active/retired status of
+the item.
 .TP
 \fBexport\fP \fI[[-]class[,class]] export_dir\fP
 Export the database to colon-separated-value files.
@@ -182,6 +184,10 @@
 With \fB-c\fP, \fB-S\fP or \fB-s\fP print a list of item id's if no
 property specified.  If property specified, print list of that
 property for every class instance.
+
+The pragma \fBshow_retired\fP can be used to print only retired items
+or to print retired and active items. The default is to print only
+active items.
 .TP
 \fBmigrate\fP
 Update a tracker's database to be compatible with the Roundup
@@ -272,6 +278,10 @@
 Lists all instances of the given class. If the properties are not
 specified, all properties are displayed. By default, the column
 widths are the width of the largest value.
+
+The pragma \fBshow_retired\fP can be used to print only retired items
+or to print retired and active items. The default is to print only
+active items.
 .TP
 \fBupdateconfig\fP \fI<filename>\fP
 This is used when updating software. It merges the \fBconfig.ini\fP
--- a/test/test_admin.py	Fri Jul 14 21:56:27 2023 -0400
+++ b/test/test_admin.py	Fri Jul 14 22:07:23 2023 -0400
@@ -1639,8 +1639,7 @@
         expected_list=sorted("1: admin\n   2: anonymous\n   3: user1\n   4: user1".split("\n"))
         self.assertEqual(out_list, expected_list)
 
-
-        # verify that active users
+        # verify that active users are shown
         self.admin=AdminTool()
         with captured_output() as (out, err):
             sys.argv=['main', '-i', self.dirname, '-P',
@@ -1651,6 +1650,26 @@
         expected="1: admin\n   2: anonymous\n   3: user1"
         self.assertEqual(out, expected)
 
+        # test display headers for retired/active
+        self.admin=AdminTool()
+        with captured_output() as (out, err):
+            sys.argv=['main', '-i', self.dirname, '-P',
+                      'display_header=yes', 'display', 'user3,user4']
+            ret = self.admin.main()
+        out = out.getvalue().strip()
+        print(out)
+        self.assertIn("[user3 (active)]\n", out)
+        self.assertIn( "[user4 (retired)]\n", out)
+
+        # test that there are no headers
+        self.admin=AdminTool()
+        with captured_output() as (out, err):
+            sys.argv=['main', '-i', self.dirname, 'display', 'user3,user4']
+            ret = self.admin.main()
+        out = out.getvalue().strip()
+        print(out)
+        self.assertNotIn("user3", out)
+        self.assertNotIn("user4", out)
 
     def testTable(self):
         ''' Note the tests will fail if you run this under pdb.

Roundup Issue Tracker: http://roundup-tracker.org/