{# Rights: the service rights and the grants, one line each to read, and their editor inside a form (see grants.py). Roles: as tags, and as checkboxes to give. #} {% from "components/ui.html" import icon, toggle %} {% macro grants_of(grants, names) %}{% for grant in grants %}{{ grant_summary(grant, names) }}{% else %}—{% endfor %}{% endmacro %} {% macro service_of(service) %}{% for right in service %}{{ right }} {% else %}—{% endfor %}{% endmacro %} {% macro rights_of(service, grants, names) %}{% if service %}
of the service {{ service_of(service) }}
{% endif %}{% if grants or not service %}{{ grants_of(grants, names) }}{% endif %}{% endmacro %} {% macro sending_of(sending) %}{% for limit in sending %}
{% if limit.recipients is none %}to anyone{% else %}to {{ limit.recipients | join(", ") }}{% endif %}, {% if limit.max_sends_per_day is none %}no daily limit{% else %}at most {{ limit.max_sends_per_day }} a day, {{ limit.sends_left }} left now{% endif %}
{% else %}—{% endfor %}{% endmacro %} {% macro role_tags(roles) %}{% for role in roles %}{{ role }} {% else %}—{% endfor %}{% endmacro %} {% macro role_checks(choices, held) %}
Roles
{% for role in choices %}{% endfor %}
{% endmacro %} {% macro grant_summary(grant, names) %}
on {% for account in grant.accounts %}{{ "every account" if account == "*" else names.get(account, account) }} {% endfor %} may {% for right in grant.allow %}{{ right }} {% endfor %} {% if grant.folders is not none %}in the folders {{ grant.folders | join(", ") }}{% endif %} {% if grant.recipients is not none %}sending to {{ grant.recipients | join(", ") }}{% endif %} {% if grant.max_sends_per_day is not none %}at most {{ grant.max_sends_per_day }} mails a day{% endif %} {% if grant.expires_at is not none %}{% if grant.expires_at | past %}expired on {{ grant.expires_at | when }}{% else %}until {{ grant.expires_at | when }}{% endif %}{% endif %}
{% endmacro %} {% macro service_editor(service, service_names, service_ops) %}
Rights of the service
{% for name in service_names %} {% endfor %}
Bound to no account: connecting accounts, users and roles, webhooks, the audit of administration. admin is every right.
Operation names of the service, beyond the groups.
{% endmacro %} {# The grants of a user or a role in their editor (docs/UI.md 6.3): one line each as it reads, the pencil unfolds its fields, the bin marks it removed (struck through, a hidden tick box), the plus at the top unfolds an empty one. Nothing is stored before the form's Save. ``open``: every grant unfolded, e.g. when the form came back refused. #} {% macro grant_editor(rows, account_choices, groups, group_ops, open=False) %} {% set names = dict(account_choices) %} {% set existing = rows | length - 1 %}
{{ toggle("grant-new", "Add a grant", "plus-lg", alone=False, open=open or not existing) }}
{% for row in rows %} {% set i = loop.index0 %} {% if loop.last %}
A new grant {{ _grant_fields(row, i, account_choices, groups, group_ops) }}
{% else %}
{{ row_summary(row, names) }} {{ toggle("grant-" ~ i, "Change", "pencil", name="Change grant " ~ loop.index, open=open) }}
Grant {{ loop.index }} {{ _grant_fields(row, i, account_choices, groups, group_ops) }}
{% endif %} {% endfor %}
{% endmacro %} {# A grant as the editor holds it, in one line, as grant_summary reads a stored one. #} {% macro row_summary(row, names) %}
on {% for account in row.accounts %}{{ "every account" if account == "*" else names.get(account, account) }} {% else %}no account{% endfor %} may {% for right in row.groups %}{{ right }} {% endfor %}{% for right in row.more.split() %}{{ right }} {% endfor %} {% if row.folders %}in the folders {{ row.folders.splitlines() | join(", ") }}{% endif %} {% if row.recipients %}sending to {{ row.recipients.split() | join(", ") }}{% endif %} {% if row.max_per_day %}at most {{ row.max_per_day }} mails a day{% endif %} {% if row.expires %}until {{ row.expires | replace("T", " ") }}{% endif %}
{% endmacro %} {% macro _grant_fields(row, i, account_choices, groups, group_ops) %}
Accounts
{% for id, email in account_choices %} {% endfor %}
Rights {% for caption, names in groups %} {{ caption }}
{% for group in names %} {% endfor %}
{% endfor %}
Operation names, beyond the groups.
From one account, in any 24 hours. Empty: no limit.
One per line: a role such as inbox, or a name. Subfolders count. Empty: every folder.
In the service's time zone. Empty: no end. Expired, the grant grants nothing.
One per line. Empty: to anyone.
{% endmacro %}