core&ui: fix bugs (#672)

Co-authored-by: panda <panda_dtdyy@outlook.com>
pull/675/head^2
Milmon 11 months ago committed by GitHub
parent afbf3b6174
commit f305cbfc60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -162,6 +162,7 @@ export class ContestDetailBaseHandler extends Handler {
checker: () => contest.canShowScoreboard.call(this, this.tdoc, true), checker: () => contest.canShowScoreboard.call(this, this.tdoc, true),
}, },
{ {
name: 'problem_detail',
displayName: `${String.fromCharCode(65 + this.tdoc.pids.indexOf(pdoc.docId))}. ${pdoc.title}`, displayName: `${String.fromCharCode(65 + this.tdoc.pids.indexOf(pdoc.docId))}. ${pdoc.title}`,
args: { query: { tid }, pid: pdoc.docId, prefix: 'contest_detail_problem' }, args: { query: { tid }, pid: pdoc.docId, prefix: 'contest_detail_problem' },
checker: () => 'pdoc' in this, checker: () => 'pdoc' in this,

@ -344,6 +344,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid); const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!ddoc || !pdoc) throw new ProblemNotFoundError(this.pdoc.reference.domainId, this.pdoc.reference.pid); if (!ddoc || !pdoc) throw new ProblemNotFoundError(this.pdoc.reference.domainId, this.pdoc.reference.pid);
this.pdoc.config = pdoc.config; this.pdoc.config = pdoc.config;
this.pdoc.additional_file = pdoc.additional_file;
} }
if (typeof this.pdoc.config !== 'string') { if (typeof this.pdoc.config !== 'string') {
let baseLangs; let baseLangs;
@ -384,7 +385,8 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
const fields = ['attend', 'startAt']; const fields = ['attend', 'startAt'];
if (this.tdoc.duration) fields.push('endAt'); if (this.tdoc.duration) fields.push('endAt');
if (contest.canShowSelfRecord.call(this, this.tdoc, true)) fields.push('detail'); if (contest.canShowSelfRecord.call(this, this.tdoc, true)) fields.push('detail');
this.response.body.tsdoc = pick(this.tsdoc, fields); this.tsdoc = pick(this.tsdoc, fields);
this.response.body.tsdoc = this.tsdoc;
} }
this.response.template = 'problem_detail.html'; this.response.template = 'problem_detail.html';
this.UiContext.extraTitleContent = this.pdoc.title; this.UiContext.extraTitleContent = this.pdoc.title;
@ -502,6 +504,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
pdoc: this.pdoc, pdoc: this.pdoc,
udoc: this.udoc, udoc: this.udoc,
tdoc: this.tdoc, tdoc: this.tdoc,
tsdoc: this.tsdoc,
title: this.pdoc.title, title: this.pdoc.title,
page_name: this.tdoc page_name: this.tdoc
? this.tdoc.rule === 'homework' ? this.tdoc.rule === 'homework'

@ -13,6 +13,9 @@
{% include "partials/problem_sidebar.html" %} {% include "partials/problem_sidebar.html" %}
{% elif vnode.type == model.document.TYPE_CONTEST %} {% elif vnode.type == model.document.TYPE_CONTEST %}
{% set tdoc = vnode %} {% set tdoc = vnode %}
{%- if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) -%}
{% set tsdoc = { attend: tdoc.attend } %}
{%- endif -%}
{% set owner_udoc = udict[vnode.owner] %} {% set owner_udoc = udict[vnode.owner] %}
{% include "partials/contest_sidebar.html" %} {% include "partials/contest_sidebar.html" %}
{% else %} {% else %}

@ -6,7 +6,8 @@
<blockquote class="note"> <blockquote class="note">
<p>{{ _('This is a copy of another problem.') }}</p> <p>{{ _('This is a copy of another problem.') }}</p>
</blockquote> </blockquote>
{% elif _files.length %} {% endif %}
{% if _files.length %}
<table class="data-table {{ filetype }}-table"> <table class="data-table {{ filetype }}-table">
<colgroup> <colgroup>
{% if not sidebar %}<col class="col--checkbox">{% endif %} {% if not sidebar %}<col class="col--checkbox">{% endif %}
@ -53,7 +54,7 @@
{%- endfor -%} {%- endfor -%}
</tbody> </tbody>
</table> </table>
{% else %} {% elif not reference %}
{{ nothing.render('No {0} at current.', compact=sidebar, args=[_(filetype)]) }} {{ nothing.render('No {0} at current.', compact=sidebar, args=[_(filetype)]) }}
{% endif %} {% endif %}
</div> </div>

@ -31,7 +31,7 @@
<div class="section__header"> <div class="section__header">
<h1 class="section__title">{{ _('Files') }}</h1> <h1 class="section__title">{{ _('Files') }}</h1>
<div class="section__tools"> <div class="section__tools">
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} {% if (handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM)) and not reference %}
<button class="primary rounded button" name="create_file">{{ _('Create File') }}</button> <button class="primary rounded button" name="create_file">{{ _('Create File') }}</button>
<button class="primary rounded button" name="upload_file">{{ _('Upload File') }}</button> <button class="primary rounded button" name="upload_file">{{ _('Upload File') }}</button>
{% endif %} {% endif %}
@ -41,7 +41,7 @@
{% include "partials/problem_files.html" %} {% include "partials/problem_files.html" %}
<div class="section__body"> <div class="section__body">
<button class="rounded button" name="download_selected_file">{{ _('Download Selected') }}</button> <button class="rounded button" name="download_selected_file">{{ _('Download Selected') }}</button>
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} {% if (handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM)) and not reference %}
<button class="rounded button" name="remove_selected_file">{{ _('Remove Selected') }}</button> <button class="rounded button" name="remove_selected_file">{{ _('Remove Selected') }}</button>
{% endif %} {% endif %}
</div> </div>

@ -153,7 +153,7 @@
</div> </div>
<div class="balancer__body"> <div class="balancer__body">
<div class="numbox"> <div class="numbox">
<div class="numbox__num medium">{{ udoc.nLiked or 0 }}</div> <div class="numbox__num medium">{{ udoc.nLike or 0 }}</div>
<div class="numbox__text">{{ _('Solutions Liked') }}</div> <div class="numbox__text">{{ _('Solutions Liked') }}</div>
</div> </div>
</div> </div>

Loading…
Cancel
Save