From 03ebe21f5f1d4faba7d5403f08dfe0f0a1353204 Mon Sep 17 00:00:00 2001 From: Jpadilla1 Date: Tue, 29 Apr 2014 23:43:39 -0400 Subject: [PATCH] fixed online users in rooms, added session_expire_at_browser_close setting --- apps/chats/views.py | 7 ++++--- chatrooms/settings.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/chats/views.py b/apps/chats/views.py index 064dc53..bd93bc4 100644 --- a/apps/chats/views.py +++ b/apps/chats/views.py @@ -59,9 +59,10 @@ def get_context_data(self, **kwargs): context['room_messages'] = Message.objects.filter(room=context['room']) if context['room_messages'].count() > 0: context['room_message_last'] = context['room_messages'].last().id - users = User.objects.filter( - last_login__gt=self.request.user.last_logged_out, - is_active__exact=1, ).order_by('-last_login') + users = ChatRoom.objects.get( + slug=self.kwargs['slug']).members.filter( + last_login__gt=self.request.user.last_logged_out, + is_active__exact=1, ).order_by('-last_login') context['online_users'] = users return context diff --git a/chatrooms/settings.py b/chatrooms/settings.py index 21c4fc2..76e74c9 100644 --- a/chatrooms/settings.py +++ b/chatrooms/settings.py @@ -150,3 +150,5 @@ # Allow all host headers ALLOWED_HOSTS = ['*'] + +SESSION_EXPIRE_AT_BROWSER_CLOSE = True