From 04b60acbad3a730225427312227ef6ec41902c2d Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Tue, 29 Sep 2015 23:18:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=83=A8=E5=88=86=20model=20=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contest/models.py | 3 +++ group/models.py | 1 + problem/models.py | 1 + 3 files changed, 5 insertions(+) diff --git a/contest/models.py b/contest/models.py index 1e4f45aa..2708bcf4 100644 --- a/contest/models.py +++ b/contest/models.py @@ -120,6 +120,9 @@ class ContestRank(models.Model): # key 是比赛题目的id submission_info = JSONField(default={}) + class Meta: + db_table = "contest_rank" + def update_rank(self, submission): if not submission.contest_id or submission.contest_id != self.contest_id: raise ValueError("Error submission type") diff --git a/group/models.py b/group/models.py index b3992468..a2db074a 100644 --- a/group/models.py +++ b/group/models.py @@ -37,5 +37,6 @@ class JoinGroupRequest(models.Model): # 是否处理 status = models.BooleanField(default=False) accepted = models.BooleanField(default=False) + class Meta: db_table = "join_group_request" diff --git a/problem/models.py b/problem/models.py index adb7dd4d..331f003e 100644 --- a/problem/models.py +++ b/problem/models.py @@ -45,6 +45,7 @@ class AbstractProblem(models.Model): total_accepted_number = models.IntegerField(default=0) class Meta: + db_table = "problem" abstract = True From 246826139f0db41f3fe3ddf0e81ee23b9a3da3b4 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Wed, 30 Sep 2015 21:21:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20mq=20=E4=B8=AD?= =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E9=9D=9E=20ac=20=E7=9A=84=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mq/scripts/mq.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/mq/scripts/mq.py b/mq/scripts/mq.py index 47231da1..5e16edf5 100644 --- a/mq/scripts/mq.py +++ b/mq/scripts/mq.py @@ -39,20 +39,21 @@ class MessageQueue(object): logger.warning("Submission user does not exist, submission_id: " + submission_id) continue - if submission.result == result["accepted"] and not submission.contest_id: + if not submission.contest_id: # 更新普通题目的 ac 计数器 - try: - problem = Problem.objects.get(id=submission.problem_id) - problem.total_accepted_number += 1 - problem.save() - except Problem.DoesNotExist: - logger.warning("Submission problem does not exist, submission_id: " + submission_id) - continue + if submission.result == result["accepted"]: + try: + problem = Problem.objects.get(id=submission.problem_id) + problem.total_accepted_number += 1 + problem.save() + except Problem.DoesNotExist: + logger.warning("Submission problem does not exist, submission_id: " + submission_id) + continue - problems_status = user.problems_status - problems_status["problems"][str(problem.id)] = 1 - user.problems_status = problems_status - user.save() + problems_status = user.problems_status + problems_status["problems"][str(problem.id)] = 1 + user.problems_status = problems_status + user.save() # 普通题目的话,到这里就结束了 continue From 85ab5adfe629274ba782c9eb3c9a1f39e6d97364 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Thu, 8 Oct 2015 11:13:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20xss=20filter=20?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/xss_filter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/xss_filter.py b/utils/xss_filter.py index 825fbc97..337f0a5a 100644 --- a/utils/xss_filter.py +++ b/utils/xss_filter.py @@ -38,7 +38,7 @@ class XssHtml(HTMLParser): 'p', 'div', 'em', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'ul', 'ol', 'tr', 'th', 'td', 'hr', 'li', 'u', 'embed', 's', 'table', 'thead', 'tbody', - 'caption', 'small', 'q', 'sup', 'sub'] + 'caption', 'small', 'q', 'sup', 'sub', 'font'] common_attrs = ["style", "class", "name"] nonend_tags = ["img", "hr", "br", "embed"] tags_own_attrs = { @@ -46,6 +46,7 @@ class XssHtml(HTMLParser): "a": ["href", "target", "rel", "title"], "embed": ["src", "width", "height", "type", "allowfullscreen", "loop", "play", "wmode", "menu"], "table": ["border", "cellpadding", "cellspacing"], + "font": ["color"] } def __init__(self, allows=[]):