mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-01 23:47:40 +00:00
[Update] 添加用户过期邮件提醒
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from celery import shared_task
|
||||
|
||||
from ops.celery.utils import create_or_update_celery_periodic_tasks
|
||||
from ops.celery.decorator import after_app_ready_start, register_as_period_task
|
||||
from ops.celery.decorator import after_app_ready_start
|
||||
from common.utils import get_logger
|
||||
from .models import User
|
||||
from .utils import send_password_expiration_reminder_mail
|
||||
from .utils import (
|
||||
send_password_expiration_reminder_mail, send_user_expiration_reminder_mail
|
||||
)
|
||||
|
||||
|
||||
logger = get_logger(__file__)
|
||||
@@ -43,4 +42,27 @@ def check_password_expired_periodic():
|
||||
create_or_update_celery_periodic_tasks(tasks)
|
||||
|
||||
|
||||
@shared_task
|
||||
def check_user_expired():
|
||||
users = User.objects.exclude(role=User.ROLE_APP)
|
||||
for user in users:
|
||||
if not user.is_valid:
|
||||
continue
|
||||
if not user.will_expired:
|
||||
continue
|
||||
send_user_expiration_reminder_mail(user)
|
||||
|
||||
|
||||
@shared_task
|
||||
@after_app_ready_start
|
||||
def check_user_expired_periodic():
|
||||
tasks = {
|
||||
'check_user_expired_periodic': {
|
||||
'task': check_user_expired.name,
|
||||
'interval': None,
|
||||
'crontab': '0 14 * * *',
|
||||
'enabled': True,
|
||||
}
|
||||
}
|
||||
create_or_update_celery_periodic_tasks(tasks)
|
||||
|
||||
|
Reference in New Issue
Block a user