mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
添加功能:pretest discuss user dashboard statistics
This commit is contained in:
1 parent
61cba6f180
commit
15d43636c0
41 files changed
+920
-523
No files matched your search
+65
-94
@@ -6,6 +6,7 @@ class UserFacingError extends Error {
|
||||
this.params = [];
|
||||
}
|
||||
}
|
||||
|
||||
class SystemError extends Error {
|
||||
constructor(type) {
|
||||
super(type);
|
||||
@@ -14,70 +15,89 @@ class SystemError extends Error {
|
||||
this.params = [];
|
||||
}
|
||||
}
|
||||
|
||||
class BadRequestError extends UserFacingError {
|
||||
constructor(type) {
|
||||
super(type);
|
||||
this.code = 400;
|
||||
}
|
||||
}
|
||||
|
||||
class ForbiddenError extends UserFacingError {
|
||||
constructor(type) {
|
||||
super(type);
|
||||
this.code = 403;
|
||||
}
|
||||
}
|
||||
|
||||
class NotFoundError extends UserFacingError {
|
||||
constructor(type) {
|
||||
super(type || 'NotFoundError');
|
||||
this.code = 404;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteOnlineJudgeError extends UserFacingError {
|
||||
constructor(message) {
|
||||
super('RemoteOnlineJudgeError');
|
||||
this.params = [message];
|
||||
}
|
||||
}
|
||||
|
||||
class AlreadyVotedError extends BadRequestError {
|
||||
constructor(psid, uid) {
|
||||
super('You\'ve already voted.');
|
||||
this.params = [psid, uid];
|
||||
}
|
||||
}
|
||||
|
||||
class LoginError extends ForbiddenError {
|
||||
constructor(uname) {
|
||||
super('LoginError');
|
||||
this.params = [uname];
|
||||
}
|
||||
}
|
||||
|
||||
class UserAlreadyExistError extends ForbiddenError {
|
||||
constructor(uname) {
|
||||
super('UserAlreadyExistError');
|
||||
this.params = [uname];
|
||||
}
|
||||
}
|
||||
|
||||
class InvalidTokenError extends ForbiddenError {
|
||||
constructor(token) {
|
||||
super('InvalidTokenError');
|
||||
this.params = [token];
|
||||
}
|
||||
}
|
||||
|
||||
class BlacklistedError extends ForbiddenError {
|
||||
constructor(ip) {
|
||||
super('Address {0} is blacklisted.');
|
||||
this.params = [ip];
|
||||
}
|
||||
}
|
||||
|
||||
class UserNotFoundError extends NotFoundError {
|
||||
constructor(user) {
|
||||
super('UserNotFoundError');
|
||||
this.params = [user];
|
||||
}
|
||||
}
|
||||
|
||||
class NoProblemError extends NotFoundError {
|
||||
constructor() {
|
||||
super('NoProblemError');
|
||||
}
|
||||
}
|
||||
|
||||
class VerifyPasswordError extends ForbiddenError {
|
||||
constructor() {
|
||||
super('VerifyPasswordError');
|
||||
}
|
||||
}
|
||||
|
||||
class OpcountExceededError extends ForbiddenError {
|
||||
constructor(op, periodSecs, maxOperations) {
|
||||
super('OpcountExceededError');
|
||||
@@ -91,6 +111,7 @@ class PermissionError extends ForbiddenError {
|
||||
this.params = [perm];
|
||||
}
|
||||
}
|
||||
|
||||
class ValidationError extends ForbiddenError {
|
||||
constructor(field0, field1) {
|
||||
super('ValidationError');
|
||||
@@ -98,66 +119,84 @@ class ValidationError extends ForbiddenError {
|
||||
else this.params = [field0, field1];
|
||||
}
|
||||
}
|
||||
|
||||
class ContestNotAttendedError extends ForbiddenError {
|
||||
constructor(tid) {
|
||||
super('You haven\'t attended this contest yet.');
|
||||
this.params = [tid];
|
||||
}
|
||||
}
|
||||
|
||||
class ContestAlreadyAttendedError extends ForbiddenError {
|
||||
constructor(tid, uid) {
|
||||
super('You\'ve already attended this contest.');
|
||||
this.params = [tid, uid];
|
||||
}
|
||||
}
|
||||
|
||||
class ContestNotLiveError extends ForbiddenError {
|
||||
constructor(tid) {
|
||||
super('This contest is not live.');
|
||||
this.params = [tid];
|
||||
}
|
||||
}
|
||||
|
||||
class ContestScoreboardHiddenError extends ForbiddenError {
|
||||
constructor(tid) {
|
||||
super('Contest scoreboard is not visible.');
|
||||
this.params = [tid];
|
||||
}
|
||||
}
|
||||
|
||||
class TrainingAlreadyEnrollError extends ForbiddenError {
|
||||
constructor(tid, uid) {
|
||||
super("You've already enrolled this training.");
|
||||
this.params = [tid, uid];
|
||||
}
|
||||
}
|
||||
|
||||
class RoleAlreadyExistError extends ForbiddenError {
|
||||
constructor(role) {
|
||||
super('This role already exists.');
|
||||
this.params = [role];
|
||||
}
|
||||
}
|
||||
|
||||
class ProblemNotFoundError extends NotFoundError {
|
||||
constructor(pid) {
|
||||
super('ProblemNotFoundError');
|
||||
this.params = [pid];
|
||||
}
|
||||
}
|
||||
|
||||
class RecordNotFoundError extends NotFoundError {
|
||||
constructor(rid) {
|
||||
super('RecordNotFoundError');
|
||||
this.params = [rid];
|
||||
}
|
||||
}
|
||||
|
||||
class SolutionNotFoundError extends NotFoundError {
|
||||
constructor(psid) {
|
||||
super('SolutionNotFoundError');
|
||||
this.params = [psid];
|
||||
}
|
||||
}
|
||||
|
||||
class TrainingNotFoundError extends NotFoundError {
|
||||
constructor(tid) {
|
||||
super('TrainingNotFoundError');
|
||||
this.params = [tid];
|
||||
}
|
||||
}
|
||||
|
||||
class ContestNotFoundError extends NotFoundError {
|
||||
constructor(cid) {
|
||||
super('ContestNotFoundError');
|
||||
this.params = [cid];
|
||||
}
|
||||
}
|
||||
|
||||
class ProblemDataNotFoundError extends NotFoundError {
|
||||
constructor(pid) {
|
||||
super('Data of problem {0} not found.');
|
||||
@@ -165,8 +204,30 @@ class ProblemDataNotFoundError extends NotFoundError {
|
||||
}
|
||||
}
|
||||
|
||||
class DiscussionNodeNotFoundError extends NotFoundError {
|
||||
constructor(type, docId) {
|
||||
super('Discussion node {0}/{1} not found.');
|
||||
this.params = [type, docId];
|
||||
}
|
||||
}
|
||||
|
||||
class DocumentNotFoundError extends NotFoundError {
|
||||
constructor(docId) {
|
||||
super('Document {0} not found.');
|
||||
this.params = [docId];
|
||||
}
|
||||
}
|
||||
|
||||
class DiscussionNotFoundError extends NotFoundError {
|
||||
constructor(did) {
|
||||
super('Discussion {0} not found.');
|
||||
this.params = [did];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
BadRequestError,
|
||||
BlacklistedError,
|
||||
ForbiddenError,
|
||||
NotFoundError,
|
||||
LoginError,
|
||||
@@ -193,49 +254,13 @@ module.exports = {
|
||||
SystemError,
|
||||
TrainingAlreadyEnrollError,
|
||||
RemoteOnlineJudgeError,
|
||||
DiscussionNodeNotFoundError,
|
||||
DocumentNotFoundError,
|
||||
DiscussionNotFoundError,
|
||||
RoleAlreadyExistError,
|
||||
};
|
||||
|
||||
/*
|
||||
from vj4.model import builtin
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class HashError(Error):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidStateError(Error):
|
||||
pass
|
||||
|
||||
|
||||
class UserFacingError(Error):
|
||||
"""Error which faces end user."""
|
||||
|
||||
def to_dict(self):
|
||||
return {'name': self.__class__.__name__, 'args': self.args}
|
||||
|
||||
@property
|
||||
def http_status(self):
|
||||
return 500
|
||||
|
||||
@property
|
||||
def template_name(self):
|
||||
return 'error.html'
|
||||
|
||||
@property
|
||||
def message(self):
|
||||
return 'An error has occurred.'
|
||||
|
||||
|
||||
class BlacklistedError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Address {0} is blacklisted.'
|
||||
|
||||
|
||||
class FileTooLongError(ValidationError):
|
||||
@property
|
||||
def message(self):
|
||||
@@ -253,13 +278,6 @@ class UnknownFieldError(ForbiddenError):
|
||||
def message(self):
|
||||
return 'Unknown field {0}.'
|
||||
|
||||
|
||||
class DocumentNotFoundError(NotFoundError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Document {2} not found.'
|
||||
|
||||
|
||||
class CsrfTokenError(ForbiddenError):
|
||||
pass
|
||||
|
||||
@@ -296,54 +314,12 @@ class DiscussionNodeAlreadyExistError(ForbiddenError):
|
||||
return 'Discussion node {1} already exists.'
|
||||
|
||||
|
||||
class DiscussionNodeNotFoundError(NotFoundError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Discussion node {1} not found.'
|
||||
|
||||
|
||||
class DiscussionNotFoundError(DocumentNotFoundError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Discussion {1} not found.'
|
||||
|
||||
|
||||
class MessageNotFoundError(NotFoundError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Message {0} not found.'
|
||||
|
||||
|
||||
class InvalidJoinInvitationCodeError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'The invitation code you provided is invalid.'
|
||||
|
||||
|
||||
class HomeworkScoreboardHiddenError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Homework scoreboard is not visible.'
|
||||
|
||||
|
||||
class HomeworkNotLiveError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'This homework is not open.'
|
||||
|
||||
|
||||
class HomeworkAlreadyAttendedError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return "You've already claimed this homework."
|
||||
|
||||
|
||||
class HomeworkNotAttendedError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return "You haven't claimed this homework yet."
|
||||
|
||||
|
||||
class TrainingRequirementNotSatisfiedError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
@@ -355,11 +331,6 @@ class UsageExceededError(ForbiddenError):
|
||||
def message(self):
|
||||
return 'Usage exceeded.'
|
||||
|
||||
class ModifyBuiltinRoleError(ForbiddenError):
|
||||
@property
|
||||
def message(self):
|
||||
return 'Built-in roles cannot be modified.'
|
||||
|
||||
|
||||
class InvalidArgumentError(BadRequestError):
|
||||
@property
|
||||
|
||||
Reference in new issue
Block a user