Skip to content
Snippets Groups Projects
Commit 552bb0c6 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Použití user_html_flags.

Nahrazuje stávající manuální vytváření hvězdiček pro neaktivní
uživatele a podbarvení testuserů.
parent caf0498f
No related branches found
No related tags found
1 merge request!82Označení neaktivovaných účtů -- vytvoření user_html_flags
...@@ -25,7 +25,7 @@ from mo.util_format import inflect_number, inflect_by_number ...@@ -25,7 +25,7 @@ from mo.util_format import inflect_number, inflect_by_number
from mo.web import app from mo.web import app
import mo.web.util import mo.web.util
from mo.web.util import MODecimalField, PagerForm from mo.web.util import MODecimalField, PagerForm
from mo.web.table import CellCheckbox, Table, Row, Column, cell_pion_link, cell_place_link, cell_email_link from mo.web.table import CellCheckbox, Table, Row, Column, cell_pion_link, cell_place_link, cell_email_link, cell_email_link_flags, CellMarkup
import wtforms.validators as validators import wtforms.validators as validators
from wtforms.widgets.html5 import NumberInput from wtforms.widgets.html5 import NumberInput
...@@ -551,16 +551,13 @@ def make_contestant_table(query: Query, round: db.Round, add_checkbox: bool = Fa ...@@ -551,16 +551,13 @@ def make_contestant_table(query: Query, round: db.Round, add_checkbox: bool = Fa
html_attr = { html_attr = {
'class': 'state-' + pion.state.name 'class': 'state-' + pion.state.name
} }
if u.is_test:
html_attr['class'] += ' testuser'
html_attr['title'] = 'Testovací uživatel'
rows.append(Row( rows.append(Row(
keys={ keys={
'sort_key': u.sort_key(), 'sort_key': u.sort_key(),
'user_id': u.user_id, 'user_id': u.user_id,
'first_name': cell_pion_link(u, pion.contest_id, u.first_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), 'last_name': cell_pion_link(u, pion.contest_id, u.last_name),
'email': cell_email_link(u), 'email': cell_email_link_flags(u),
'school': pant.school_place.name, 'school': pant.school_place.name,
'school_code': cell_place_link(pant.school_place, pant.school_place.get_code()), 'school_code': cell_place_link(pant.school_place, pant.school_place.get_code()),
'grade': pant.grade, 'grade': pant.grade,
......
...@@ -11,6 +11,7 @@ import werkzeug.exceptions ...@@ -11,6 +11,7 @@ import werkzeug.exceptions
from mo.csv import FileFormat from mo.csv import FileFormat
import mo.db as db import mo.db as db
from mo.web import app from mo.web import app
from mo.web.util import user_html_flags
@dataclass @dataclass
...@@ -200,6 +201,9 @@ class Table: ...@@ -200,6 +201,9 @@ class Table:
def cell_email_link(user: db.User) -> CellLink: def cell_email_link(user: db.User) -> CellLink:
return CellLink(user.email, 'mailto:' + urllib.parse.quote(user.email, safe='@')) return CellLink(user.email, 'mailto:' + urllib.parse.quote(user.email, safe='@'))
def cell_email_link_flags(user: db.User) -> CellLink:
return CellLink(user.email, 'mailto:' + urllib.parse.quote(user.email, safe='@'), html_suffix=user_html_flags(user))
def cell_user_link(user: db.User, text: str) -> CellLink: def cell_user_link(user: db.User, text: str) -> CellLink:
return CellLink(text, url_for('org_user', id=user.user_id)) return CellLink(text, url_for('org_user', id=user.user_id))
......
...@@ -61,7 +61,7 @@ konkrétní úlohu. Symbol <span class="icon">🗐</span> značí, že existuje ...@@ -61,7 +61,7 @@ konkrétní úlohu. Symbol <span class="icon">🗐</span> značí, že existuje
</thead> </thead>
{% for pion in pions %} {% for pion in pions %}
{% set u = pion.user %} {% set u = pion.user %}
<tr class="state-{{ pion.state.name }}{% if u.is_test %} testuser{% endif %}" {% if u.is_test %}title="Testovací uživatel"{% endif %}> <tr class="state-{{ pion.state.name }}>
<th>{{ u|pion_link(contest.contest_id) }} <th>{{ u|pion_link(contest.contest_id) }}
<td>{{ pion.state.friendly_name() }} <td>{{ pion.state.friendly_name() }}
{% set sum_points = [] %} {% set sum_points = [] %}
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</thead> </thead>
<tr><td>Jméno:<td>{{ user.first_name }} <tr><td>Jméno:<td>{{ user.first_name }}
<tr><td>Příjmení:<td>{{ user.last_name }} <tr><td>Příjmení:<td>{{ user.last_name }}
<tr><td>E-mail:<td>{{ user.email|mailto }} <tr><td>E-mail:<td>{{ user.email|mailto }}{{ user|user_flags }}
<tr><td>Škola:<td><a href='{{ url_for('org_place', id=pant.school) }}'>{{ pant.school_place.name }}</a> <tr><td>Škola:<td><a href='{{ url_for('org_place', id=pant.school) }}'>{{ pant.school_place.name }}</a>
<tr><td>Třída:<td>{{ pant.grade }} <tr><td>Třída:<td>{{ pant.grade }}
<tr><td>Rok narození:<td>{{ pant.birth_year }} <tr><td>Rok narození:<td>{{ pant.birth_year }}
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
{% for user in users %} {% for user in users %}
<tr> <tr>
<td>{{ user.first_name }}</td><td>{{ user.last_name }}</td> <td>{{ user.first_name }}</td><td>{{ user.last_name }}</td>
<td>{{ user.email|mailto }}{% if user.password_hash == None %}<span class="user-inactive" title='Účet dosud nebyl aktivován'> *</span>{% endif %}</td> <td>{{ user.email|mailto }}{{ user|user_flags }}</td>
<td>{% if user.is_admin %}správce{% elif user.roles|count == 0 %}<i>žádná role</i>{% else %} <td>{% if user.is_admin %}správce{% elif user.roles|count == 0 %}<i>žádná role</i>{% else %}
<ul> <ul>
{% for role in user.roles %} {% for role in user.roles %}
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{% set site_id = sc.site.place_id if sc.site else None %} {% set site_id = sc.site.place_id if sc.site else None %}
<table class="data"> <table class="data">
<tr><th>Účastník<td>{{ sc.user|pion_link(sc.contest.contest_id) }} <tr><th>Účastník<td>{{ sc.user|pion_link(sc.contest.contest_id) }}{{ sc.user|user_flags }}
<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> <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 %} {% if solution %}
<tr><th>Body<td> <tr><th>Body<td>
......
...@@ -73,9 +73,9 @@ ...@@ -73,9 +73,9 @@
</tr> </tr>
</thead> </thead>
{% for user in users %} {% for user in users %}
<tr{% if user.is_test %} class="testuser" title="Testovací uživatel"{% endif %}> <tr>
<td>{{ user.first_name }}</td><td>{{ user.last_name }}</td> <td>{{ user.first_name }}</td><td>{{ user.last_name }}</td>
<td>{{ user.email|mailto }}{% if user.password_hash == None %}<span class="user-inactive" title='Účet dosud nebyl aktivován'> *</span>{% endif %}</td> <td>{{ user.email|mailto }}{{ user|user_flags }}</td>
<td>{% if user.participants|count == 0 %}<i>v žádném ročníku</i>{% else %} <td>{% if user.participants|count == 0 %}<i>v žádném ročníku</i>{% else %}
<ul> <ul>
{% for participant in user.participants %} {% for participant in user.participants %}
......
...@@ -35,14 +35,14 @@ finální (ve výchozím stavu poslední nahrané).{% elif sc.allow_upload_solut ...@@ -35,14 +35,14 @@ finální (ve výchozím stavu poslední nahrané).{% elif sc.allow_upload_solut
{% set u = for_user or obj.user %} {% set u = for_user or obj.user %}
{% set task = for_task or obj %} {% set task = for_task or obj %}
{% if for_task %} {% if for_task %}
<tr class="state-{{ obj.state.name }}{% if u.is_test %} testuser{% endif %}" {% if u.is_test %}title="Testovací uživatel"{% endif %}> <tr class="state-{{ obj.state.name }}">
{% else %} {% else %}
<tr> <tr>
{% endif %} {% endif %}
<td>{% if for_user %} <td>{% if for_user %}
<a href='{{ url_for('org_contest_task', contest_id=ct_id, task_id=task.task_id) }}'>{{ task.code }} {{ task.name }}</a> <a href='{{ url_for('org_contest_task', contest_id=ct_id, task_id=task.task_id) }}'>{{ task.code }} {{ task.name }}</a>
{% else %} {% else %}
{{ u|pion_link(contest.contest_id) }}</a> {{ u|pion_link(contest.contest_id) }}{{ u|user_flags }}</a>
{% endif %} {% endif %}
{% if for_task %}<td>{{ obj.state.friendly_name() }}{% endif %} {% if for_task %}<td>{{ obj.state.friendly_name() }}{% endif %}
{% if sol %} {% if sol %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment