Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprecated method in expire_accounts.py #10173

Merged
merged 4 commits into from
Dec 22, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/expire_accounts.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from datetime import datetime
from datetime import UTC
mekarpeles marked this conversation as resolved.
Show resolved Hide resolved

import web


def delete_old_links():
for doc in web.ctx.site.store.values(type="account-link"):
expiry_date = datetime.strptime(doc["expires_on"], "%Y-%m-%dT%H:%M:%S.%f")
now = datetime.utcnow()
# Make expiry_date timezone-aware:
expiry_date = expiry_date.replace(tzinfo=UTC)
now = datetime.now(UTC)
key = doc["_key"]
if expiry_date > now:
print("Deleting link %s" % (key))
Expand Down
Loading