{% endif %}value="{{ user.username }}">{{ user|username }} ({{ user.count }})</option>
{% endfor %}
</select>
+
+<select name="active-users" style="display:none;">
+ {% for user in active_users %}
+ <option value="{{ user.username }}">{{ user|username }}</option>
+ {% endfor %}
+</select>
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from re import split
-from django.db.models import Q, Count
+from django.db.models import Q, Count, F, Max
from django import template
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
count=Count('chunk')).filter(count__gt=0).order_by(
'-count', 'last_name', 'first_name'),
"other_users": User.objects.annotate(
- count=Count('chunk')).filter(count=0).order_by(
- 'last_name', 'first_name'),
- }
+ count=Count('chunk')).filter(count=0).annotate(m=Max('chunkchange__created_at')).order_by(F('m').desc(nulls_last=True), 'last_name', 'first_name'),
+ "active_users": User.objects.annotate(m=Max('chunkchange__created_at')).order_by(F('m').desc(nulls_last=True), 'last_name', 'first_name'),
+ }
new_context.update({
"filters": True,
var user_callback = get_callback('user');
var users = [
- get_items("user", user_callback),
- {sep: '----'},
- get_items("other-user", user_callback)
+ get_items("active-users", user_callback)
];
var current_user_items = user_items = {};
var i = 0;