From: Radek Czajka Date: Sat, 11 Dec 2021 12:29:13 +0000 (+0100) Subject: User list sorted by last activity. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/25e7ab3df1f48cf819df12c5642df6ccf3c7500e User list sorted by last activity. --- diff --git a/src/documents/templates/documents/book_list/book_list.html b/src/documents/templates/documents/book_list/book_list.html index eb4c8f5d..812ea791 100644 --- a/src/documents/templates/documents/book_list/book_list.html +++ b/src/documents/templates/documents/book_list/book_list.html @@ -115,3 +115,9 @@ {% endif %}value="{{ user.username }}">{{ user|username }} ({{ user.count }}) {% endfor %} + + diff --git a/src/documents/templatetags/book_list.py b/src/documents/templatetags/book_list.py index acd22083..bf5fbd09 100644 --- a/src/documents/templatetags/book_list.py +++ b/src/documents/templatetags/book_list.py @@ -2,7 +2,7 @@ # 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 @@ -127,9 +127,9 @@ def book_list(context, user=None): 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, diff --git a/src/redakcja/static/js/documents/book_list.js b/src/redakcja/static/js/documents/book_list.js index 9d2511d4..0f03f4a4 100644 --- a/src/redakcja/static/js/documents/book_list.js +++ b/src/redakcja/static/js/documents/book_list.js @@ -50,9 +50,7 @@ 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;