Skip to content

Commit 8457bad

Browse files
authored
Merge pull request #71 from codemate-oj/feat/luckycv/defined-contest
Feat/luckycv/defined contest
2 parents 20cf836 + b68720b commit 8457bad

7 files changed

Lines changed: 645 additions & 13 deletions

File tree

packages/codemate-plugin/plugins/login-limit/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export function apply(ctx: Context) {
1515
const udoc = await UserModel.getById(that.args['domainId'], that.session.uid);
1616
if (udoc.hasPriv(PRIV.PRIV_UNLIMITED_ACCESS)) return; // bypass admin
1717
const userIp = that.request.ip;
18+
const createHost = that.request.host;
1819
// 处理IP白名单逻辑,以适应SSR
1920
const whiteListSetting: string = SystemModel.get('loginlimit.whitelist') ?? '';
2021
const ipWhiteList = whiteListSetting.split(',');
2122
if (ipWhiteList.includes(userIp)) return; // bypass server
22-
// 踢掉所有其他IP
23-
const tdocs = await TokenModel.getMulti(TokenModel.TYPE_SESSION, { uid: udoc._id }).toArray();
23+
// 踢掉所有其他同域IP
24+
const tdocs = await TokenModel.getMulti(TokenModel.TYPE_SESSION, { uid: udoc._id, createHost }).toArray();
2425
await Promise.all(tdocs.map(async (tdoc) => TokenModel.del(tdoc._id, TokenModel.TYPE_SESSION)));
2526
if (tdocs.length > 0) {
2627
logger.info(`User ${udoc._id} login at ${userIp}. ${tdocs.length} sessions expired.`);

packages/hydrooj/src/handler/contest.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,17 @@ export class ContestEditHandler extends Handler {
545545
@param('checkinEndAtDate', Types.Date)
546546
@param('checkinEndAtTime', Types.Time)
547547
@param('title', Types.Title)
548+
@param('languageSubject', Types.String, true)
549+
@param('category', Types.String, true)
550+
@param('organizer', Types.String, true)
551+
@param('stage', Types.String, true)
552+
@param('totalScore', Types.Float, true)
553+
@param('problemCategoryConfig', Types.String, true)
554+
@param('judgementPrice', Types.Float, true)
555+
@param('attendPrice', Types.Float, true)
556+
@param('evalutionPrice', Types.Float, true)
557+
@param('contestMode', Types.String, true)
558+
@param('hasMonitor', Types.Boolean, true)
548559
@param('content', Types.Content)
549560
@param('rule', Types.Range(Object.keys(contest.RULES).filter((i) => !contest.RULES[i].hidden)))
550561
@param('pids', Types.Content)
@@ -570,6 +581,17 @@ export class ContestEditHandler extends Handler {
570581
checkinEndAtDate: string,
571582
checkinEndAtTime: string,
572583
title: string,
584+
languageSubject: string,
585+
category: string,
586+
organizer: string,
587+
stage: string,
588+
totalScore: number,
589+
problemCategoryConfig: string,
590+
judgementPrice: number,
591+
attendPrice: number,
592+
evalutionPrice: number,
593+
contestMode: string,
594+
hasMonitor: boolean = false,
573595
content: string,
574596
rule: string,
575597
_pids: string,
@@ -613,6 +635,17 @@ export class ContestEditHandler extends Handler {
613635
if (tid) {
614636
await contest.edit(domainId, tid, {
615637
title,
638+
languageSubject,
639+
category,
640+
organizer,
641+
stage,
642+
totalScore,
643+
problemCategoryConfig,
644+
judgementPrice,
645+
attendPrice,
646+
evalutionPrice,
647+
contestMode,
648+
hasMonitor,
616649
content,
617650
rule,
618651
beginAt,
@@ -637,6 +670,17 @@ export class ContestEditHandler extends Handler {
637670
}
638671
} else {
639672
tid = await contest.add(domainId, title, content, this.user._id, rule, beginAt, endAt, pids, rated, {
673+
languageSubject,
674+
category,
675+
organizer,
676+
stage,
677+
totalScore,
678+
problemCategoryConfig,
679+
judgementPrice,
680+
attendPrice,
681+
evalutionPrice,
682+
contestMode,
683+
hasMonitor,
640684
duration: contestDuration,
641685
tag,
642686
checkinBeginAt,

packages/hydrooj/src/interface.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,18 @@ export interface Tdoc extends Document {
433433
imageURL?: string; // 比赛封面图
434434
needRealName?: boolean; // 是否需要实名
435435

436+
languageSubject?: string; // 语言
437+
category?: string; // 比赛类别
438+
organizer?: string; // 主办方
439+
stage?: string; // 比赛阶段
440+
totalScore?: number; // 比赛折算总分
441+
problemCategoryConfig?: string; // 题目排版配置及折算分数
442+
judgementPrice?: number; // 付费评测
443+
attendPrice?: number; // 付费参赛
444+
evalutionPrice?: number; // 付费评估
445+
contestMode?: string; // 比赛题目排版模式
446+
hasMonitor?: boolean; // 加载防作弊系统
447+
436448
/**
437449
* In hours
438450
* 在比赛有效时间内选择特定的 X 小时参加比赛(从首次打开比赛算起)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.defined-problem-category button {
2+
min-width: 3rem;
3+
border: 1px solid #e8e8e8;
4+
padding: .5rem 1rem;
5+
color: #555;
6+
}
7+
.defined-problem-category input.textbox, .defined-problem-category select.select {
8+
margin-bottom: 0;
9+
}
10+
.defined-problem-category .flex-gap-align-bottom {
11+
display: flex;
12+
gap: 10px;
13+
align-items: baseline;
14+
margin-bottom: .5rem;
15+
}

0 commit comments

Comments
 (0)