diff --git a/mo/web/org_contest.py b/mo/web/org_contest.py index 9ae93c19ca64a48c8c671ebc12148779a7b4bd83..fdebce5c5e6dd8e9629a809fa11ceeddcc9b2876 100644 --- a/mo/web/org_contest.py +++ b/mo/web/org_contest.py @@ -288,7 +288,8 @@ def get_contest_site_rr(id: int, site_id: Optional[int], right_needed: Optional[ def contest_breadcrumbs( round: Optional[db.Round] = None, contest: Optional[db.Contest] = None, site: Optional[db.Place] = None, task: Optional[db.Task] = None, - user: Optional[db.User] = None, action: Optional[str] = None + user: Optional[db.User] = None, action: Optional[str] = None, + table: Optional[bool] = False ) -> Markup: elements = [(url_for('org_rounds'), 'Soutěže')] round_id = None @@ -313,6 +314,11 @@ def contest_breadcrumbs( if user: user_id = user.user_id elements.append((url_for('org_contest_user', contest_id=ct_id, user_id=user_id), user.full_name())) + if table: + if contest: + elements.append((url_for('org_contest_list', id=ct_id, site=site_id), "Seznam účastníků")) + else: + elements.append((url_for('org_round_list', id=round_id), "Seznam účastníků")) if action: elements.append(('', action)) @@ -466,7 +472,8 @@ def org_contest_list(id: int, site_id: Optional[int] = None): emails = None mailto_link = None if request.endpoint == 'org_contest_list_emails': - (emails, mailto_link) = get_contestant_emails(query) + (emails, mailto_link) = get_contestant_emails(query, + mailto_subject=f'{contest.round.name} {contest.round.category} {contest.place.name_locative()}') count = len(emails) else: # (count, query) = filter.apply_limits(query, pagesize=50) diff --git a/mo/web/org_round.py b/mo/web/org_round.py index 6454aaa589e4776fe6c71e534e0ecf5e9578fe11..8f5f7c0926b0edb7ecc01c179b6328b12700094e 100644 --- a/mo/web/org_round.py +++ b/mo/web/org_round.py @@ -378,7 +378,8 @@ def org_round_list(id: int): emails = None mailto_link = None if request.endpoint == 'org_round_list_emails': - (emails, mailto_link) = get_contestant_emails(query) + (emails, mailto_link) = get_contestant_emails(query, + mailto_subject=f'{round.name} kategorie {round.category}') count = len(emails) else: (count, query) = filter.apply_limits(query, pagesize=50) diff --git a/mo/web/templates/org_contest_list.html b/mo/web/templates/org_contest_list.html index a52f292d2b0ee28f7671d8c25229c66dcef4d19d..edf82b924aaa910cd9f4b80ab458663ede048fac 100644 --- a/mo/web/templates/org_contest_list.html +++ b/mo/web/templates/org_contest_list.html @@ -6,7 +6,7 @@ Seznam účastníků {% if site %}v soutěžním místě {{ site.name }}{% else %}{{ contest.place.name_locative() }}{% endif %} {% endblock %} {% block breadcrumbs %} -{{ contest_breadcrumbs(round=round, contest=contest, site=site, action="Seznam účastníků") }} +{{ contest_breadcrumbs(round=round, contest=contest, site=site, action="Seznam účastníků" if table else "E-maily", table=False if table else True) }} {% endblock %} {% set id = contest.contest_id %} {% set site_id = site.place_id if site else None %} diff --git a/mo/web/templates/org_round_list.html b/mo/web/templates/org_round_list.html index 69b4ca3fd586f25b0546ad0d7c51c240aafa3138..e3ecd19842cc501ecd0e9dba5251754ae85dd4b9 100644 --- a/mo/web/templates/org_round_list.html +++ b/mo/web/templates/org_round_list.html @@ -3,7 +3,7 @@ {% block title %}Seznam účastníků kola {{ round.round_code() }}{% endblock %} {% block breadcrumbs %} -{{ contest_breadcrumbs(round=round, action="Seznam účastníků") }} +{{ contest_breadcrumbs(round=round, action="Seznam účastníků" if table else "E-maily", table=False if table else True) }} {% endblock %} {% set id = round.round_id %} diff --git a/mo/web/templates/parts/org_participants_emails.html b/mo/web/templates/parts/org_participants_emails.html index 3e9ca863d29620bfabddfc223ca69f3a0d64148e..b84c2102ec95312adcf1c168346399c3e71bb3a1 100644 --- a/mo/web/templates/parts/org_participants_emails.html +++ b/mo/web/templates/parts/org_participants_emails.html @@ -1,19 +1,23 @@ -<a class="btn btn-default pull-right" style="margin-top: 15px;" - href="{{ url_for('org_contest_list', id=id, site_id=site_id, **request.args) if contest else url_for('org_round_list', id=id, **request.args) }}"> - Zpět na tabulku účastníků -</a> - <h3>E-mailové adresy</h3> -<div class="form-frame"> + {% if emails %} -<p>Pokud máte e-mailového klienta, který umí odkazy typu <code>mailto:</code>, tak vám následující tlačítko předvyplní nový email: -<a class="btn btn-primary" href="{{ mailto_link }}">Vytvořit email pro {{ count|inflected("adresáta", "adresáty", "adresátů") }}</a> +<pre>{{ emails|join('\n')|escape }}</pre> +<textarea id="emails-textarea" style="display: none">{{ emails|join('\n')|escape }}</textarea> -<p>Emailové adresy si také můžete zkopírovat z následujícího pole. Prosím posílejte jako <b>skrytou kopii</b>, ať účastníci nevidí navzájem své emaily.</p> -<code><textarea id="emails-textarea" class="form-control" readonly style="resize: none;" onclick="this.focus(); this.select();"> -{{ emails|join('\n')|escape }}</textarea></code> -{% else %}<i>Žádné emailové adresy k vypsání.</i>{% endif %} -</div> +<p> +<a class="btn btn-primary" href="{{ mailto_link }}">Vytvořit e-mail pro {{ count|inflected("adresáta", "adresáty", "adresátů") }}</a> +<button class="btn btn-default" id="copy-emails">Zkopírovat všechny adresy do schránky</button> <script type="text/javascript"> -document.getElementById('emails-textarea').style.height = (document.getElementById('emails-textarea').scrollHeight + 5) + "px"; + var ta = document.getElementById('emails-textarea'); + document.getElementById('copy-emails').addEventListener('click', function () { + ta.style.display = 'block'; + ta.select(); + document.execCommand('copy', false); + ta.style.display = 'none'; + }); </script> +</p> + +<p>E-mailové adresy účastníků prosím vkládejte do pole pro <b>skrytou kopii (Bcc)</b>, ať si navzájem nevidí své e-maily.</p> + +{% else %}<i>Žádné e-mailové adresy k vypsání.</i>{% endif %} diff --git a/mo/web/templates/parts/org_participants_table_actions.html b/mo/web/templates/parts/org_participants_table_actions.html index e7097f7b439b5933a2254896a1420d42b1dcd022..24eb85aa361049b900d3a1672d8637673e50cfda 100644 --- a/mo/web/templates/parts/org_participants_table_actions.html +++ b/mo/web/templates/parts/org_participants_table_actions.html @@ -7,7 +7,7 @@ <a class="btn btn-primary pull-right" title="Zobrazí emailové adresy ve snadno zkopírovatelném formátu" href="{{ url_for('org_contest_list_emails', id=id, site_id=site_id, **request.args) if contest else url_for('org_round_list_emails', id=id, **request.args) }}"> - Vypsat emailové adresy + Vypsat e-mailové adresy </a> {% if action_form %}