Remove py2 unicode syntax

This commit is contained in:
int-y1 2022-05-28 23:24:01 -04:00 committed by Tudor Brindus
parent 7436f42e2f
commit 5a41535b8f
5 changed files with 6 additions and 10 deletions

View File

@ -25,7 +25,7 @@ class NavigationBarAdmin(DraggableMPTTAdmin):
self.__save_model_calls = 0
def linked_path(self, obj):
return format_html(u'<a href="{0}" target="_blank">{0}</a>', obj.path)
return format_html('<a href="{0}" target="_blank">{0}</a>', obj.path)
linked_path.short_description = _('link path')
def save_model(self, request, obj, form, change):

View File

@ -49,7 +49,7 @@ class DefaultContestFormat(BaseContestFormat):
format_data = (participation.format_data or {}).get(str(contest_problem.id))
if format_data:
return format_html(
u'<td class="{state}"><a href="{url}">{points}<div class="solving-time">{time}</div></a></td>',
'<td class="{state}"><a href="{url}">{points}<div class="solving-time">{time}</div></a></td>',
state=(('pretest-' if self.contest.run_pretests_only and contest_problem.is_pretested else '') +
self.best_solution_state(format_data['points'], contest_problem.points)),
url=reverse('contest_user_submissions',
@ -62,7 +62,7 @@ class DefaultContestFormat(BaseContestFormat):
def display_participation_result(self, participation):
return format_html(
u'<td class="user-points"><a href="{url}">{points}<div class="solving-time">{cumtime}</div></a></td>',
'<td class="user-points"><a href="{url}">{points}<div class="solving-time">{cumtime}</div></a></td>',
url=reverse('contest_all_user_submissions',
args=[self.contest.key, participation.user.user.username]),
points=floatformat(participation.score, -self.contest.points_precision),

View File

@ -6,7 +6,7 @@ from django.template.defaultfilters import floatformat
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _, gettext_lazy, ungettext
from django.utils.translation import gettext as _, gettext_lazy, ngettext
from judge.contest_format.default import DefaultContestFormat
from judge.contest_format.registry import register_contest_format
@ -128,7 +128,7 @@ class ICPCContestFormat(DefaultContestFormat):
penalty = self.config['penalty']
if penalty:
yield ungettext(
yield ngettext(
'Each submission before the first maximum score submission will incur a **penalty of %d minute**.',
'Each submission before the first maximum score submission will incur a **penalty of %d minutes**.',
penalty,

View File

@ -37,10 +37,6 @@ two_factor_validators_by_length = {
}
def fix_unicode(string, unsafe=tuple('\u202a\u202b\u202d\u202e')):
return string + (sum(k in unsafe for k in string) - string.count('\u202c')) * '\u202c'
class ProfileForm(ModelForm):
if newsletter_id is not None:
newsletter = forms.BooleanField(label=_('Subscribe to contest updates'), initial=False, required=False)

View File

@ -113,7 +113,7 @@ class QueryStringSortMixin(object):
links[current] = sort_prefix + ('' if self.order.startswith('-') else '-') + current
order = {key: '' for key in self.all_sorts}
order[current] = ' \u25BE' if self.order.startswith('-') else u' \u25B4'
order[current] = ' \u25BE' if self.order.startswith('-') else ' \u25B4'
return {'sort_links': links, 'sort_order': order}
def get_sort_paginate_context(self):