{%- macro list_groups(groups) -%} {%- if groups -%} {%- endif -%} {%- endmacro -%}

Recent users

{%- for user,last_seen in users -%} {%- endfor -%}
Username Groups Last seen
{{user.name}} {{list_groups(user.groups)}} {{last_seen.format('YYYY-MM-DD hh:mm A')}} ({{last_seen.humanize()}})

Access Log

{%- set columns = [ ('authorized',True), ('date',False), ('user',True), ('entry',True), ('groups',False), ] -%} {%- set headers = { 'authorized': 'Vis', } -%} {%- macro format(col, rec, grouper=False) -%} {%- if col == 'entry' -%}{{rec.title}} {%- elif col == 'date' -%}{{rec.format('YYYY-MM-DD hh:mm A')}} {%- elif col == 'user' -%}{%- if rec.name -%}{{rec.name}}{%- elif grouper -%}No user{%- endif -%} {%- elif col == 'groups' -%}{{list_groups(rec)}} {%- elif col == 'authorized' -%}{%- if grouper -%} {{'Authorized' if rec else 'Forbidden'}} {%- else -%} {{'✅' if rec else '❌'}} {%- endif -%} {%- endif -%} {%- endmacro -%} {%- macro column(col, rec, add_class='') -%} {%- if col != by -%}{{format(col, rec)}}{%- endif -%} {%- endmacro -%} {%- macro show_row(access) -%} {{column('authorized', access.authorized)}} {{column('date', access.date)}} {{column('user', access.user, ' admin' if access.user.is_admin else '')}} {{column('entry', access.entry)}} {{column('groups', access.user_groups)}} {%- endmacro -%} {%- for column, groupable in columns -%} {%- if by != column -%} {%- endif -%} {%- endfor -%} {%- if by -%} {%- for group in log|groupby(by) -%} {%- for access in group.list|sort(True,'date') -%} {{ show_row(access) }} {%- endfor -%} {%- endfor -%} {%- else -%} {%- for access in log|sort(True,'date') -%} {{ show_row(access) }} {%- endfor -%} {%- endif -%}
{%- if groupable -%} {{headers.get(column,column.title())}} {%- elif column == 'date' -%} {{column.title()}} {%- else -%} {{column.title()}} {%- endif -%}
{{format(by, group.grouper, True)}}