diff --git a/contest/models.py b/contest/models.py index 1e4f45a..2708bcf 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 b399246..a2db074 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/mq/scripts/mq.py b/mq/scripts/mq.py index 47231da..5e16edf 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 diff --git a/problem/models.py b/problem/models.py index adb7dd4..331f003 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 diff --git a/utils/xss_filter.py b/utils/xss_filter.py index 825fbc9..337f0a5 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=[]):