mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
主页
This commit is contained in:
1 parent
ce3d11b999
commit
b1153b641a
13 files changed
+163
-42
No files matched your search
+52
-1
@@ -1,8 +1,59 @@
|
|||||||
const { Route, Handler } = require('../service/server');
|
const { Route, Handler } = require('../service/server');
|
||||||
|
const contest = require('../model/contest');
|
||||||
|
const user = require('../model/user');
|
||||||
|
const training = require('../model/training');
|
||||||
|
const { PERM_VIEW_TRAINING, PERM_VIEW_CONTEST, PERM_VIEW_DISCUSSION } = require('../permission');
|
||||||
|
const { CONTESTS_ON_MAIN, TRAININGS_ON_MAIN, DISCUSSIONS_ON_MAIN } = require('../options').constants;
|
||||||
|
|
||||||
class HomeHandler extends Handler {
|
class HomeHandler extends Handler {
|
||||||
|
async contest() {
|
||||||
|
if (this.user.hasPerm(PERM_VIEW_CONTEST)) {
|
||||||
|
const tdocs = await contest.getMulti()
|
||||||
|
.limit(CONTESTS_ON_MAIN)
|
||||||
|
.toArray();
|
||||||
|
const tsdict = await contest.getListStatus(
|
||||||
|
this.user._id, tdocs.map((tdoc) => tdoc._id),
|
||||||
|
);
|
||||||
|
return [tdocs, tsdict];
|
||||||
|
}
|
||||||
|
return [[], {}];
|
||||||
|
}
|
||||||
|
|
||||||
|
async training() {
|
||||||
|
if (this.user.hasPerm(PERM_VIEW_TRAINING)) {
|
||||||
|
const tdocs = await training.getMulti()
|
||||||
|
.sort('_id', 1)
|
||||||
|
.limit(TRAININGS_ON_MAIN)
|
||||||
|
.toArray();
|
||||||
|
const tsdict = await training.getListStatus(
|
||||||
|
this.user._id, tdocs.map((tdoc) => tdoc._id),
|
||||||
|
);
|
||||||
|
return [tdocs, tsdict];
|
||||||
|
}
|
||||||
|
return [[], {}];
|
||||||
|
}
|
||||||
|
|
||||||
|
async discussion() {
|
||||||
|
// TODO(masnn)
|
||||||
|
// if (this.user.hasPerm(PERM_VIEW_DISCUSSION)) {
|
||||||
|
// const ddocs = await discussion.getMulti()
|
||||||
|
// .limit(DISCUSSIONS_ON_MAIN)
|
||||||
|
// .toArray();
|
||||||
|
// const vndict = await discussion.getListVnodes(map(discussion.node_id, ddocs));
|
||||||
|
// return [ddocs, vndict];
|
||||||
|
// }
|
||||||
|
return [[], {}];
|
||||||
|
}
|
||||||
|
|
||||||
async get() {
|
async get() {
|
||||||
this.response.body = {};
|
const [[tdocs, tsdict], [trdocs, trsdict], [ddocs, vndict]] = await Promise.all([
|
||||||
|
this.contest(), this.training(), this.discussion(),
|
||||||
|
]);
|
||||||
|
const udict = await user.getList(ddocs.map((ddoc) => ddoc.owner));
|
||||||
|
this.response.template = 'main.html';
|
||||||
|
this.response.body = {
|
||||||
|
tdocs, tsdict, trdocs, trsdict, ddocs, vndict, udict,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+38
-9
@@ -1,6 +1,9 @@
|
|||||||
const { PERM_JUDGE } = require('../permission');
|
const { PERM_JUDGE } = require('../permission');
|
||||||
const record = require('../model/record');
|
const record = require('../model/record');
|
||||||
const problem = require('../model/problem');
|
const problem = require('../model/problem');
|
||||||
|
const builtin = require('../model/builtin');
|
||||||
|
const contest = require('../model/contest');
|
||||||
|
const user = require('../model/user');
|
||||||
const bus = require('../service/bus');
|
const bus = require('../service/bus');
|
||||||
const queue = require('../service/queue');
|
const queue = require('../service/queue');
|
||||||
const {
|
const {
|
||||||
@@ -9,42 +12,66 @@ const {
|
|||||||
|
|
||||||
queue.assert('judge');
|
queue.assert('judge');
|
||||||
|
|
||||||
|
async function _postJudge(rdoc) {
|
||||||
|
const accept = rdoc.status === builtin.STATUS_ACCEPTED;
|
||||||
|
bus.publish('record_change', rdoc);
|
||||||
|
const tasks = [];
|
||||||
|
if (rdoc.tid) {
|
||||||
|
tasks.push(
|
||||||
|
contest.updateStatus(rdoc.tid, rdoc.uid, rdoc._id, rdoc.pid, accept, rdoc.score),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!rdoc.rejudged) {
|
||||||
|
if (await problem.updateStatus(rdoc.pid, rdoc.uid, rdoc._id, rdoc.status)) {
|
||||||
|
if (accept) {
|
||||||
|
tasks.push(
|
||||||
|
problem.inc(rdoc.pid, 'nAccept', 1),
|
||||||
|
user.inc(rdoc.uid, 'nAccept', 1),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Promise.all(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
async function next(body) {
|
async function next(body) {
|
||||||
let rdoc = await record.get(body.rid);
|
let rdoc = await record.get(body.rid);
|
||||||
const $set = {};
|
const $set = {};
|
||||||
|
const $push = {};
|
||||||
if (body.case) {
|
if (body.case) {
|
||||||
rdoc.testCases.push(body.case);
|
rdoc.testCases.push(body.case);
|
||||||
$set.testCases = rdoc.testCases;
|
$push.testCases = body.case;
|
||||||
}
|
}
|
||||||
if (body.judge_text) {
|
if (body.judge_text) {
|
||||||
rdoc.judgeTexts.push(body.judge_text);
|
rdoc.judgeTexts.push(body.judge_text);
|
||||||
$set.judgeTexts = rdoc.judgeTexts;
|
$push.judgeTexts = body.judge_text;
|
||||||
}
|
}
|
||||||
if (body.compiler_text) {
|
if (body.compiler_text) {
|
||||||
rdoc.compilerTexts.push(body.compiler_text);
|
rdoc.compilerTexts.push(body.compiler_text);
|
||||||
$set.compilerTexts = rdoc.compilerTexts;
|
$push.compilerTexts = body.compiler_text;
|
||||||
}
|
}
|
||||||
if (body.status) $set.status = body.status;
|
if (body.status) $set.status = body.status;
|
||||||
if (body.score) $set.score = body.score;
|
if (body.score) $set.score = body.score;
|
||||||
if (body.time_ms) $set.time = body.time_ms;
|
if (body.time_ms) $set.time = body.time_ms;
|
||||||
if (body.memory_kb) $set.memory = body.memory_kb;
|
if (body.memory_kb) $set.memory = body.memory_kb;
|
||||||
rdoc = await record.update(body.rid, $set);
|
rdoc = await record.update(body.rid, $set, $push);
|
||||||
bus.publish('record_change', rdoc);
|
bus.publish('record_change', rdoc);
|
||||||
}
|
}
|
||||||
async function end(body) {
|
async function end(body) {
|
||||||
let rdoc = await record.get(body.rid);
|
let rdoc = await record.get(body.rid);
|
||||||
const $set = {};
|
const $set = {};
|
||||||
|
const $push = {};
|
||||||
if (body.case) {
|
if (body.case) {
|
||||||
rdoc.testCases.push(body.case);
|
rdoc.testCases.push(body.case);
|
||||||
$set.testCases = rdoc.testCases;
|
$push.testCases = body.case;
|
||||||
}
|
}
|
||||||
if (body.judge_text) {
|
if (body.judge_text) {
|
||||||
rdoc.judgeTexts.push(body.judge_text);
|
rdoc.judgeTexts.push(body.judge_text);
|
||||||
$set.judgeTexts = rdoc.judgeTexts;
|
$push.judgeTexts = body.judge_text;
|
||||||
}
|
}
|
||||||
if (body.compiler_text) {
|
if (body.compiler_text) {
|
||||||
rdoc.compilerTexts.push(body.compiler_text);
|
rdoc.compilerTexts.push(body.compiler_text);
|
||||||
$set.compilerTexts = rdoc.compilerTexts;
|
$push.compilerTexts = body.compiler_text;
|
||||||
}
|
}
|
||||||
if (body.status) $set.status = body.status;
|
if (body.status) $set.status = body.status;
|
||||||
if (body.score) $set.score = body.score;
|
if (body.score) $set.score = body.score;
|
||||||
@@ -52,8 +79,9 @@ async function end(body) {
|
|||||||
if (body.memory_kb) $set.memory = body.memory_kb;
|
if (body.memory_kb) $set.memory = body.memory_kb;
|
||||||
$set.judgeAt = new Date();
|
$set.judgeAt = new Date();
|
||||||
$set.judger = body.judger;
|
$set.judger = body.judger;
|
||||||
rdoc = await record.update(body.rid, $set);
|
rdoc = await record.update(body.rid, $set, $push);
|
||||||
bus.publish('record_change', rdoc);
|
await _postJudge(rdoc);
|
||||||
|
rdoc = await record.update(body.rid, $set, $push);
|
||||||
}
|
}
|
||||||
|
|
||||||
class JudgeHandler extends Handler {
|
class JudgeHandler extends Handler {
|
||||||
@@ -87,6 +115,7 @@ class JudgeHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async postEnd() {
|
async postEnd() {
|
||||||
|
this.request.body.judger = this.user._id;
|
||||||
await end(this.request.body);
|
await end(this.request.body);
|
||||||
this.response.body = {};
|
this.response.body = {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const {
|
|||||||
PERM_CREATE_PROBLEM, PERM_READ_PROBLEM_DATA, PERM_EDIT_PROBLEM,
|
PERM_CREATE_PROBLEM, PERM_READ_PROBLEM_DATA, PERM_EDIT_PROBLEM,
|
||||||
PERM_JUDGE, PERM_VIEW_PROBLEM_SOLUTION, PERM_CREATE_PROBLEM_SOLUTION,
|
PERM_JUDGE, PERM_VIEW_PROBLEM_SOLUTION, PERM_CREATE_PROBLEM_SOLUTION,
|
||||||
PERM_EDIT_PROBLEM_SOLUTION, PERM_DELETE_PROBLEM_SOLUTION, PERM_EDIT_PROBLEM_SOLUTION_REPLY,
|
PERM_EDIT_PROBLEM_SOLUTION, PERM_DELETE_PROBLEM_SOLUTION, PERM_EDIT_PROBLEM_SOLUTION_REPLY,
|
||||||
PERM_REPLY_PROBLEM_SOLUTION,
|
PERM_REPLY_PROBLEM_SOLUTION, PERM_LOGGEDIN,
|
||||||
} = require('../permission');
|
} = require('../permission');
|
||||||
|
|
||||||
queue.assert('judge');
|
queue.assert('judge');
|
||||||
@@ -32,9 +32,13 @@ class ProblemHandler extends Handler {
|
|||||||
async get({ page = 1, category = null }) {
|
async get({ page = 1, category = null }) {
|
||||||
this.response.template = 'problem_main.html';
|
this.response.template = 'problem_main.html';
|
||||||
const q = {};
|
const q = {};
|
||||||
|
let psdict = {};
|
||||||
if (category) q.category = category;
|
if (category) q.category = category;
|
||||||
if (!this.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
if (!this.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN)) q.hidden = false;
|
||||||
const pdocs = await problem.getMany(q, { pid: 1 }, page, constants.PROBLEM_PER_PAGE);
|
const pdocs = await problem.getMany(q, { pid: 1 }, page, constants.PROBLEM_PER_PAGE);
|
||||||
|
if (this.user.hasPerm(PERM_LOGGEDIN)) {
|
||||||
|
psdict = await problem.getListStatus(this.user._id, pdocs.map((pdoc) => pdoc._id));
|
||||||
|
}
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
path: [
|
path: [
|
||||||
['Hydro', '/'],
|
['Hydro', '/'],
|
||||||
@@ -42,6 +46,7 @@ class ProblemHandler extends Handler {
|
|||||||
],
|
],
|
||||||
page,
|
page,
|
||||||
pdocs,
|
pdocs,
|
||||||
|
psdict,
|
||||||
category: '',
|
category: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,12 +54,14 @@ class RecordDetailHandler extends Handler {
|
|||||||
if (rdoc.uid !== this.user.uid && !this.user.hasPerm(PERM_READ_RECORD_CODE)) {
|
if (rdoc.uid !== this.user.uid && !this.user.hasPerm(PERM_READ_RECORD_CODE)) {
|
||||||
rdoc.code = null;
|
rdoc.code = null;
|
||||||
}
|
}
|
||||||
|
const pdoc = await problem.getById(rdoc.pid);
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
path: [
|
path: [
|
||||||
['Hydro', '/'],
|
['Hydro', '/'],
|
||||||
['record_detail', null],
|
['record_detail', null],
|
||||||
],
|
],
|
||||||
rdoc,
|
rdoc,
|
||||||
|
pdoc,
|
||||||
show_status: true,
|
show_status: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class TrainingDetailHandler extends TrainingHandler {
|
|||||||
for (const pid in psdict) {
|
for (const pid in psdict) {
|
||||||
const psdoc = psdict[pid];
|
const psdoc = psdict[pid];
|
||||||
if (psdoc.status) {
|
if (psdoc.status) {
|
||||||
if (psdoc.status === builtin.status.STATUS_ACCEPTED) donePids.add(pid);
|
if (psdoc.status === builtin.STATUS_ACCEPTED) donePids.add(pid);
|
||||||
else progPids.add(pid);
|
else progPids.add(pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ async function edit(_id, $set) {
|
|||||||
if (!pdoc) throw new ProblemNotFoundError(_id);
|
if (!pdoc) throw new ProblemNotFoundError(_id);
|
||||||
return pdoc;
|
return pdoc;
|
||||||
}
|
}
|
||||||
|
async function inc(_id, field, n) {
|
||||||
|
await coll.findOneAndUpdate({ _id }, { $inc: { [field]: n } });
|
||||||
|
const pdoc = await getById(_id);
|
||||||
|
if (!pdoc) throw new ProblemNotFoundError(_id);
|
||||||
|
return pdoc;
|
||||||
|
}
|
||||||
function count(query) {
|
function count(query) {
|
||||||
return coll.find(query).count();
|
return coll.find(query).count();
|
||||||
}
|
}
|
||||||
@@ -134,6 +140,14 @@ async function getListStatus(uid, pids) {
|
|||||||
for (const psdoc of psdocs) r[psdoc.pid] = psdoc;
|
for (const psdoc of psdocs) r[psdoc.pid] = psdoc;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
async function updateStatus(pid, uid, rid, status) {
|
||||||
|
const res = await collStatus.findOneAndUpdate(
|
||||||
|
{ pid, uid },
|
||||||
|
{ $set: { rid, status } },
|
||||||
|
{ upsert: true },
|
||||||
|
);
|
||||||
|
return res.value;
|
||||||
|
}
|
||||||
async function setTestdata(_id, readStream) {
|
async function setTestdata(_id, readStream) {
|
||||||
const pdoc = await getById(_id);
|
const pdoc = await getById(_id);
|
||||||
const f = gridfs.openUploadStream('data.zip');
|
const f = gridfs.openUploadStream('data.zip');
|
||||||
@@ -148,6 +162,7 @@ async function setTestdata(_id, readStream) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
add,
|
add,
|
||||||
|
inc,
|
||||||
get,
|
get,
|
||||||
getMany,
|
getMany,
|
||||||
edit,
|
edit,
|
||||||
@@ -159,4 +174,5 @@ module.exports = {
|
|||||||
getListStatus,
|
getListStatus,
|
||||||
getMultiStatus,
|
getMultiStatus,
|
||||||
setTestdata,
|
setTestdata,
|
||||||
|
updateStatus,
|
||||||
};
|
};
|
||||||
@@ -39,9 +39,12 @@ function getMany(query, sort, page, limit) {
|
|||||||
return coll.find(query).sort(sort).skip((page - 1) * limit).limit(limit)
|
return coll.find(query).sort(sort).skip((page - 1) * limit).limit(limit)
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
}
|
||||||
async function update(rid, $set) {
|
async function update(rid, $set, $push) {
|
||||||
const _id = new ObjectID(rid);
|
const _id = new ObjectID(rid);
|
||||||
await coll.findOneAndUpdate({ _id }, { $set });
|
const upd = {};
|
||||||
|
if ($set && Object.keys($set).length) upd.$set = $set;
|
||||||
|
if ($push && Object.keys($push).length) upd.$push = $push;
|
||||||
|
await coll.findOneAndUpdate({ _id }, upd);
|
||||||
const rdoc = await coll.findOne({ _id });
|
const rdoc = await coll.findOne({ _id });
|
||||||
if (!rdoc) throw new RecordNotFoundError(rid);
|
if (!rdoc) throw new RecordNotFoundError(rid);
|
||||||
return rdoc;
|
return rdoc;
|
||||||
|
|||||||
+15
-2
@@ -6,6 +6,18 @@ const db = require('../service/db.js');
|
|||||||
const coll = db.collection('traning');
|
const coll = db.collection('traning');
|
||||||
const collStatus = db.collection('training.status');
|
const collStatus = db.collection('training.status');
|
||||||
|
|
||||||
|
function getStatus(tid, uid) {
|
||||||
|
return collStatus.findOne({ tid, uid });
|
||||||
|
}
|
||||||
|
function getMultiStatus(query) {
|
||||||
|
return collStatus.find(query);
|
||||||
|
}
|
||||||
|
async function getListStatus(uid, tids) {
|
||||||
|
const psdocs = await getMultiStatus({ uid, pid: { $in: Array.from(new Set(tids)) } }).toArray();
|
||||||
|
const r = {};
|
||||||
|
for (const psdoc of psdocs) r[psdoc.pid] = psdoc;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
async function enroll(tid, uid) {
|
async function enroll(tid, uid) {
|
||||||
try {
|
try {
|
||||||
await collStatus.insertOne({ tid, uid, enroll: 1 });
|
await collStatus.insertOne({ tid, uid, enroll: 1 });
|
||||||
@@ -93,8 +105,9 @@ module.exports = {
|
|||||||
return tdoc;
|
return tdoc;
|
||||||
},
|
},
|
||||||
getMulti: (query) => coll.find(query),
|
getMulti: (query) => coll.find(query),
|
||||||
getMultiStatus: (query) => collStatus.find(query),
|
getMultiStatus,
|
||||||
getStatus: (tid, uid) => collStatus.findOne({ tid, uid }),
|
getStatus,
|
||||||
enroll,
|
enroll,
|
||||||
setStatus,
|
setStatus,
|
||||||
|
getListStatus,
|
||||||
};
|
};
|
||||||
@@ -89,6 +89,11 @@ async function changePassword(uid, currentPassword, newPassword) {
|
|||||||
$set: { salt, hash: pwhash.hash(newPassword, salt) },
|
$set: { salt, hash: pwhash.hash(newPassword, salt) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async function inc(_id, field, n) {
|
||||||
|
await coll.findOneAndUpdate({ _id }, { $inc: { [field]: n } });
|
||||||
|
const udoc = await getById(_id);
|
||||||
|
return udoc;
|
||||||
|
}
|
||||||
async function create({
|
async function create({
|
||||||
uid, mail, uname, password, regip = '127.0.0.1', role = 'default',
|
uid, mail, uname, password, regip = '127.0.0.1', role = 'default',
|
||||||
}) {
|
}) {
|
||||||
@@ -129,6 +134,7 @@ module.exports = {
|
|||||||
getById,
|
getById,
|
||||||
getByUname,
|
getByUname,
|
||||||
getMany,
|
getMany,
|
||||||
|
inc,
|
||||||
setById,
|
setById,
|
||||||
setEmail,
|
setEmail,
|
||||||
setPassword,
|
setPassword,
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ let options = {
|
|||||||
SOLUTION_PER_PAGE: 20,
|
SOLUTION_PER_PAGE: 20,
|
||||||
CONTEST_PER_PAGE: 20,
|
CONTEST_PER_PAGE: 20,
|
||||||
TRAINING_PER_PAGE: 10,
|
TRAINING_PER_PAGE: 10,
|
||||||
|
CONTESTS_ON_MAIN: 5,
|
||||||
|
TRAININGS_ON_MAIN: 5,
|
||||||
|
DISCUSSIONS_ON_MAIN: 20,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{% macro render_problem_title(pdoc, tdoc=none, show_tags=true, show_invisible_flag=true, rp=none, invalid=false) %}
|
{% macro render_problem_title(pdoc, tdoc=none, show_tags=true, show_invisible_flag=true, rp=none, invalid=false) %}
|
||||||
{%- if not invalid %}
|
{%- if not invalid %}
|
||||||
<a
|
<a
|
||||||
{%- if tdoc is none %}
|
{%- if tdoc %}
|
||||||
href="/p/{{ pdoc.pid }}"
|
|
||||||
{%- else %}
|
|
||||||
href="/c/{{ tdoc._id }}/p/{{ pdoc._id }}"
|
href="/c/{{ tdoc._id }}/p/{{ pdoc._id }}"
|
||||||
|
{%- else %}
|
||||||
|
href="/p/{{ pdoc.pid }}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
>
|
>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<h1 class="section__title">{{ _('Discussion Nodes') }}</h1>
|
<h1 class="section__title">{{ _('Discussion Nodes') }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="section__body"><ul class="group-list">
|
<div class="section__body"><ul class="group-list">
|
||||||
{% for category, nodes in discussion_nodes.items() %}
|
{% for category, nodes in discussionNodes.items() %}
|
||||||
<li class="group-list__item">
|
<li class="group-list__item">
|
||||||
<h2 class="section__title">{{ category }}</h2>
|
<h2 class="section__title">{{ category }}</h2>
|
||||||
<ol class="chip-list">
|
<ol class="chip-list">
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
{% set no_path_section = true %}
|
{% set no_path_section = true %}
|
||||||
|
{% set page_name = "domain_main" %}
|
||||||
{% extends "layout/basic.html" %}
|
{% extends "layout/basic.html" %}
|
||||||
{% import "components/contest.html" as contest with context %}
|
{% import "components/contest.html" as contest with context %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if handler.domain['bulletin'] %}
|
{% if system['bulletin'] %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section__body typo">
|
<div class="section__body typo">
|
||||||
{{ handler.domain['bulletin']|markdown }}
|
{{ system['bulletin']|markdown }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -15,9 +16,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-9 columns">
|
<div class="large-9 columns">
|
||||||
{% if not tdocs %}
|
{% if tdocs.length %}
|
||||||
<!-- no contest -->
|
|
||||||
{% else %}
|
|
||||||
<div class="section page--contest_main">
|
<div class="section page--contest_main">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Contest') }}</h1>
|
<h1 class="section__title">{{ _('Contest') }}</h1>
|
||||||
@@ -28,15 +27,15 @@
|
|||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media__left medium">
|
<div class="media__left medium">
|
||||||
<div class="contest__date numbox">
|
<div class="contest__date numbox">
|
||||||
<div class="numbox__num large">{{ datetime_span(tdoc['begin_at'], false, '%d') }}</div>
|
<div class="numbox__num large">{{ datetime_span(tdoc['beginAt'], false, '%d')|safe }}</div>
|
||||||
<div class="numbox__text">{{ datetime_span(tdoc['begin_at'], false, '%Y-%m') }}</div>
|
<div class="numbox__text">{{ datetime_span(tdoc['beginAt'], false, '%Y-%m')|safe }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="media__body medium">
|
<div class="media__body medium">
|
||||||
<h1 class="contest__title"><a href="/c/{{ tdoc._id }}" data-emoji-enabled>{{ tdoc.title }}</a></h1>
|
<h1 class="contest__title"><a href="/c/{{ tdoc._id }}" data-emoji-enabled>{{ tdoc.title }}</a></h1>
|
||||||
<ul class="supplementary list">
|
<ul class="supplementary list">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ reverse_url('contest_main') }}?rule={{ tdoc['rule'] }}" class="contest-type-tag"><span class="icon icon-award"></span>{{ vj4.constant.contest.RULE_TEXTS[tdoc['rule']] }}</a>
|
<a href="/c?rule={{ tdoc['rule'] }}" class="contest-type-tag"><span class="icon icon-award"></span>{{ model.contest.RULES[tdoc.rule].TEXT }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="icon icon-schedule--fill text-blue"></span> {{ contest.render_duration(tdoc) }} {{ _('hour(s)') }}
|
<span class="icon icon-schedule--fill text-blue"></span> {{ contest.render_duration(tdoc) }} {{ _('hour(s)') }}
|
||||||
@@ -57,14 +56,13 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not trdocs %}
|
{% if trdocs.length %}
|
||||||
<!-- no training -->
|
|
||||||
{% else %}
|
|
||||||
<div class="section page--training_main">
|
<div class="section page--training_main">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Training') }}</h1>
|
<h1 class="section__title">{{ _('Training') }}</h1>
|
||||||
</div>
|
</div>
|
||||||
{% with tdocs=trdocs, tsdict=trsdict %}
|
{% set tdocs = trdocs %}
|
||||||
|
{% set tsdict = trsdict %}
|
||||||
<ol class="section__list all primary training__list">
|
<ol class="section__list all primary training__list">
|
||||||
{% for tdoc in tdocs %}
|
{% for tdoc in tdocs %}
|
||||||
<li class="section__list__item training__item">
|
<li class="section__list__item training__item">
|
||||||
@@ -76,19 +74,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="media__body middle">
|
<div class="media__body middle">
|
||||||
<h1 class="training__title"><a href="{{ reverse_url('training_detail', tid=tdoc._id) }}" data-emoji-enabled>{{ tdoc.title }}</a></h1>
|
<h1 class="training__title"><a href="/t/{{ tdoc._id }}" data-emoji-enabled>{{ tdoc.title }}</a></h1>
|
||||||
<div class="training__intro typo">
|
<div class="training__intro typo">
|
||||||
<p>{{ tdoc['content'] }}</p>
|
<p>{{ tdoc['content'] }}</p>
|
||||||
</div>
|
</div>
|
||||||
<ul class="supplementary list training__progress">
|
<ul class="supplementary list training__progress">
|
||||||
<li>
|
<li>
|
||||||
<span class="icon icon-flag text-blue"></span> {{ _('{0} sections').format(tdoc['dag']|length) }}, {{ _('{0} problems').format(training.get_pids(tdoc)|length) }}
|
<span class="icon icon-flag text-blue"></span> {{ _('{0} sections').format(tdoc['dag']|length) }}, {{ _('{0} problems').format(model.training.getPids(tdoc)|length) }}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{% if tsdict[tdoc._id]['enroll'] %}
|
{% if tsdict[tdoc._id]['enroll'] %}
|
||||||
{% if not tsdict[tdoc._id]['done'] %}
|
{% if not tsdict[tdoc._id]['done'] %}
|
||||||
<span class="icon training-status--icon progress"></span>
|
<span class="icon training-status--icon progress"></span>
|
||||||
<span class="training-status--text progress">{{ _('Completed') }} {{ (100 * tsdict[tdoc._id]['done_pids']|length / training.get_pids(tdoc)|length)|round|int }}%</span>
|
<span class="training-status--text progress">{{ _('Completed') }} {{ (100 * tsdict[tdoc._id]['donePids']|length / model.training.getPids(tdoc)|length)|round|int }}%</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="icon training-status--icon done"></span>
|
<span class="icon training-status--icon done"></span>
|
||||||
<span class="training-status--text done">{{ _('Completed') }} 100%</span>
|
<span class="training-status--text done">{{ _('Completed') }} 100%</span>
|
||||||
@@ -103,12 +101,9 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
{% endwith %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not ddocs %}
|
{% if ddocs.length %}
|
||||||
<!-- no discussion -->
|
|
||||||
{% else %}
|
|
||||||
<div class="section page--discussion_main">
|
<div class="section page--discussion_main">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Discussion') }}</h1>
|
<h1 class="section__title">{{ _('Discussion') }}</h1>
|
||||||
@@ -119,9 +114,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="large-3 columns">
|
<div class="large-3 columns">
|
||||||
{% if handler.hasPerm(perm.PERM_VIEW_DISCUSSION) %}
|
{% if handler.hasPerm(perm.PERM_VIEW_DISCUSSION) %}
|
||||||
{% include 'discussion_nodes_widget.html' %}
|
{#{% include 'discussion_nodes_widget.html' %} // TODO(masnn) #}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if domain_id == vj4.model.builtin.DOMAIN_ID_SYSTEM %}
|
|
||||||
<div class="section side">
|
<div class="section side">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Recommended') }}</h1>
|
<h1 class="section__title">{{ _('Recommended') }}</h1>
|
||||||
@@ -153,7 +147,6 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in new issue
Block a user