Skip to content

Commit

Permalink
core&ui: fix record display (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy authored Nov 30, 2023
1 parent 323f6b7 commit e0db6c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/hydrooj/src/handler/contest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ export class ContestProblemListHandler extends ContestDetailBaseHandler {
await record.getMulti(domainId, { contest: tid, uid: this.user._id })
.sort({ _id: -1 }).toArray(),
]);
if (!this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
this.response.body.rdocs = this.response.body.rdocs.map((rdoc) => contest.applyProjection(this.tdoc, rdoc, this.user));
for (const psdoc of psdocs) {
this.response.body.rdict[psdoc.rid] = contest.applyProjection(this.tdoc, this.response.body.rdict[psdoc.rid], this.user);
}
}
this.response.body.canViewRecord = true;
} else {
for (const i of psdocs) this.response.body.rdict[i.rid] = { _id: i.rid };
Expand Down
2 changes: 2 additions & 0 deletions packages/ui-default/templates/components/record.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
href="{{ url('record_detail', rid=rdoc[rid_key], domainId=rdoc.domainId) if allDomain else url('record_detail', rid=rdoc[rid_key]) }}"
class="record-status--text {{ model.builtin.STATUS_CODES[rdoc.status] }}"
>
{% if typeof(rdoc['score']) == 'number' %}
<span style="color: {{ utils.status.getScoreColor(rdoc.score|default(0)) }}">{{ rdoc.score|default(0) }}</span>
{% endif %}
{{ model.builtin.STATUS_SHORT_TEXTS[rdoc.status] if short else model.builtin.STATUS_TEXTS[rdoc.status] }}
</a>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/ui-default/templates/record_detail_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<div class="section__header">
<h1 class="section__title">
<span class="icon record-status--icon {{ model.builtin.STATUS_CODES[rdoc['status']] }}"></span>
{% if typeof(rdoc['score']) == 'number' %}
<span style="color: {{ utils.status.getScoreColor(rdoc.score|default(0)) }}">{{ rdoc.score|default(0) }}</span>
{% endif %}
<span class="record-status--text {{ model.builtin.STATUS_CODES[rdoc['status']] }}">
{{ model.builtin.STATUS_TEXTS[rdoc['status']] }}
</span>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-default/templates/record_main_tr.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
{% endif %}
</a>
</td>
<td class="col--time">{% if [STATUS.STATUS_TIME_LIMIT_EXCEEDED, STATUS.STATUS_MEMORY_LIMIT_EXCEEDED, STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED].includes(rdoc['status']) %}&ge;{% endif %}{{ rdoc.time|round|int }}ms</td>
<td class="col--memory">{% if [STATUS.STATUS_TIME_LIMIT_EXCEEDED, STATUS.STATUS_MEMORY_LIMIT_EXCEEDED, STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED].includes(rdoc['status']) %}&ge;{% endif %}{{ size(rdoc.memory, 1024) }}</td>
<td class="col--time">{% if rdoc['time'] %}{% if [STATUS.STATUS_TIME_LIMIT_EXCEEDED, STATUS.STATUS_MEMORY_LIMIT_EXCEEDED, STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED].includes(rdoc['status']) %}&ge;{% endif %}{{ rdoc.time|round|int }}ms{% else %}-{% endif %}</td>
<td class="col--memory">{% if rdoc['memory'] %}{% if [STATUS.STATUS_TIME_LIMIT_EXCEEDED, STATUS.STATUS_MEMORY_LIMIT_EXCEEDED, STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED].includes(rdoc['status']) %}&ge;{% endif %}{{ size(rdoc.memory, 1024) }}{% else %}-{% endif %}</td>
<td class="col--lang">{{ model.setting.langs[rdoc['lang']].display }}</td>
<td class="col--submit-at">{{ datetimeSpan(rdoc['_id'])|safe }}</td>
</tr>

0 comments on commit e0db6c6

Please sign in to comment.