Skip to content

Commit

Permalink
Fix F811 redefinition of unused 'label' in ContestSubmissionInline
Browse files Browse the repository at this point in the history
  • Loading branch information
hieplpvip committed Sep 14, 2023
1 parent 7f19d38 commit 7067d26
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions judge/admin/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,22 @@ def formfield_for_dbfield(self, db_field, **kwargs):
contest__problems=submission.problem) \
.only('id', 'contest__name', 'virtual')

def label(obj):
def _label(obj):
if obj.spectate:
return gettext('%s (spectating)') % obj.contest.name
if obj.virtual:
return gettext('%s (virtual %d)') % (obj.contest.name, obj.virtual)
return obj.contest.name
label = _label
elif db_field.name == 'problem':
kwargs['queryset'] = ContestProblem.objects.filter(problem=submission.problem) \
.only('id', 'problem__name', 'contest__name')

def label(obj):
def _label(obj):
return pgettext('contest problem', '%(problem)s in %(contest)s') % {
'problem': obj.problem.name, 'contest': obj.contest.name,
}
label = _label
field = super(ContestSubmissionInline, self).formfield_for_dbfield(db_field, **kwargs)
if label is not None:
field.label_from_instance = label
Expand Down

0 comments on commit 7067d26

Please sign in to comment.