2017-12-04 08:41:00 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
from django.core.cache import cache
|
2018-12-19 02:49:30 +00:00
|
|
|
|
|
|
|
from assets.models import Asset, SystemUser
|
|
|
|
from users.models import User
|
2017-12-12 04:19:45 +00:00
|
|
|
|
|
|
|
from .const import USERS_CACHE_KEY, ASSETS_CACHE_KEY, SYSTEM_USER_CACHE_KEY
|
|
|
|
|
|
|
|
|
|
|
|
def get_session_asset_list():
|
2018-12-19 02:49:30 +00:00
|
|
|
return Asset.objects.values_list('hostname', flat=True)
|
2017-12-12 04:19:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_session_user_list():
|
2018-12-19 02:49:30 +00:00
|
|
|
return User.objects.values_list('username', flat=True)
|
2017-12-12 04:19:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_session_system_user_list():
|
2018-12-19 02:49:30 +00:00
|
|
|
return SystemUser.objects.values_list('username', flat=True)
|
2017-12-12 04:19:45 +00:00
|
|
|
|
2017-12-04 08:41:00 +00:00
|
|
|
|
|
|
|
def get_user_list_from_cache():
|
|
|
|
return cache.get(USERS_CACHE_KEY)
|
|
|
|
|
|
|
|
|
|
|
|
def get_asset_list_from_cache():
|
|
|
|
return cache.get(ASSETS_CACHE_KEY)
|
|
|
|
|
|
|
|
|
|
|
|
def get_system_user_list_from_cache():
|
|
|
|
return cache.get(SYSTEM_USER_CACHE_KEY)
|
|
|
|
|
|
|
|
|
|
|
|
|