Skip to content

Commit

Permalink
Remove contest editorial column if empty
Browse files Browse the repository at this point in the history
Revise editorial column fix

Fix format for checks
  • Loading branch information
kevinjycui committed May 31, 2020
1 parent eeb4f2f commit 0100326
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions judge/views/contests.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ def get_context_data(self, **kwargs):
.annotate(has_public_editorial=Sum(Case(When(solution__is_public=True, then=1),
default=0, output_field=IntegerField()))) \
.add_i18n_name(self.request.LANGUAGE_CODE)
context['contest_has_public_editorials'] = any(
problem.is_public and problem.has_public_editorial for problem in context['contest_problems']
)
return context


Expand Down
16 changes: 10 additions & 6 deletions templates/contest/contest.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ <h2 style="margin-bottom: 0.2em"><i class="fa fa-fw fa-question-circle"></i>{{ _
<th>{{ _('Points') }}</th>
<th>{{ _('AC Rate') }}</th>
<th>{{ _('Users') }}</th>
<th></th>
{% if contest_has_public_editorials %}
<th></th>
{% endif %}
</tr>
</thead>
<tbody>
Expand All @@ -106,11 +108,13 @@ <h2 style="margin-bottom: 0.2em"><i class="fa fa-fw fa-question-circle"></i>{{ _
{{ problem.user_count }}
{% endif %}
</td>
<td>
{% if problem.is_public and problem.has_public_editorial %}
<a href="{{ url('problem_editorial', problem.code) }}">{{ _('Editorial') }}</a>
{% endif %}
</td>
{% if contest_has_public_editorials %}
<td>
{% if problem.is_public and problem.has_public_editorial %}
<a href="{{ url('problem_editorial', problem.code) }}">{{ _('Editorial') }}</a>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit 0100326

Please sign in to comment.