diff --git a/ca_manager/lookup.py b/ca_manager/lookup.py index 92fa86d..b44f77a 100755 --- a/ca_manager/lookup.py +++ b/ca_manager/lookup.py @@ -144,3 +144,10 @@ def __iter__(self): Iterate over all certificate request in OUTPUT_PATH """ return Certificate.select().iterator() + + def latest(self, n=5): + """ + Get the latest n certificates; default n=5 + """ + + return Certificate.select().order_by(-Certificate.date_issued).limit(n) diff --git a/ca_manager/shell.py b/ca_manager/shell.py index a12ff40..774a861 100755 --- a/ca_manager/shell.py +++ b/ca_manager/shell.py @@ -23,6 +23,9 @@ class CAManagerShell(cmd.Cmd): def __init__(self, ca_manager): super(CAManagerShell, self).__init__() self.ca_manager = ca_manager + self.intro += "Latest certs signed:\n\n" + for cert in self.ca_manager.certificate.latest(): + self.intro += "%s\n" % (cert,) def do_ls_cas(self, l): 'List the available certification authorities: LS_CA'