Skip to content
Snippets Groups Projects
Commit d8672ddf authored by Martin Mareš's avatar Martin Mareš
Browse files

S protokoly a body nelze pracovat, dokud je soutěž ve stavu přípravy

Zabraňuje například generování protokolů v situaci, kdy správce kola
ještě nenakonfiguroval úlohy.
parent f57c4690
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ class Right(Enum):
upload_solutions = auto() # Odevzdávat za účastníka ve stavu "running"
upload_feedback = auto() # Nahrávat opravené řešení ve stavu "grading"
view_submits = auto() # Prohlížet si řešení a opravy
upload_submits = auto() # Nahrávat řešení a opravy nezávisle na stavu soutěže
upload_submits = auto() # Nahrávat řešení a opravy kromě stavu "preparing"
edit_points = auto() # Přidělovat body ve stavu "grading"
view_statement = auto() # Prohlížet zadání, pokud je dostupné pro dozor
add_users = auto()
......@@ -291,32 +291,35 @@ class RoundRights(Rights):
def _get_state(self) -> db.RoundState:
return self.round.state
def _is_configured(self) -> bool:
return self._get_state() != db.RoundState.preparing
def _is_active(self) -> bool:
return self._get_state() not in [db.RoundState.preparing, db.RoundState.closed]
def offer_upload_solutions(self) -> bool:
return (self.have_right(Right.upload_submits)
return (self.have_right(Right.upload_submits) and self._is_configured()
or (self.have_right(Right.upload_solutions) and self._is_active()))
def offer_upload_feedback(self) -> bool:
return (self.have_right(Right.upload_submits)
return (self.have_right(Right.upload_submits) and self._is_configured()
or (self.have_right(Right.upload_feedback) and self._is_active()))
def offer_edit_points(self) -> bool:
return (self.have_right(Right.manage_contest)
return (self.have_right(Right.manage_contest) and self._is_configured()
or (self.have_right(Right.edit_points) and self._is_active()))
def can_upload_solutions(self) -> bool:
return (self.have_right(Right.upload_submits)
return (self.have_right(Right.upload_submits) and self._is_configured()
or self.have_right(Right.upload_solutions) and self._get_state() == db.RoundState.running)
def can_upload_feedback(self) -> bool:
return (self.have_right(Right.upload_submits)
return (self.have_right(Right.upload_submits) and self._is_configured()
or self.have_right(Right.upload_feedback) and self._get_state() == db.RoundState.grading)
def can_edit_points(self) -> bool:
return (self.have_right(Right.edit_points) and self._get_state() == db.RoundState.grading
or self.have_right(Right.manage_contest))
or self.have_right(Right.manage_contest) and self._is_configured())
def can_create_solutions(self) -> bool:
return self.can_upload_solutions() or self.can_upload_feedback()
......
......@@ -70,10 +70,8 @@
{% if not site and can_view_contestants and state in [RoundState.grading, RoundState.closed] %}
<a class="btn btn-primary" href='{{ ctx.url_for('org_score') }}'>Výsledky</a>
{% endif %}
{% if can_view_contestants %}
<a class="btn btn-default" href='{{ ctx.url_for('org_contest_protocols') }}'>Protokoly</a>
{% endif %}
{% if can_upload_anything %}
<a class="btn btn-default" href='{{ ctx.url_for('org_contest_protocols') }}'>Protokoly</a>
<a class="btn btn-default" href='{{ ctx.url_for('org_contest_scans') }}'>Zpracování skenů</a>
{% endif %}
{% if not site and can_manage %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment