mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #1531 from modoboa/fix/active_users
Display only one line per user.
This commit is contained in:
@@ -20,6 +20,7 @@ from django.utils.encoding import smart_text
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import get_language, ugettext as _
|
||||
|
||||
from .. import models
|
||||
from .. import signals
|
||||
|
||||
register = template.Library()
|
||||
@@ -185,8 +186,6 @@ class ConnectedUsers(template.Node):
|
||||
self.varname = varname
|
||||
|
||||
def render(self, context):
|
||||
from modoboa.core.models import User
|
||||
|
||||
sessions = Session.objects.filter(expire_date__gte=timezone.now())
|
||||
uid_list = []
|
||||
# Build a list of user ids from that query
|
||||
@@ -197,12 +196,8 @@ class ConnectedUsers(template.Node):
|
||||
uid_list.append(uid)
|
||||
|
||||
# Query all logged in users based on id list
|
||||
context[self.varname] = []
|
||||
for uid in uid_list:
|
||||
try:
|
||||
context[self.varname].append(User.objects.get(pk=uid))
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
context[self.varname] = (
|
||||
models.User.objects.filter(pk__in=uid_list).distinct())
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user