From f05e88551751f12277dea7d88755f2b0ed58bf9f Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 23 Apr 2022 22:42:46 +0300 Subject: workaround security update on distsortreversed Due to Django security update CVE-2021-45116 which removed the capability of resolving a method in a template when called dictsortreversed --- core/views/logbooks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'core/views/logbooks.py') diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 9695d54..6160de4 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -32,6 +32,9 @@ todo = '''Fix the get_person_chronology() display bug. ''' def notablepersons(request): + def notabilitykey(person): + return person.notability() + persons = Person.objects.all() # From what I can tell, "persons" seems to be the table rows, while "pcols" is the table columns. - AC 16 Feb 09 pcols = [ ] @@ -41,9 +44,11 @@ def notablepersons(request): pcols.append(persons[i * nc: (i + 1) * nc]) notablepersons = [] - for person in Person.objects.all(): - if person.bisnotable(): - notablepersons.append(person) +# Needed recoding because of Django CVE-2021-45116 + for person in persons: + if person.bisnotable(): + notablepersons.append(person) + notablepersons.sort(key=notabilitykey, reverse=True) return render(request,'notablepersons.html', {'persons': persons, 'pcols':pcols, 'notablepersons':notablepersons}) -- cgit v1.2.3