membershipworks: Handle case where scrape task has never been run in admin action

This commit is contained in:
Adam Goldsmith 2023-12-22 13:37:19 -05:00
parent 97bcc1df6d
commit 8d78868e88

View File

@ -32,7 +32,10 @@ class BaseMembershipWorksAdmin(DjangoObjectActions, ReadOnlyAdmin):
.order_by("started")
.last()
)
tool["label"] = f"Refresh Data [Last Run {naturaltime(last_run.started)}]"
last_run_time = (
naturaltime(last_run.started) if last_run is not None else "Never"
)
tool["label"] = f"Refresh Data [Last Run {last_run_time}]"
return tool
@action