1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-24 14:12:03 +00:00
seahub/profile/utils.py

15 lines
502 B
Python

from django.core.cache import cache
from models import Profile
from settings import NICKNAME_CACHE_PREFIX, NICKNAME_CACHE_TIMEOUT
from seahub.shortcuts import get_first_object_or_none
def refresh_cache(user):
"""
Function to be called when change user nickname.
"""
profile = get_first_object_or_none(Profile.objects.filter(user=user))
nickname = profile.nickname if profile else user.split('@')[0]
cache.set(NICKNAME_CACHE_PREFIX+user, nickname, NICKNAME_CACHE_TIMEOUT)