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
def current_user(): from offline.middleware import threadlocals return threadlocals.get_current_user()