Change "reusability" to "type" for invites

- This makes the choice much clearer
- Allows for less generic terms in the table
- Future extensibility \o/
This commit is contained in:
Jonas Schäfer
2021-01-27 15:54:56 +01:00
parent ad0041ba84
commit 2f368e0a34
6 changed files with 46 additions and 38 deletions

View File

@@ -148,8 +148,13 @@ class InvitePost(flask_wtf.FlaskForm): # type:ignore
default=7*86400,
)
reusable = wtforms.BooleanField(
_l("Invite a group of people"),
type_ = wtforms.RadioField(
_l("Invitation type"),
choices=[
("account", _l("Individual")),
("group", _l("Group")),
],
default="account",
)
action_create_invite = wtforms.SubmitField(
@@ -228,7 +233,7 @@ async def create_invite() -> typing.Union[str, quart.Response]:
(c.id_, c.name) for c in circles
]
if form.validate_on_submit():
if form.reusable.data:
if form.type_.data == "group":
invite = await client.create_group_invite(
group_ids=form.circles.data,
ttl=form.lifetime.data,

View File

@@ -5,8 +5,8 @@
<h2 class="form-title">{% trans %}Create new invitation{% endtrans %}</h2>
<p class="form-descr weak">{% trans %}Create a new invitation link to invite more users to your Snikket service by clicking the button below.{% endtrans %}</p>
<div class="f-ebox">
{{ invite_form.reusable }}
{{ invite_form.reusable.label }}
{{ invite_form.type_.label }}
{{ invite_form.type_ }}
</div>
<div class="f-ebox">
{{ invite_form.lifetime.label }}

View File

@@ -14,7 +14,7 @@
<dd>{{ invite.expires | format_date }}</dd>
<dt>{% trans %}Link{% endtrans %}</dt>
<dd>{% call showuri(invite.landing_page) %}{% endcall %}</dd>
<dt>{% trans %}Reusability{% endtrans %}</dt>
<dt>{% trans %}Invitation type{% endtrans %}</dt>
<dd>{% if invite.reusable %}{% trans %}This invitation link can be used arbitrarily often, until it expires, is revoked or a service-wide user limit is reached.{% endtrans %}{% else %}{% trans %}This invitation link can only be used once and is then depleted.{% endtrans %}{% endif %}</dd>
{%- set ngroups = invite.group_ids | length -%}
{%- if ngroups > 1 -%}

View File

@@ -1,5 +1,5 @@
{% extends "admin_app.html" %}
{% from "library.j2" import action_button, icon, clipboard_button, form_button, custom_form_button, extract_circle_name %}
{% from "library.j2" import action_button, icon, clipboard_button, form_button, custom_form_button, extract_circle_name, invite_type_name %}
{% block head_lead %}
{{ super() }}
{% include "copy-snippet.html" %}
@@ -19,7 +19,7 @@
<thead>
<tr>
<th>{% trans %}Valid until{% endtrans %}</th>
<th class="collapsible">{% trans %}Reusable{% endtrans %}</th>
<th class="collapsible">{% trans %}Type{% endtrans %}</th>
<th class="collapsible">{% trans %}Circle{% endtrans %}</th>
<th>{% trans %}Actions{% endtrans %}</th>
</tr>
@@ -28,8 +28,7 @@
{% for invite in invites %}
<tr>
<td>{{ (invite.expires - now) | format_timedelta(add_direction=True) }}</td>
<td class="collapsible">{% if invite.reusable %}{% trans %}Yes{% endtrans %}{% else %}{% trans
%}No{% endtrans %}{% endif %}</td>
<td class="collapsible">{% call invite_type_name(invite) %}{% endcall %}</td>
<td class="collapsible">
{#- -#}
<ul class="inline">

View File

@@ -107,3 +107,11 @@
<em>{% trans %}deleted{% endtrans %}</em>
{%- endif -%}
{% endmacro %}
{%- macro invite_type_name(invite_info, caller=None) -%}
{%- if invite_info.reusable -%}
{% trans %}Group{% endtrans %}
{%- else -%}
{% trans %}Individual{% endtrans %}
{%- endif -%}
{%- endmacro -%}

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-01-27 15:34+0100\n"
"POT-Creation-Date: 2021-01-27 15:55+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -53,39 +53,47 @@ msgstr ""
msgid "Four weeks"
msgstr ""
#: snikket_web/admin.py:152
msgid "Invite a group of people"
#: snikket_web/admin.py:152 snikket_web/templates/admin_edit_invite.html:17
msgid "Invitation type"
msgstr ""
#: snikket_web/admin.py:156
#: snikket_web/admin.py:154 snikket_web/templates/library.j2:115
msgid "Individual"
msgstr ""
#: snikket_web/admin.py:155 snikket_web/templates/library.j2:113
msgid "Group"
msgstr ""
#: snikket_web/admin.py:161
msgid "New invitation link"
msgstr ""
#: snikket_web/admin.py:218
#: snikket_web/admin.py:223
msgid "Revoke"
msgstr ""
#: snikket_web/admin.py:274 snikket_web/admin.py:318
#: snikket_web/admin.py:279 snikket_web/admin.py:323
msgid "Name"
msgstr ""
#: snikket_web/admin.py:279 snikket_web/templates/admin_circles.html:44
#: snikket_web/admin.py:284 snikket_web/templates/admin_circles.html:44
msgid "Create circle"
msgstr ""
#: snikket_web/admin.py:323
#: snikket_web/admin.py:328
msgid "Select user"
msgstr ""
#: snikket_web/admin.py:328
#: snikket_web/admin.py:333
msgid "Update circle"
msgstr ""
#: snikket_web/admin.py:332
#: snikket_web/admin.py:337
msgid "Delete circle permanently"
msgstr ""
#: snikket_web/admin.py:338
#: snikket_web/admin.py:343
msgid "Add user"
msgstr ""
@@ -472,10 +480,6 @@ msgstr ""
msgid "Link"
msgstr ""
#: snikket_web/templates/admin_edit_invite.html:17
msgid "Reusability"
msgstr ""
#: snikket_web/templates/admin_edit_invite.html:18
msgid ""
"This invitation link can be used arbitrarily often, until it expires, is "
@@ -573,30 +577,22 @@ msgid "Pending invitations"
msgstr ""
#: snikket_web/templates/admin_invites.html:22
msgid "Reusable"
msgid "Type"
msgstr ""
#: snikket_web/templates/admin_invites.html:31
msgid "Yes"
msgstr ""
#: snikket_web/templates/admin_invites.html:31
msgid "No"
msgstr ""
#: snikket_web/templates/admin_invites.html:44
#: snikket_web/templates/admin_invites.html:43
msgid "Show invite details"
msgstr ""
#: snikket_web/templates/admin_invites.html:47
#: snikket_web/templates/admin_invites.html:46
msgid "Copy invite link to clipboard"
msgstr ""
#: snikket_web/templates/admin_invites.html:50
#: snikket_web/templates/admin_invites.html:49
msgid "Delete invitation"
msgstr ""
#: snikket_web/templates/admin_invites.html:58
#: snikket_web/templates/admin_invites.html:57
msgid "Currently, there are no pending invitations."
msgstr ""