API additions for viewing expired certs as well. Default behavior modified to show only valid certs and those which have expired less than 1 month ago.

This commit is contained in:
Kush Bavishi 2019-06-17 10:41:11 -07:00
parent 198abcfe65
commit f836c6fff6
2 changed files with 8 additions and 5 deletions

View File

@ -329,12 +329,14 @@ def render(args):
""" """
query = database.session_query(Certificate) query = database.session_query(Certificate)
time_range = args.pop("time_range") show_expired = args.pop("showExpired")
if not time_range: if show_expired != 1:
six_month_old = arrow.now()\ one_month_old = arrow.now()\
.shift(months=current_app.config.get("HIDE_EXPIRED_CERTS_AFTER_MONTHS", -6))\ .shift(months=current_app.config.get("HIDE_EXPIRED_CERTS_AFTER_MONTHS", -1))\
.format("YYYY-MM-DD") .format("YYYY-MM-DD")
query = query.filter(Certificate.not_after > six_month_old) query = query.filter(Certificate.not_after > one_month_old)
time_range = args.pop("time_range")
destination_id = args.pop("destination_id") destination_id = args.pop("destination_id")
notification_id = args.pop("notification_id", None) notification_id = args.pop("notification_id", None)

View File

@ -347,6 +347,7 @@ class CertificatesList(AuthenticatedResource):
) )
parser.add_argument("creator", type=str, location="args") parser.add_argument("creator", type=str, location="args")
parser.add_argument("show", type=str, location="args") parser.add_argument("show", type=str, location="args")
parser.add_argument("showExpired", type=int, location="args")
args = parser.parse_args() args = parser.parse_args()
args["user"] = g.user args["user"] = g.user