7
7
from django .db .models import Count , F , Q
8
8
from django .http import HttpResponse , JsonResponse
9
9
from django .utils import timezone
10
+ from django .utils .html import conditional_escape , escape
10
11
from django .utils .translation import gettext as _ , gettext_lazy , ngettext , ngettext_lazy
11
12
from django .views .generic .base import TemplateView , View
12
13
from django .views .generic .edit import FormView
@@ -151,6 +152,7 @@ def get_table(self):
151
152
count = adj .feedback_count
152
153
feedback_data .append ({
153
154
'text' : ngettext ("%(count)d feedback" , "%(count)d feedbacks" , count ) % {'count' : count },
155
+ 'sort' : count ,
154
156
'link' : reverse_tournament ('adjfeedback-view-on-adjudicator' , self .tournament , kwargs = {'pk' : adj .id }),
155
157
})
156
158
table .add_column ({'key' : 'feedbacks' , 'title' : _ ("Feedbacks" )}, feedback_data )
@@ -175,6 +177,7 @@ def get_tables(self):
175
177
count = team .feedback_count
176
178
team_feedback_data .append ({
177
179
'text' : ngettext ("%(count)d feedback" , "%(count)d feedbacks" , count ) % {'count' : count },
180
+ 'sort' : count ,
178
181
'link' : reverse_tournament ('adjfeedback-view-from-team' ,
179
182
tournament ,
180
183
kwargs = {'pk' : team .id }),
@@ -190,6 +193,7 @@ def get_tables(self):
190
193
count = adj .feedback_count
191
194
adj_feedback_data .append ({
192
195
'text' : ngettext ("%(count)d feedback" , "%(count)d feedbacks" , count ) % {'count' : count },
196
+ 'sort' : count ,
193
197
'link' : reverse_tournament ('adjfeedback-view-from-adjudicator' ,
194
198
tournament ,
195
199
kwargs = {'pk' : adj .id }),
@@ -361,7 +365,7 @@ def get_tables(self):
361
365
use_code_names = use_team_code_names_data_entry (self .tournament , self .tabroom )
362
366
teams_table = TabbycatTableBuilder (view = self , sort_key = "team" , title = _ ("A Team" ))
363
367
add_link_data = [{
364
- 'text' : team_name_for_data_entry (team , use_code_names ),
368
+ 'text' : conditional_escape ( team_name_for_data_entry (team , use_code_names ) ),
365
369
'link' : self .get_from_team_link (team ),
366
370
} for team in tournament .team_set .all ()]
367
371
header = {'key' : 'team' , 'title' : _ ("Team" )}
@@ -372,13 +376,13 @@ def get_tables(self):
372
376
'key' : 'institution' ,
373
377
'icon' : 'home' ,
374
378
'tooltip' : _ ("Institution" ),
375
- }, [team .institution .code if team .institution else TabbycatTableBuilder .BLANK_TEXT for team in tournament .team_set .all ()])
379
+ }, [escape ( team .institution .code ) if team .institution else TabbycatTableBuilder .BLANK_TEXT for team in tournament .team_set .all ()])
376
380
377
381
adjs_table = TabbycatTableBuilder (view = self , sort_key = "adjudicator" , title = _ ("An Adjudicator" ))
378
382
adjudicators = tournament .adjudicator_set .all ()
379
383
380
384
add_link_data = [{
381
- 'text' : adj .get_public_name (tournament ),
385
+ 'text' : escape ( adj .get_public_name (tournament ) ),
382
386
'link' : self .get_from_adj_link (adj ),
383
387
} for adj in adjudicators ]
384
388
header = {'key' : 'adjudicator' , 'title' : _ ("Adjudicator" )}
@@ -389,7 +393,7 @@ def get_tables(self):
389
393
'key' : 'institution' ,
390
394
'icon' : 'home' ,
391
395
'tooltip' : _ ("Institution" ),
392
- }, [adj .institution .code if adj .institution else TabbycatTableBuilder .BLANK_TEXT for adj in adjudicators ])
396
+ }, [escape ( adj .institution .code ) if adj .institution else TabbycatTableBuilder .BLANK_TEXT for adj in adjudicators ])
393
397
394
398
return [teams_table , adjs_table ]
395
399
0 commit comments