+@active_tab('unassigned')
+@never_cache
+def unassigned(request):
+ chunks = Chunk.objects.filter(user=None).order_by('book__title', 'book', 'number')
+ books = []
+ book = None
+ for chunk in chunks:
+ if chunk.book != book:
+ book = chunk.book
+ books.append(helpers.ChoiceChunks(book, [chunk]))
+ else:
+ books[-1].chunks.append(chunk)
+
+ return direct_to_template(request, 'wiki/document_list.html', extra_context={
+ 'books': books,
+ 'last_books': sorted(request.session.get("wiki_last_books", {}).items(),
+ key=lambda x: x[1]['time'], reverse=True),
+ })
+
+
+@never_cache
+def user(request, username=None):
+ if username is None:
+ if request.user.is_authenticated():
+ user = request.user
+ else:
+ raise Http404
+ else:
+ user = get_object_or_404(User, username=username)
+
+ chunks = Chunk.objects.filter(user=user).order_by('book__title', 'number')
+ books = []
+ book = None
+ for chunk in chunks:
+ if chunk.book != book:
+ book = chunk.book
+ books.append(helpers.ChoiceChunks(book, [chunk]))
+ else:
+ books[-1].chunks.append(chunk)
+
+ return direct_to_template(request, 'wiki/document_list.html', extra_context={
+ 'books': books,
+ 'last_books': sorted(request.session.get("wiki_last_books", {}).items(),
+ key=lambda x: x[1]['time'], reverse=True),
+ })
+my = login_required(active_tab('my')(user))
+
+
+@active_tab('users')
+def users(request):
+ return direct_to_template(request, 'wiki/user_list.html', extra_context={
+ 'users': User.objects.all().annotate(count=Count('document')).order_by(
+ '-count', 'last_name', 'first_name'),
+ })
+
+