order thinks on the front page by time of last edit
instead of time of creation
This commit is contained in:
parent
dcdb3d87be
commit
94643dc2c7
5 changed files with 37 additions and 4 deletions
|
@ -4,6 +4,7 @@ from django.http import HttpResponse, JsonResponse
|
|||
from django.shortcuts import render, redirect
|
||||
from django.views import generic
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import now
|
||||
from itertools import groupby
|
||||
import json
|
||||
import mimetypes
|
||||
|
@ -41,7 +42,7 @@ class IndexView(ThinkMixin, generic.ListView):
|
|||
|
||||
context['templates'] = Think.objects.filter(is_template=True)
|
||||
|
||||
context['recent_thinks'] = Think.objects.filter(is_template=False).order_by('-creation_time')[:3]
|
||||
context['recent_thinks'] = Think.objects.all().order_by('-last_edited', '-creation_time')[:3]
|
||||
|
||||
context['thinks'] = sorted(Think.objects.filter(is_template=False), key=lambda t: (t.category if t.category else '', -t.creation_time.timestamp()))
|
||||
|
||||
|
@ -100,6 +101,9 @@ class ThinkView(ThinkMixin, generic.DetailView):
|
|||
|
||||
think = self.object
|
||||
|
||||
think.last_edited = now()
|
||||
think.save(update_fields=('last_edited',))
|
||||
|
||||
root = think.root
|
||||
|
||||
strpath = self.request.GET.get('path')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue