|
|
|
|
@ -1,12 +1,15 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
from __future__ import absolute_import |
|
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta |
|
|
|
|
import traceback |
|
|
|
|
|
|
|
|
|
from django.core.mail import mail_admins |
|
|
|
|
from datetime import datetime, timedelta |
|
|
|
|
|
|
|
|
|
from celery import shared_task |
|
|
|
|
|
|
|
|
|
from django.utils import timezone |
|
|
|
|
from django.core.mail import mail_admins |
|
|
|
|
|
|
|
|
|
from myauth.models import DokUser, ConfirmEmail |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +41,17 @@ def check_license(): |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_not_activated_users(): |
|
|
|
|
profiles = UserProfile.objects.filter(active=False, confirmed=False) |
|
|
|
|
users = DokUser.objects.filter(profile__active=False, profile__confirmed=False) |
|
|
|
|
confirms = ConfirmEmail.objects.filter(is_confirmed=False) |
|
|
|
|
@shared_task |
|
|
|
|
def delete_not_activated_users(): |
|
|
|
|
now = timezone.now() |
|
|
|
|
users = DokUser.objects.filter(profile__active=False, profile__confirmed=False).\ |
|
|
|
|
filter(profile__created_at__lte=now - timedelta(5)) |
|
|
|
|
if users: |
|
|
|
|
for user in users: |
|
|
|
|
profile = user.profile |
|
|
|
|
confirm = ConfirmEmail.objects.filter(user=user, is_confirmed=False) |
|
|
|
|
if profile: |
|
|
|
|
profile.delete() |
|
|
|
|
if confirm: |
|
|
|
|
confirm.delete() |
|
|
|
|
user.delete() |
|
|
|
|
|