Skip to content

Commit

Permalink
Merge pull request Ehco1996#183 from tataki/dev
Browse files Browse the repository at this point in the history
添加用户等级到期邮件通知
  • Loading branch information
Ehco1996 authored Nov 4, 2018
2 parents 40ae849 + 24c9677 commit b8ec191
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions commands/croncmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

from apps.sspanel.models import User, PayRequest
from apps.ssserver.models import Node, NodeOnlineLog, TrafficLog, AliveIp
from django.core.mail import send_mail


def check_user_state():
'''检测用户状态,将所有账号到期的用户状态重置'''
users = User.objects.filter(level__gt=0)
expire_user = []
for user in users:
# 判断用户过期
if timezone.now() - timezone.timedelta(days=1) > \
Expand All @@ -21,9 +23,15 @@ def check_user_state():
ss_user.download_traffic = 0
ss_user.transfer_enable = settings.DEFAULT_TRAFFIC
ss_user.save()
expire_user.append(user.email)
print('time: {} user: {} level timeout '
.format(timezone.now().strftime('%Y-%m-%d'),
user.username))
if expire_user and settings.EXPIRE_EMAIL_NOTICE:
send_mail('您的{0}账号已到期'.format(settings.TITLE),
"您的{0}账号已到期,现被暂停使用。如需继续使用请前往 {1} 充值".format(settings.TITLE, settings.HOST),
settings.DEFAULT_FROM_EMAIL,
expire_user)
print('Time: {} CHECKED'.format(timezone.now()))


Expand Down
5 changes: 4 additions & 1 deletion configs/default/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@
HOST = 'http://127.0.0.1:8000/'

# 部分API接口TOKEN
TOKEN = 'youowntoken'
TOKEN = 'youowntoken'

# 是否开启用户到期邮件通知
EXPIRE_EMAIL_NOTICE = False

0 comments on commit b8ec191

Please sign in to comment.