core&ui: fix homework operation (#500)

pull/501/head
panda 2 years ago committed by GitHub
parent b5a5633b73
commit fdfa5e9722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -109,14 +109,6 @@ class HomeworkDetailHandler extends Handler {
await contest.attend(domainId, tdoc.docId, this.user._id);
this.back();
}
@param('tid', Types.ObjectID)
async postDelete(domainId: string, tid: ObjectID) {
const tdoc = await contest.get(domainId, tid);
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
await contest.del(domainId, tid);
this.response.redirect = this.url('homework_main');
}
}
class HomeworkEditHandler extends Handler {
@ -163,7 +155,7 @@ class HomeworkEditHandler extends Handler {
@param('pids', Types.Content)
@param('rated', Types.Boolean)
@param('assign', Types.CommaSeperatedArray, true)
async post(
async postUpdate(
domainId: string, tid: ObjectID, beginAtDate: string, beginAtTime: string,
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
penaltyRules: PenaltyRules, title: string, content: string, _pids: string, rated = false,
@ -208,6 +200,14 @@ class HomeworkEditHandler extends Handler {
this.response.body = { tid };
this.response.redirect = this.url('homework_detail', { tid });
}
@param('tid', Types.ObjectID)
async postDelete(domainId: string, tid: ObjectID) {
const tdoc = await contest.get(domainId, tid);
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
await contest.del(domainId, tid);
this.response.redirect = this.url('homework_main');
}
}
export async function apply(ctx) {

@ -91,7 +91,7 @@
}) }}
<div class="row"><div class="columns">
{% if page_name == 'homework_edit' %}
<button type="submit" class="rounded primary button">
<button name="operation" value="update" type="submit" class="rounded primary button">
{{ _('Update') }}
</button>
<button name="operation" value="update" type="submit" formaction="{{ url('homework_create') }}" class="rounded button">
@ -103,7 +103,7 @@
</button>
{% endif %}
{% else %}
<button type="submit" class="rounded primary button">
<button name="operation" value="update" type="submit" class="rounded primary button">
{{ _('Create') }}
</button>
{% endif %}

Loading…
Cancel
Save