From 2760c6233df5e24b94fe31f47a52d8776596664b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pracha=C5=99?= <jan.prachar@gmail.com>
Date: Fri, 19 Mar 2021 17:14:14 +0100
Subject: [PATCH] =?UTF-8?q?org=5Fcontest:=20Tla=C4=8D=C3=ADtko=20na=20p?=
 =?UTF-8?q?=C5=99epnut=C3=AD=20stavu=20sout=C4=9B=C5=BEe?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 mo/web/org_contest.py             |  1 +
 mo/web/templates/org_contest.html | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/mo/web/org_contest.py b/mo/web/org_contest.py
index 367ef536..e3df79d5 100644
--- a/mo/web/org_contest.py
+++ b/mo/web/org_contest.py
@@ -373,6 +373,7 @@ def org_contest(id: int, site_id: Optional[int] = None):
         can_create_solutions=rr.can_upload_feedback() or rr.can_upload_solutions(),
         can_view_statement=rr.can_view_statement(),
         tasks=tasks, places_counts=places_counts,
+        edit_form=ContestEditForm(obj=contest),
     )
 
 
diff --git a/mo/web/templates/org_contest.html b/mo/web/templates/org_contest.html
index 2675f9e0..af224f5a 100644
--- a/mo/web/templates/org_contest.html
+++ b/mo/web/templates/org_contest.html
@@ -19,7 +19,22 @@
 	{% with state=contest.state %}
 	<tr><td>Stav<td><span class='rstate-{{state.name}}'>{{ state.friendly_name() }}</span>
 		{% if round.state != RoundState.delegate %}
-		(určeno nastavením kola)
+			(určeno nastavením kola)
+		{% elif can_manage and not site %}
+			{% if state == RoundState.running %}
+			<form method="post" action="{{ url_for('org_contest_edit', id=contest.contest_id) }}" style="display: inline-block">
+				{{ edit_form.csrf_token }}
+				<button type="submit" class="btn btn-sm btn-default">Změnit na: opravuje se</button>
+				<input type="hidden" name="state" value="{{ RoundState.grading.name }}">
+			</form>
+			{% elif state == RoundState.grading %}
+			<form method="post" action="{{ url_for('org_contest_edit', id=contest.contest_id) }}" style="display: inline-block">
+				{{ edit_form.csrf_token }}
+				<button type="submit" class="btn btn-sm btn-default">Změnit na: ukončeno</button>
+				<input type="hidden" name="state" value="{{ RoundState.closed.name }}">
+			</form>
+			{% endif %}
+		{% else %}
 		{% endif %}
 	{% endwith %}
 	{% with state=contest.ct_state() %}
-- 
GitLab