Skip to content
Snippets Groups Projects
Commit b0871a17 authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Odkaz na stránku účastníka v soutěži ze stránek soutěže

Přidán globální Jinja filter pion_link(contest_id) a také typ odkazu do
mo.web.table.
parent 72ae40ef
Branches
No related tags found
1 merge request!24Stránka účastníka v soutěži
......@@ -53,6 +53,12 @@ def user_link(u: db.User) -> Markup:
return Markup('<a href="{url}">{name}{test}</a>').format(url=url, name=u.full_name(), test=" (test)" if u.is_test else "")
@app.template_filter()
def pion_link(u: db.User, contest_id: int) -> Markup:
url = url_for('org_contest_user', contest_id=contest_id, user_id=u.user_id)
return Markup('<a href="{url}">{name}{test}</a>').format(url=url, name=u.full_name(), test=" (test)" if u.is_test else "")
@app.template_filter()
def or_dash(s: Any) -> str:
return str(s) if s else ''
......@@ -20,7 +20,7 @@ from mo.util_format import inflect_number
from mo.web import app
import mo.web.util
from mo.web.util import PagerForm
from mo.web.table import CellCheckbox, Table, Row, Column, cell_place_link, cell_user_link, cell_email_link
from mo.web.table import CellCheckbox, Table, Row, Column, cell_pion_link, cell_place_link, cell_email_link
import wtforms.validators as validators
......@@ -480,8 +480,8 @@ def make_contestant_table(query: Query, add_checkbox: bool = False, add_contest_
rows.append(Row(
keys={
'sort_key': u.sort_key(),
'first_name': cell_user_link(u, u.first_name),
'last_name': cell_user_link(u, u.last_name),
'first_name': cell_pion_link(u, pion.contest_id, u.first_name),
'last_name': cell_pion_link(u, pion.contest_id, u.last_name),
'email': cell_email_link(u),
'school': pant.school_place.name,
'school_code': cell_place_link(pant.school_place, pant.school_place.get_code()),
......
......@@ -5,10 +5,11 @@ from sqlalchemy.orm import joinedload
from typing import List, Tuple, Optional, Dict
import werkzeug.exceptions
import mo
import mo.db as db
from mo.rights import Right
from mo.web import app
from mo.web.table import Cell, CellLink, Column, Row, Table, cell_user_link
from mo.web.table import Cell, CellLink, Column, Row, Table, cell_pion_link
class OrderCell(Cell):
......@@ -164,7 +165,7 @@ def org_score(round_id: Optional[int] = None, contest_id: Optional[int] = None):
row = Row(keys={
'user': user,
'email': user.email,
'participant': cell_user_link(user, user.full_name()),
'participant': cell_pion_link(user, pion.contest_id, user.full_name()),
'contest': CellLink(pion.contest.place.name, url_for('org_contest', id=pion.contest_id)),
'pion_place': pion.place.name,
'school': CellLink(school.name, url_for('org_place', id=school.place_id)),
......
......@@ -189,5 +189,9 @@ def cell_user_link(user: db.User, text: str) -> CellLink:
return CellLink(text, url_for('org_user', id=user.user_id))
def cell_pion_link(user: db.User, contest_id: int, text: str) -> CellLink:
return CellLink(text, url_for('org_contest_user', contest_id=contest_id, user_id=user.user_id))
def cell_place_link(place: db.Place, text: str) -> CellLink:
return CellLink(text, url_for('org_place', id=place.place_id), hint=place.name)
......@@ -43,7 +43,7 @@ konkrétní úlohu. Symbol <b>+</b> značí, že existuje více verzí dostupný
{% for pion in pions %}
{% set u = pion.user %}
<tr{% if u.is_test %} class="testuser" title="Testovací uživatel"{% endif %}>
<th><a href="{{ url_for('org_user', id=u.user_id) }}">{{ u.full_name() }}</a></th>
<th>{{ u|pion_link(pion.contest_id) }}
{% set sum_points = [] %}
{% for task in tasks %}
{% if u.user_id in tasks_sols[task.task_id] %}
......
......@@ -2,14 +2,14 @@
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Řešení {{ sc.task.code }} {{ sc.task.name }} &ndash; {{ sc.user.full_name() }}{% endblock %}
{% block breadcrumbs %}
{{ contest_breadcrumbs(round=sc.round, contest=sc.contest, site=sc.site, task=sc.task, action=sc.user.full_name()) | safe }}
{{ contest_breadcrumbs(round=sc.round, contest=sc.contest, site=sc.site, task=sc.task, user=sc.user, action="Detail řešení") | safe }}
{% endblock %}
{% block body %}
{% set site_id = sc.site.place_id if sc.site else None %}
<table class="data">
<tr><th>Účastník<td>{{ sc.user|user_link }}
<tr><th>Účastník<td>{{ sc.user|pion_link(sc.contest.contest_id) }}
<tr><th>Úloha<td><a href='{{ url_for('org_contest_task', contest_id=sc.contest.contest_id, site_id=site_id, task_id=sc.task.task_id) }}'>{{ sc.task.code }} {{ sc.task.name }}</a>
{% if solution %}
<tr><th>Body<td>{% if solution.points is not none %}{{solution.points}}{% else %}<span class="unknown">?</span>{% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment