使用新的生成比赛排名的方式
This commit is contained in:
@@ -14,4 +14,8 @@ class RichTextField(models.TextField):
|
||||
parser = XssHtml()
|
||||
parser.feed(value)
|
||||
parser.close()
|
||||
return parser.getHtml()
|
||||
return parser.getHtml()
|
||||
|
||||
|
||||
class JsonField(models.TextField):
|
||||
pass
|
||||
@@ -100,5 +100,5 @@ def paginate(request, query_set, object_serializer):
|
||||
|
||||
|
||||
def rand_str(length=32):
|
||||
string = hashlib.md5(str(time.time()) + str(random.randrange(1, 9999999900))).hexdigest()
|
||||
string = hashlib.md5(str(time.time()) + str(random.randrange(1, 987654321234567))).hexdigest()
|
||||
return string[0:length]
|
||||
@@ -23,9 +23,50 @@ def get_contest_status_color(contest):
|
||||
return "success"
|
||||
|
||||
|
||||
def get_the_formatted_time(seconds):
|
||||
if not seconds:
|
||||
return ""
|
||||
seconds = int(seconds)
|
||||
hour = seconds / (60 * 60)
|
||||
minute = (seconds - hour * 60 * 60) / 60
|
||||
second = seconds - hour * 60 * 60 - minute * 60
|
||||
return str(hour) + ":" + str(minute) + ":" + str(second)
|
||||
|
||||
|
||||
def get_submission_class(rank, problem):
|
||||
if str(problem.id) not in rank.submission_info:
|
||||
return ""
|
||||
else:
|
||||
submission = rank.submission_info[str(problem.id)]
|
||||
if submission["is_ac"]:
|
||||
_class = "alert-success"
|
||||
if submission["is_first_ac"]:
|
||||
_class += " first-achieved"
|
||||
else:
|
||||
_class = "alert-danger"
|
||||
return _class
|
||||
|
||||
|
||||
def get_submission_content(rank, problem):
|
||||
if str(problem.id) not in rank.submission_info:
|
||||
return ""
|
||||
else:
|
||||
submission = rank.submission_info[str(problem.id)]
|
||||
if submission["is_ac"]:
|
||||
r = get_the_formatted_time(submission["ac_time"])
|
||||
if submission["error_number"]:
|
||||
r += "(-" + str(submission["error_number"]) + ")"
|
||||
return r
|
||||
else:
|
||||
return "(-" + str(submission["error_number"]) + ")"
|
||||
|
||||
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
register.filter("contest_status", get_contest_status)
|
||||
register.filter("contest_status_color", get_contest_status_color)
|
||||
register.filter("format_seconds", get_the_formatted_time)
|
||||
register.simple_tag(get_submission_class, name="get_submission_class")
|
||||
register.simple_tag(get_submission_content, name="get_submission_content")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user