From ea46551c7e1e66d70af58c7480b738ea7e42d003 Mon Sep 17 00:00:00 2001 From: masnn0 <50578964+masnn0@users.noreply.github.com> Date: Sat, 27 Jun 2020 03:40:45 +0800 Subject: [PATCH] Ranking (#513) --- vj4/handler/user.py | 17 ++++++++++ vj4/locale/en.yaml | 1 + vj4/locale/zh_CN.yaml | 3 +- vj4/ui/pages/domain_ranking.page.styl | 20 ++++++++++++ vj4/ui/templates/domain_ranking.html | 47 +++++++++++++++++++++++++++ vj4/ui/templates/partials/nav.html | 3 ++ 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 vj4/ui/pages/domain_ranking.page.styl create mode 100644 vj4/ui/templates/domain_ranking.html diff --git a/vj4/handler/user.py b/vj4/handler/user.py index 812b375d8..8798ebab9 100644 --- a/vj4/handler/user.py +++ b/vj4/handler/user.py @@ -15,6 +15,7 @@ from vj4.model.adaptor import setting from vj4.util import misc from vj4.util import options +from vj4.util import pagination from vj4.util import validator from vj4.handler import base @@ -253,3 +254,19 @@ async def get(self, *, q: str, exact_match: bool=False): for i in range(len(udocs)): self.modify_udoc(udocs, i) self.json(udocs) + + +@app.route('/ranking', 'domain_ranking') +class RankHandler(base.Handler): + USERS_PER_PAGE = 100 + + @base.require_priv(builtin.PRIV_USER_PROFILE) + @base.get_argument + @base.route_argument + @base.sanitize + async def get(self, *, page: int=1): + dudocs, dupcount, _ = await pagination.paginate( + domain.get_multi_user(domain_id=self.domain_id, rp={'$gt': 0.0}).sort([('rank', 1)]), + page, self.USERS_PER_PAGE) + udict = await user.get_dict(dudoc['uid'] for dudoc in dudocs) + self.render('domain_ranking.html', page=page, dupcount=dupcount, dudocs=dudocs, udict=udict) diff --git a/vj4/locale/en.yaml b/vj4/locale/en.yaml index a50778203..213994878 100644 --- a/vj4/locale/en.yaml +++ b/vj4/locale/en.yaml @@ -49,6 +49,7 @@ user_lostpass: Lost Password user_register: Register home_domain_create: Create Domain domain_main: Main +domain_ranking: Ranking domain_manage: Domain Manage domain_manage_dashboard: Dashboard domain_manage_discussion: Discussion Nodes diff --git a/vj4/locale/zh_CN.yaml b/vj4/locale/zh_CN.yaml index e86f1d863..bc8c37ddf 100644 --- a/vj4/locale/zh_CN.yaml +++ b/vj4/locale/zh_CN.yaml @@ -309,6 +309,7 @@ Create Domain: 创建域 Properties: 属性 Access Control: 访问控制 domain_main: 首页 +domain_ranking: 排名 domain_manage: 管理域 domain_manage_dashboard: 概况 domain_manage_discussion: 讨论节点 @@ -792,4 +793,4 @@ What's this?: 这是什么? About test data: 关于测试数据 With this feature, you can copy problems that you can view from a domain to some other domain. Their title, content, tags and categories will be copied. However, their test data are not copied directly.: 您可以通过这个功能将某域下您能查看的题目复制到其它域中,题目的标题、描述、标签与分类将被复制过来。但是测试数据不会被直接复制。 Instead of copying the test data directly, the test data of the copied problems will be linked to the test data of the source problems (called the source test data). Thus, the copied problems can observe the changes in the source test data. The permissions of the test data of the copied problems follow the source test data, e.g., you still might not download them but the judges can. By uploading some new test data, the link will be broken and the new test data will be used.: 虽然测试数据不会被复制,但是系统会将题目的测试数据链接到原题。因此在原题的数据被改动的时候,复制后的题目的数据也会同时改动。链接后的测试数据的权限以原题为准,比如您可能依旧无法下载数据,但是评测机可以。在题目设置页面中可以通过上传新的测试数据的方式,这个数据链接会被删除,以后将使用您的新测试数据。 -This message will be presented to those whose submissions are accepted.: 这条消息将会被展示给通过此题的用户。 \ No newline at end of file +This message will be presented to those whose submissions are accepted.: 这条消息将会被展示给通过此题的用户。 diff --git a/vj4/ui/pages/domain_ranking.page.styl b/vj4/ui/pages/domain_ranking.page.styl new file mode 100644 index 000000000..a8e4e0a06 --- /dev/null +++ b/vj4/ui/pages/domain_ranking.page.styl @@ -0,0 +1,20 @@ +.page--domain_ranking + .col--rank + width: rem(90px) + border-right: 1px solid $table-border-color + text-align: center + + .col--user + width: rem(260px) + border-right: 1px solid $table-border-color + + .col--rp + width: rem(80px) + border-right: 1px solid $table-border-color + text-align: center + + .col--accept + width: rem(80px) + border-right: 1px solid $table-border-color + text-align: center + diff --git a/vj4/ui/templates/domain_ranking.html b/vj4/ui/templates/domain_ranking.html new file mode 100644 index 000000000..016b9e757 --- /dev/null +++ b/vj4/ui/templates/domain_ranking.html @@ -0,0 +1,47 @@ +{% extends "layout/basic.html" %} +{% import "components/paginator.html" as paginator with context %} +{% import "components/nothing.html" as nothing with context %} +{% block content %} +
{{ _('Rank') }} | +{{ _('User') }} | +{{ _('RP') }} | +{{ _('Accepted') }} | +{{ _('Bio') }} | +
---|---|---|---|---|
{{ dudoc['rank'] }} | +{{ user.render_inline(udict[dudoc['uid']], dudoc=dudoc) }} | +{{ dudoc['rp']|default(0.0)|round(2) }} | +{{ dudoc['num_accept']|default(0) }} | +{{ udict[dudoc['uid']]['bio']|default('')|markdown }} | +