示例#1
0
文件: sites.py 项目: D3f0/protopy
 def user(self):
     #TODO Controlar el error si no esta el middleware
     from offline.middleware import threadlocals
     user = threadlocals.get_current_user()
     data = {
             'class': 'AnonymousUser',
             'username': user.username,
             'is_staff': user.is_staff,
             'is_active': user.is_active,
             'is_superuser': user.is_superuser
             }
     if not user.is_anonymous():
         data.update({
             'class': 'User',
             'first_name': user.first_name,
             'last_name': user.last_name,
             'email': user.email,
             'password': user.password,
             })
     return data
示例#2
0
def current_user():
    from offline.middleware import threadlocals
    return threadlocals.get_current_user()