Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
53f0b2e9
Commit
53f0b2e9
authored
Mar 04, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 增加清理登陆日志的任务
parent
de79e362
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
tasks.py
apps/users/tasks.py
+17
-2
README.md
docs/README.md
+5
-0
No files found.
apps/users/tasks.py
View file @
53f0b2e9
# -*- 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
from
.models
import
User
from
ops.celery.decorator
import
after_app_ready_start
,
register_as_period_task
from
common.utils
import
get_logger
from
.models
import
User
,
LoginLog
from
.utils
import
write_login_log
,
send_password_expiration_reminder_mail
...
...
@@ -43,3 +46,15 @@ def check_password_expired_periodic():
}
}
create_or_update_celery_periodic_tasks
(
tasks
)
@register_as_period_task
(
interval
=
3600
*
24
)
@shared_task
def
clean_login_log_period
():
now
=
timezone
.
now
()
try
:
days
=
int
(
settings
.
LOGIN_LOG_KEEP_DAYS
)
except
ValueError
:
days
=
90
expired_day
=
now
-
datetime
.
timedelta
(
days
=
days
)
LoginLog
.
objects
.
filter
(
datetime__lt
=
expired_day
)
.
delete
()
docs/README.md
0 → 100644
View file @
53f0b2e9
## 说明
文档已移动到docs分支,该目录中不是最新文档, 请提交到docs分支
## 访问在线文档
[
访问
](
https://docs.jumpserver.org
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment