From 7e61a8f1d720fabf18bb05fab9732e4efc0b3a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 22 Apr 2011 12:25:24 +0200 Subject: [PATCH] Check expiration date instead of the expired flag (#394) --- extra/modules/quota.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extra/modules/quota.py b/extra/modules/quota.py index c7ae758..0bb38d7 100644 --- a/extra/modules/quota.py +++ b/extra/modules/quota.py @@ -16,6 +16,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA +from datetime import datetime + from quixote import get_request, get_publisher from quixote.errors import AccessError @@ -97,4 +99,11 @@ def is_locked(): return get_boolean_quota('x-asec-locked') def is_expired(): - return get_boolean_quota('x-asec-expired') + t = get_request().get_header('x-asec-expiration-date') + if not t: + return False + try: + expiration_date = datetime.strptime(t, '%Y-%m-%dT%H:%M:%S.%f') + except ValueError: + return False + return expiration_date < datetime.now()