增加查看指定的人提交的功能

This commit is contained in:
virusdefender 2016-05-30 15:08:21 +08:00
parent df4db5141f
commit c30c3f3528
No known key found for this signature in database
GPG Key ID: 1686FB5677979E61
2 changed files with 30 additions and 25 deletions

View File

@ -243,28 +243,34 @@ def submission_list_page(request, page=1):
""" """
所有提交的列表页 所有提交的列表页
""" """
submission_filter = {"my": None, "user_id": None}
# 是否显示所有人的提交 # 是否显示所有人的提交
show_all = False show_all = False
submission_filter = {"my": None}
# 兼容部分版本,设置中没有这一项 # url中如果存在user_id参数,说明只显示这个人的提交,忽略其他参数
try: user_id = request.GET.get("user_id", None)
show_all = settings.SHOW_ALL_SUBMISSIONS_LIST if user_id and request.user.admin_type == SUPER_ADMIN:
except Exception: submission_filter["user_id"] = user_id
pass submissions = Submission.objects.filter(user_id=user_id, contest_id__isnull=True)
# url中my=true可以只显示自己的
if request.GET.get("my", None) == "true":
submission_filter["my"] = "true"
show_all = False
if show_all:
submissions = Submission.objects.filter(contest_id__isnull=True)
else: else:
submissions = Submission.objects.filter(user_id=request.user.id, contest_id__isnull=True) # 兼容部分版本,设置中没有这一项
try:
show_all = settings.SHOW_ALL_SUBMISSIONS_LIST
except Exception:
pass
submissions = submissions.values("id", "user_id", "problem_id", "result", "create_time", "accepted_answer_time", # url中my=true可以只显示自己的
"language").order_by("-create_time") if request.GET.get("my", None) == "true":
submission_filter["my"] = "true"
show_all = False
if show_all:
submissions = Submission.objects.filter(contest_id__isnull=True)
else:
submissions = Submission.objects.filter(user_id=request.user.id, contest_id__isnull=True)
submissions = submissions.values("id", "user_id", "problem_id", "result", "create_time",
"accepted_answer_time", "language").order_by("-create_time")
language = request.GET.get("language", None) language = request.GET.get("language", None)
if language: if language:
@ -291,12 +297,11 @@ def submission_list_page(request, page=1):
cache_result["problem"][problem_id] = problem.title cache_result["problem"][problem_id] = problem.title
item["title"] = cache_result["problem"][problem_id] item["title"] = cache_result["problem"][problem_id]
if show_all: user_id = item["user_id"]
user_id = item["user_id"] if user_id not in cache_result["user"]:
if user_id not in cache_result["user"]: user = User.objects.get(id=user_id)
user = User.objects.get(id=user_id) cache_result["user"][user_id] = user
cache_result["user"][user_id] = user item["user"] = cache_result["user"][user_id]
item["user"] = cache_result["user"][user_id]
if item["user_id"] == request.user.id or request.user.admin_type == SUPER_ADMIN: if item["user_id"] == request.user.id or request.user.admin_type == SUPER_ADMIN:
item["show_link"] = True item["show_link"] = True

View File

@ -10,7 +10,7 @@
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
{% if show_all %}<th>用户</th>{% endif %} <th>用户</th>
<th>题目名称</th> <th>题目名称</th>
<th>提交时间</th> <th>提交时间</th>
<th> <th>
@ -58,7 +58,7 @@
{{ forloop.counter |add:start_id }} {{ forloop.counter |add:start_id }}
{% endif %} {% endif %}
</th> </th>
{% if show_all %}<td><a href="/user/{{ item.user.username }}">{{ item.user.username }}</a></td>{% endif %} <td><a href="/user/{{ item.user.username }}">{{ item.user.username }}</a></td>
<td> <td>
<a href="/problem/{{ item.problem_id }}/">{{ item.title }}</a> <a href="/problem/{{ item.problem_id }}/">{{ item.title }}</a>
</td> </td>