浏览代码

[fix] check if user exists while setting last active date

version-14
Saurabh 8 年前
committed by Nabin Hait
父节点
当前提交
68186a4943
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. +10
    -4
      frappe/commands/site.py

+ 10
- 4
frappe/commands/site.py 查看文件

@@ -460,10 +460,12 @@ def clear_limits(context, site, limits):
if not limits:
update_site_config('limits', 'None', validate=False)

@click.command('set-last-active')
@click.command('set-last-active-for-user')
@click.option('--user', help="Setup last active date for user")
@pass_context
def set_last_active(context, user=None):
def set_last_active_for_user(context, user=None):
"Set users last active date to current datetime"

from frappe.core.doctype.user.user import get_system_users
from frappe.utils.user import set_last_active_to_now
@@ -472,7 +474,11 @@ def set_last_active(context, user=None):
with frappe.init_site(site):
frappe.connect()
if not user:
user = get_system_users(limit=1)[0]
user = get_system_users(limit=1)
if len(user) > 0:
user = user[0]
else:
return

set_last_active_to_now(user)
frappe.db.commit()
@@ -499,5 +505,5 @@ commands = [
clear_limits,
disable_user,
_use,
set_last_active,
set_last_active_for_user,
]

正在加载...
取消
保存