2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

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
This commit is contained in:
Philip Sargent 2022-04-23 22:42:46 +03:00
parent 9ead6b00f9
commit f05e885517
3 changed files with 19 additions and 7 deletions

1
.gitignore vendored
View File

@ -126,3 +126,4 @@ media/jslib/openlayers/Lang/vi.js
media/jslib/openlayers/Lang/zh-CN.js media/jslib/openlayers/Lang/zh-CN.js
media/jslib/openlayers/Lang/zh-TW.js media/jslib/openlayers/Lang/zh-TW.js
_test_response.html _test_response.html
_deploy/wsl/localsettingsWSL.py.bak

View File

@ -32,6 +32,9 @@ todo = '''Fix the get_person_chronology() display bug.
''' '''
def notablepersons(request): def notablepersons(request):
def notabilitykey(person):
return person.notability()
persons = Person.objects.all() 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 # From what I can tell, "persons" seems to be the table rows, while "pcols" is the table columns. - AC 16 Feb 09
pcols = [ ] pcols = [ ]
@ -41,9 +44,11 @@ def notablepersons(request):
pcols.append(persons[i * nc: (i + 1) * nc]) pcols.append(persons[i * nc: (i + 1) * nc])
notablepersons = [] notablepersons = []
for person in Person.objects.all(): # Needed recoding because of Django CVE-2021-45116
if person.bisnotable(): for person in persons:
notablepersons.append(person) if person.bisnotable():
notablepersons.append(person)
notablepersons.sort(key=notabilitykey, reverse=True)
return render(request,'notablepersons.html', {'persons': persons, 'pcols':pcols, 'notablepersons':notablepersons}) return render(request,'notablepersons.html', {'persons': persons, 'pcols':pcols, 'notablepersons':notablepersons})

View File

@ -2,21 +2,27 @@
{% block title %}Person Index{% endblock %} {% block title %}Person Index{% endblock %}
{% block content %} {% block content %}
<!-- notablepersons.html - this text visible because this template has been included -->
<h2>Notably Recent Expoers</h2> <h2>Notably Recent Expoers</h2>
<p>This table is just for fun. And it's apparently not working (boo) in April 2022.
<table class="searchable"> <table class="searchable">
<tr><th>Person</th><th>First</th><th>Last</th><th>Recency</th></tr> <tr><th>Person</th><th>First</th><th>Last</th><th>Recency</th></tr>
{% for person in notablepersons|dictsortreversed:"notability" %} {% for person in notablepersons %}
<tr> <tr>
<td><a href="{{ person.get_absolute_url }}">{{person|safe}}</a></td> <td><a href="{{ person.get_absolute_url }}">{{person|safe}}</a></td>
<td><a href="{{ person.first.get_absolute_url }}">{{ person.first.expedition.year }}</a></td> <td><a href="{{ person.first.get_absolute_url }}">{{ person.first.expedition.year }}</a></td>
<td><a href="{{ person.last.get_absolute_url }}">{{ person.last.expedition.year }}</a></td> <td><a href="{{ person.last.get_absolute_url }}">{{ person.last.expedition.year }}</a></td>
<td style="text-align:right">{{person.notability|floatformat:2}}</td> <td style="text-align:right">{{person.notability|floatformat:2}}</td>
</tr> </tr>
{% endfor %} {% empty %}
<td>&nbsp;No one is notable&nbsp;</td><td> &nbsp; </td><td> &nbsp;</td><td> &nbsp;</td>
{% endfor %}
</table> </table>
<p>This is based purely on attendance, not on activities, surveying or usefulness of any kind. But as Woody Allen said: "90% of success is just turning up". This is mostly people who have been within the past three years, with an additional bias for number of attendances since 1976. The metric is just a geometric "recency" (1/2 for attending last year, 1/3 for the year before, etc., added up.) The display cuttoff is 1/3 so if you came just once, three years ago, you are on the list. <p>This is based purely on attendance, not on activities, surveying or usefulness of any kind.
But as Woody Allen said: "90% of success is just turning up".
This is mostly people who have been within the past three years, with an additional bias for number of attendances since 1976.
The metric is just a geometric "recency" (1/2 for attending last year, 1/3 for the year before, etc., added up.)
The display cuttoff is 1/3 so if you came just once, three years ago, you are on the list.
<h2>All expoers</h2> <h2>All expoers</h2>