Skip to content

Commit

Permalink
fix(contest): sort account list
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichi3227 committed Sep 3, 2024
1 parent 818a136 commit 3ce5460
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/handlers/contests/manage/acct.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async def post(self):
self.contest.reg_list.remove(acct_id)

changed_list.append(acct_id)
changed_list.sort()
await ContestService.inst.update_contest(self.acct, self.contest)
await self.finish('S')

Expand All @@ -79,6 +80,7 @@ async def post(self):
return

changed_list.remove(acct_id)
changed_list.sort()
await ContestService.inst.update_contest(self.acct, self.contest)
await self.finish('S')

Expand Down
2 changes: 0 additions & 2 deletions src/handlers/contests/manage/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async def post(self):

if reqtype == "update":
name = self.get_argument("name")
desc = self.get_argument("desc")

contest_mode = ContestMode(int(self.get_argument("contest_mode")))
contest_start = self.get_argument("contest_start")
Expand Down Expand Up @@ -74,7 +73,6 @@ async def post(self):
return

self.contest.name = name
self.contest.desc = desc

self.contest.contest_mode = contest_mode
self.contest.contest_start = contest_start
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/contests/manage/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ContestManageGeneralHandler,
ContestManageAddHandler,
ContestManageDashHandler,
ContestManageDescEditHandler,
)
from handlers.contests.manage.pro import ContestManageProHandler
from handlers.contests.manage.reg import ContestManageRegHandler
Expand All @@ -19,6 +20,7 @@ def get_contests_manage_url(db, rs, pool):
(r'/contests/\d+/manage', ContestManageDashHandler, args),
(r'/contests/\d+/manage/dash', ContestManageDashHandler, args),
(r'/contests/\d+/manage/general', ContestManageGeneralHandler, args),
(r'/contests/\d+/manage/desc', ContestManageDescEditHandler, args),
(r'/contests/\d+/manage/acct', ContestManageAcctHandler, args),
(r'/contests/\d+/manage/pro', ContestManageProHandler, args),
(r'/contests/\d+/manage/reg', ContestManageRegHandler, args),
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async def post(self):
self.error(err)
return

if reqtype == 'submit' and pro['status'] == [ProService.STATUS_ONLINE, ProService.STATUS_CONTEST]:
if reqtype == 'submit' and pro['status'] in [ProService.STATUS_ONLINE, ProService.STATUS_CONTEST]:
await self.rs.publish('challist_sub', 1)

self.finish(json.dumps(chal_id))
Expand Down
10 changes: 8 additions & 2 deletions src/static/templ/chal.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@

{% if rechal == True %}
$('#rechal').on('click', function(e) {
$.post('/oj/be/submit', {
let url = '';
{% if chal['contest_id'] == 0 %}
url = '/oj/be/submit';
{% else %}
url = '/oj/be/contests/{{ chal['contest_id'] }}/submit';
{% end %}
$.post(url, {
'reqtype': 'rechal',
'chal_id': chal_id,
}, function(res) {
Expand All @@ -72,7 +78,7 @@
return;

}

res = JSON.parse(res);
let code = $("#code");
code.attr("data-language", res.comp_type);
Expand Down
10 changes: 6 additions & 4 deletions src/static/templ/contests/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
let desc_tex = `{% raw contest.desc_after_contest.replace('\\', '\\\\').replace('`', '\\`') %}`;
{% end %}

let descEle = document.getElementById('desc');
descEle.innerHTML = DOMPurify.sanitize(marked.parse(desc_tex));
MathJax.Hub.Queue(["Typeset",MathJax.Hub, descEle]);
}
</script>

<div class="row">
<h1>{{ contest.name }}</h1>
Expand Down Expand Up @@ -97,9 +102,6 @@ <h5>Not Registered</h5>
</div>
</div>

<div class="col-lg-10 col-12">
<!-- TODO: desc 支援 markdown -->
<p style="white-space: pre-line;">{{ contest.desc }}</p>
</div>
<div class="col-lg-10 col-12" id="desc"></div>
</div>
</div>
15 changes: 3 additions & 12 deletions src/static/templ/contests/manage/general.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
$("button.submit").on('click', function(e) {
let start_time = null, end_time = null, reg_end_time = null;
let contest_name = $("#contestName").val();
let contest_desc = $("#contestDesc").val();
let contest_mode = $("#contestMode").val();
let reg_mode = $("#regMode").val();
let submit_cd_time = parseInt($("#submitCdTime").val());
Expand Down Expand Up @@ -75,7 +74,7 @@
}

reg_end_time = reg_end_date_picker.viewDate;

if (isNaN(submit_cd_time) || submit_cd_time < 0) {
index.show_notify_dialog("Submission CD Time必須是正整數(包含0)", index.DIALOG_TYPE.warning);
return;
Expand All @@ -86,7 +85,6 @@
$.post("/oj/be/contests/{{ contest_id }}/manage/general", {
reqtype: "update",
name: contest_name,
desc: contest_desc,

contest_mode: contest_mode,
contest_start: start_time.toISOString(),
Expand Down Expand Up @@ -252,7 +250,7 @@ <h4 for="" class="form-label">Limits</h4>
</div>

<div class="form-check form-check-inline">
<input class="form-check-input compilers" type="checkbox" id="inlineCheckbox5" value="python3"{% if 'python' in contest.allow_compilers %} checked {% end %}>
<input class="form-check-input compilers" type="checkbox" id="inlineCheckbox5" value="python3"{% if 'python3' in contest.allow_compilers %} checked {% end %}>
<label class="form-check-label" for="inlineCheckbox5">CPython 3.11</label>
</div>

Expand All @@ -267,16 +265,9 @@ <h4 for="" class="form-label">Limits</h4>
</div>
</div>

<!-- TODO: desc 支援 markdown -->
<!-- TODO: desc markdown 預覽 -->
<div class="mb-1">
<label for="contestDesc" class="form-label">Contest Desc</label>
<textarea id="contestDesc" class="form-control">{{ contest.desc }}</textarea>
</div>

<button class="btn btn-primary submit">Update</button>

</div>


{% end %}
{% end %}
1 change: 1 addition & 0 deletions src/static/templ/contests/manage/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<nav class="nav nav-pills">
<a href="/oj/contests/{{ contest_id }}/manage/dash/" class="nav-link {% if page == 'dash' %} active{% end %}">Dashboard</a>
<a href="/oj/contests/{{ contest_id }}/manage/general/" class="nav-link {% if page == 'general' %} active{% end %}">General</a>
<a href="/oj/contests/{{ contest_id }}/manage/desc/" class="nav-link {% if page == 'desc' %} active{% end %}">DescEdit</a>
<a href="/oj/contests/{{ contest_id }}/manage/acct/" class="nav-link {% if page == 'acct' %} active{% end %}">Account</a>
<a href="/oj/contests/{{ contest_id }}/manage/pro/" class="nav-link {% if page == 'pro' %} active{% end %}">Problem</a>
<a href="/oj/contests/{{ contest_id }}/manage/reg/" class="nav-link {% if page == 'reg' %} active{% end %}">Registration</a>
Expand Down

0 comments on commit 3ce5460

Please sign in to comment.