1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 22:54:11 +00:00

Merge pull request #4902 from haiwen/last-access

update admin get users api
This commit is contained in:
Daniel Pan
2021-05-24 12:30:19 +08:00
committed by GitHub

View File

@@ -34,12 +34,11 @@ from seahub.profile.settings import CONTACT_CACHE_TIMEOUT, CONTACT_CACHE_PREFIX,
from seahub.utils import is_valid_username2, is_org_context, \ from seahub.utils import is_valid_username2, is_org_context, \
is_pro_version, normalize_cache_key, is_valid_email, \ is_pro_version, normalize_cache_key, is_valid_email, \
IS_EMAIL_CONFIGURED, send_html_email, get_site_name, \ IS_EMAIL_CONFIGURED, send_html_email, get_site_name, \
gen_shared_link, gen_shared_upload_link, \ gen_shared_link, gen_shared_upload_link
get_file_audit_events, get_file_update_events
from seahub.utils.file_size import get_file_size_unit from seahub.utils.file_size import get_file_size_unit
from seahub.utils.timeutils import timestamp_to_isoformat_timestr, \ from seahub.utils.timeutils import timestamp_to_isoformat_timestr, \
datetime_to_isoformat_timestr, utc_to_local datetime_to_isoformat_timestr
from seahub.utils.user_permissions import get_user_role from seahub.utils.user_permissions import get_user_role
from seahub.utils.repo import normalize_repo_status_code from seahub.utils.repo import normalize_repo_status_code
from seahub.constants import DEFAULT_ADMIN from seahub.constants import DEFAULT_ADMIN
@@ -64,21 +63,10 @@ json_content_type = 'application/json; charset=utf-8'
def get_user_last_access_time(email, last_login_time): def get_user_last_access_time(email, last_login_time):
device_last_access = '' device_last_access = ''
audit_last_access = ''
update_last_access = ''
devices = TokenV2.objects.filter(user=email).order_by('-last_accessed') devices = TokenV2.objects.filter(user=email).order_by('-last_accessed')
if devices: if devices:
device_last_access = devices[0].last_accessed device_last_access = devices[0].last_accessed
audit_events = get_file_audit_events(email, 0, None, 0, 1) or []
if audit_events:
audit_last_access = audit_events[0].timestamp
update_events = get_file_update_events(email, 0, None, 0, 1) or []
if update_events:
update_last_access = update_events[0].timestamp
last_access_time_list = [] last_access_time_list = []
if last_login_time: if last_login_time:
last_access_time_list.append(last_login_time) last_access_time_list.append(last_login_time)
@@ -86,12 +74,6 @@ def get_user_last_access_time(email, last_login_time):
if device_last_access: if device_last_access:
last_access_time_list.append(device_last_access) last_access_time_list.append(device_last_access)
if audit_last_access:
last_access_time_list.append(utc_to_local(audit_last_access))
if update_last_access:
last_access_time_list.append(utc_to_local(update_last_access))
if not last_access_time_list: if not last_access_time_list:
return '' return ''
else: else: