mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +00:00
Added captcha to thirdpart
This commit is contained in:
25
thirdpart/captcha/management/commands/captcha_clean.py
Normal file
25
thirdpart/captcha/management/commands/captcha_clean.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from captcha.models import get_safe_now
|
||||
import sys
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Clean up expired captcha hashkeys."
|
||||
|
||||
def handle(self, **options):
|
||||
from captcha.models import CaptchaStore
|
||||
verbose = int(options.get('verbosity'))
|
||||
expired_keys = CaptchaStore.objects.filter(expiration__lte=get_safe_now()).count()
|
||||
if verbose >= 1:
|
||||
print "Currently %d expired hashkeys" % expired_keys
|
||||
try:
|
||||
CaptchaStore.remove_expired()
|
||||
except:
|
||||
if verbose >= 1:
|
||||
print "Unable to delete expired hashkeys."
|
||||
sys.exit(1)
|
||||
if verbose >= 1:
|
||||
if expired_keys > 0:
|
||||
print "%d expired hashkeys removed." % expired_keys
|
||||
else:
|
||||
print "No keys to remove."
|
Reference in New Issue
Block a user