{#- Pieces the administration's pages on the Abilian Design System share. -#} {#- Whether an account may sign in, and whether it ever has. -#} {% macro state(user) -%} {% if not user.can_login %}{{ _("Disabled") }} {%- elif user.last_active %}{{ _("Active") }} {%- else %}{{ _("Never signed in") }}{% endif %} {%- endmacro %} {#- Signing in as someone, to see what they see. A POST: it changes who is signed in. -#} {% macro sign_in_as(user, class="ads-btn") -%}
{{ csrf.field() }}
{%- endmacro %} {#- A line of the log: who did what to which object, and where; what changed, under it. `kinds` says, by class, how a line names an object of it. -#} {% macro audit_line(entry, kinds) -%} {% set e = entry.entry %} {% set class_name = e.entity_type.rsplit(".", 1)[-1] %} {% set obj = e.entity %} {% set who = person(e.user) %} {% set what %}{% if entry.entity_url %}{{ obj.name or e.entity_name }}{% else %}{{ e.entity_name }}{% endif %}{% endset %} {% set kind = kinds[class_name][1] if class_name in kinds else class_name %} {%- if entry.verb == "create" %}{{ _("%(who)s created %(kind)s %(what)s", who=who, kind=kind, what=what) }} {%- elif entry.verb == "update" %}{{ _("%(who)s changed %(kind)s %(what)s", who=who, kind=kind, what=what) }} {%- else %}{{ _("%(who)s deleted %(kind)s %(what)s", who=who, kind=kind, what=what) }}{% endif %} {%- if obj and obj.community is defined and obj.community %} {{ _("in %(community)s", community=obj.community.name) }}{% endif %} {% if entry.verb == "update" and e.changes %}{{ field_changes(e.changes) }}{% endif %} {%- endmacro %} {#- What a change changed: each field a person reads (`Changes.shown_columns`), its old value struck out, then its new one; what was added to a list and what was taken from it. Long values are cut short. -#} {% macro field_changes(changes) -%} {% set keys = changes.shown_columns() %} {% if keys or changes.collections %} {% endif %} {%- endmacro %} {#- Who did something, in a line of the log: their account, or the system itself (a migration, the command line), which is no one's. -#} {% macro person(user) -%} {% if user and user.id != 0 %}{{ user.name }}{% else %}{{ _("The system") }}{% endif %} {%- endmacro %} {#- A line of the log about permissions: a role given or taken, on an object or on the whole site; an object made to inherit its permissions, or to stop. -#} {% macro permission_line(entry) -%} {% set e = entry.entry %} {% set who = person(e.manager) %} {% set role = role_name(e.role) if e.role else "" %} {% set principal %}{% if e.user %}{{ person(e.user) }}{% elif e.group %}{{ e.group.name }}{% endif %}{% endset %} {% set target %}{% if entry.object_url %}{{ e.object.name }}{% else %}{{ e.object_name }}{% endif %}{% endset %} {%- if e.op == "GRANT" %}{{ _("%(who)s gave the role %(role)s to %(principal)s", who=who, role=role, principal=principal) }} {%- elif e.op == "REVOKE" %}{{ _("%(who)s took the role %(role)s from %(principal)s", who=who, role=role, principal=principal) }} {%- elif e.op == "SET_INHERIT" %}{{ _("%(who)s made %(target)s inherit its permissions", who=who, target=target) }} {%- else %}{{ _("%(who)s stopped %(target)s inheriting its permissions", who=who, target=target) }}{% endif %} {%- if e.object_id and e.op in ("GRANT", "REVOKE") %} {{ _("on %(target)s", target=target) }}{% endif %} {%- endmacro %} {#- A role, by its label; one without a translation keeps its key ("role_reader"), and its name reads better. -#} {% macro role_name(role) -%} {% set label = role.label | string %}{{ role.name if label.startswith("role_") else label }} {%- endmacro %}