{# What a token's state reads as, on the owner's list and on the administrators' page. The reason is one of models.REVOKED_*, or none for a token revoked before reasons were kept. #} {% macro revoked_reason(code) -%} {%- if code == 'owner' -%}{{ _('by its owner') }} {%- elif code == 'admin' -%}{{ _('by an administrator') }} {%- elif code == 'password_changed' -%}{{ _('the password was changed') }} {%- elif code == 'account_disabled' -%}{{ _('the account was switched off') }} {%- elif code and code.startswith('import_') -%}{{ _('when it was carried over') }} {%- endif -%} {%- endmacro %} {% macro token_state(token) -%} {% if token.is_revoked %} {{ _('Revoked') }} {% set why = revoked_reason(token.revoked_reason) %} {% if why %}{{ why }}{% endif %} {% elif token.is_expired %} {{ _('Expired') }} {% else %} {{ _('Active') }} {% endif %} {%- endmacro %}