Accept Merge Request #270 dev -> master : (dev -> master)

Merge Request: dev -> master
Created By: @virusdefender
Accepted By: @virusdefender
URL: https://coding.net/u/virusdefender/p/qduoj/git/merge/270
This commit is contained in:
virusdefender
2015-10-08 11:35:12 +08:00
5 changed files with 20 additions and 13 deletions

View File

@@ -120,6 +120,9 @@ class ContestRank(models.Model):
# key 是比赛题目的id # key 是比赛题目的id
submission_info = JSONField(default={}) submission_info = JSONField(default={})
class Meta:
db_table = "contest_rank"
def update_rank(self, submission): def update_rank(self, submission):
if not submission.contest_id or submission.contest_id != self.contest_id: if not submission.contest_id or submission.contest_id != self.contest_id:
raise ValueError("Error submission type") raise ValueError("Error submission type")

View File

@@ -37,5 +37,6 @@ class JoinGroupRequest(models.Model):
# 是否处理 # 是否处理
status = models.BooleanField(default=False) status = models.BooleanField(default=False)
accepted = models.BooleanField(default=False) accepted = models.BooleanField(default=False)
class Meta: class Meta:
db_table = "join_group_request" db_table = "join_group_request"

View File

@@ -39,20 +39,21 @@ class MessageQueue(object):
logger.warning("Submission user does not exist, submission_id: " + submission_id) logger.warning("Submission user does not exist, submission_id: " + submission_id)
continue continue
if submission.result == result["accepted"] and not submission.contest_id: if not submission.contest_id:
# 更新普通题目的 ac 计数器 # 更新普通题目的 ac 计数器
try: if submission.result == result["accepted"]:
problem = Problem.objects.get(id=submission.problem_id) try:
problem.total_accepted_number += 1 problem = Problem.objects.get(id=submission.problem_id)
problem.save() problem.total_accepted_number += 1
except Problem.DoesNotExist: problem.save()
logger.warning("Submission problem does not exist, submission_id: " + submission_id) except Problem.DoesNotExist:
continue logger.warning("Submission problem does not exist, submission_id: " + submission_id)
continue
problems_status = user.problems_status problems_status = user.problems_status
problems_status["problems"][str(problem.id)] = 1 problems_status["problems"][str(problem.id)] = 1
user.problems_status = problems_status user.problems_status = problems_status
user.save() user.save()
# 普通题目的话,到这里就结束了 # 普通题目的话,到这里就结束了
continue continue

View File

@@ -45,6 +45,7 @@ class AbstractProblem(models.Model):
total_accepted_number = models.IntegerField(default=0) total_accepted_number = models.IntegerField(default=0)
class Meta: class Meta:
db_table = "problem"
abstract = True abstract = True

View File

@@ -38,7 +38,7 @@ class XssHtml(HTMLParser):
'p', 'div', 'em', 'span', 'h1', 'h2', 'h3', 'h4', 'p', 'div', 'em', 'span', 'h1', 'h2', 'h3', 'h4',
'h5', 'h6', 'blockquote', 'ul', 'ol', 'tr', 'th', 'td', 'h5', 'h6', 'blockquote', 'ul', 'ol', 'tr', 'th', 'td',
'hr', 'li', 'u', 'embed', 's', 'table', 'thead', 'tbody', 'hr', 'li', 'u', 'embed', 's', 'table', 'thead', 'tbody',
'caption', 'small', 'q', 'sup', 'sub'] 'caption', 'small', 'q', 'sup', 'sub', 'font']
common_attrs = ["style", "class", "name"] common_attrs = ["style", "class", "name"]
nonend_tags = ["img", "hr", "br", "embed"] nonend_tags = ["img", "hr", "br", "embed"]
tags_own_attrs = { tags_own_attrs = {
@@ -46,6 +46,7 @@ class XssHtml(HTMLParser):
"a": ["href", "target", "rel", "title"], "a": ["href", "target", "rel", "title"],
"embed": ["src", "width", "height", "type", "allowfullscreen", "loop", "play", "wmode", "menu"], "embed": ["src", "width", "height", "type", "allowfullscreen", "loop", "play", "wmode", "menu"],
"table": ["border", "cellpadding", "cellspacing"], "table": ["border", "cellpadding", "cellspacing"],
"font": ["color"]
} }
def __init__(self, allows=[]): def __init__(self, allows=[]):