mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: user_detail: show solutions (#414)
This commit is contained in:
1 parent
e3dd65c690
commit
6ed4d74210
8 files changed
+62
-30
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.16.5",
|
||||
"version": "3.16.6",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -16,6 +16,7 @@ import domain from '../model/domain';
|
||||
import oauth from '../model/oauth';
|
||||
import * as oplog from '../model/oplog';
|
||||
import problem, { ProblemDoc } from '../model/problem';
|
||||
import SolutionModel from '../model/solution';
|
||||
import * as system from '../model/system';
|
||||
import task from '../model/task';
|
||||
import token from '../model/token';
|
||||
@@ -323,6 +324,16 @@ class UserDetailHandler extends Handler {
|
||||
this.response.body = {
|
||||
isSelfProfile, udoc, sdoc, pdocs, tags,
|
||||
};
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION)) {
|
||||
const psdocs = await SolutionModel.getByUser(domainId, uid).limit(10).toArray();
|
||||
this.response.body.psdocs = psdocs;
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) {
|
||||
this.response.body.pdict = await problem.getList(
|
||||
domainId, psdocs.map((i) => i.parentId), canViewHidden,
|
||||
this.user.group, false, problem.PROJECTION_LIST,
|
||||
);
|
||||
}
|
||||
}
|
||||
this.UiContext.extraTitleContent = udoc.uname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,13 @@ class SolutionModel {
|
||||
).sort({ vote: -1 });
|
||||
}
|
||||
|
||||
static getByUser(domainId: string, uid: number) {
|
||||
return document.getMulti(
|
||||
domainId, document.TYPE_PROBLEM_SOLUTION,
|
||||
{ parentType: document.TYPE_PROBLEM, owner: uid },
|
||||
).sort({ _id: -1 });
|
||||
}
|
||||
|
||||
static reply(domainId: string, psid: ObjectID, owner: number, content: string) {
|
||||
return document.push(domainId, document.TYPE_PROBLEM_SOLUTION, psid, 'reply', content, owner);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user