Revamp rendering of invitation type to better accomodate roster invites

This commit is contained in:
Jonas Schäfer
2021-01-28 16:15:46 +01:00
parent c2126419d4
commit d5ad562d2c
3 changed files with 17 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
{% extends "admin_app.html" %} {% extends "admin_app.html" %}
{% from "library.j2" import showuri, form_button, standard_button, extract_circle_name %} {% from "library.j2" import showuri, form_button, standard_button, extract_circle_name, invite_type_description %}
{% block head_lead %} {% block head_lead %}
{{ super() }} {{ super() }}
{% include "copy-snippet.html" %} {% include "copy-snippet.html" %}
@@ -15,7 +15,7 @@
<dt>{% trans %}Link{% endtrans %}</dt> <dt>{% trans %}Link{% endtrans %}</dt>
<dd>{% call showuri(invite.landing_page) %}{% endcall %}</dd> <dd>{% call showuri(invite.landing_page) %}{% endcall %}</dd>
<dt>{% trans %}Invitation type{% 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> <dd>{% call invite_type_description(invite) %}{% endcall %}</dd>
{%- set ngroups = invite.group_ids | length -%} {%- set ngroups = invite.group_ids | length -%}
{%- if ngroups > 1 -%} {%- if ngroups > 1 -%}
{#- not supported via the web UI, but we should still display it properly -#} {#- not supported via the web UI, but we should still display it properly -#}
@@ -36,6 +36,10 @@
{%- endif -%} {%- endif -%}
</dd> </dd>
{%- endif -%} {%- endif -%}
{%- if invite.type_.value == "roster" -%}
<dt>{% trans %}Contact{% endtrans %}</dt>
<dd>{% trans peer_jid=invite.jid %}The user will get added as contact of {{ peer_jid }}.{% endtrans %}</dd>
{%- endif -%}
<dt>{% trans %}Created{% endtrans %}</dt> <dt>{% trans %}Created{% endtrans %}</dt>
<dd>{{ invite.created_at | format_date }}</dd> <dd>{{ invite.created_at | format_date }}</dd>
</dl> </dl>

View File

@@ -1,5 +1,5 @@
{% extends "admin_app.html" %} {% extends "admin_app.html" %}
{% from "library.j2" import action_button, icon, clipboard_button, form_button, custom_form_button, extract_circle_name, invite_type_name %} {% from "library.j2" import action_button, icon, clipboard_button, form_button, custom_form_button, extract_circle_name, invite_type_name, invite_type_description %}
{% block head_lead %} {% block head_lead %}
{{ super() }} {{ super() }}
{% include "copy-snippet.html" %} {% include "copy-snippet.html" %}
@@ -28,7 +28,7 @@
{% for invite in invites %} {% for invite in invites %}
<tr> <tr>
<td>{{ (invite.expires - now) | format_timedelta(add_direction=True) }}</td> <td>{{ (invite.expires - now) | format_timedelta(add_direction=True) }}</td>
<td class="collapsible">{% call invite_type_name(invite) %}{% endcall %}</td> <td class="collapsible"><span class="with-tooltip above" data-tooltip="{% call invite_type_description(invite) %}{% endcall %}">{% call invite_type_name(invite) %}{% endcall %}</span></td>
<td class="collapsible"> <td class="collapsible">
{#- -#} {#- -#}
<ul class="inline"> <ul class="inline">

View File

@@ -109,11 +109,17 @@
{% endmacro %} {% endmacro %}
{%- macro invite_type_name(invite_info, caller=None) -%} {%- macro invite_type_name(invite_info, caller=None) -%}
{%- if invite_info.type_.value == "roster" %} {%- if invite_info.reusable -%}
{%- trans %}Contact{% endtrans %}
{%- elif invite_info.reusable -%}
{% trans %}Group{% endtrans %} {% trans %}Group{% endtrans %}
{%- else -%} {%- else -%}
{% trans %}Individual{% endtrans %} {% trans %}Individual{% endtrans %}
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{%- macro invite_type_description(invite_info, caller=None) -%}
{%- if invite_info.reusable -%}
{% trans %}Can be used multiple times to create accounts on this Snikket service.{% endtrans %}
{%- else -%}
{% trans %}Can be used once to create an account on this Snikket service.{% endtrans %}
{%- endif -%}
{%- endmacro -%}