byceps/byceps

View on GitHub
byceps/blueprints/admin/orga/templates/admin/orga/persons_for_brand.html

Summary

Maintainability
Test Coverage
{% extends 'layout/admin/base.html' %}
{% from 'macros/admin.html' import render_extra_in_heading %}
{% from 'macros/admin/user.html' import render_user_admin_link %}
{% from 'macros/icons.html' import render_icon %}
{% from 'macros/user.html' import render_user_avatar %}
{% set current_page = 'orga_admin' %}
{% set current_page_brand = brand %}
{% set page_title = _('Organizers') %}

{% block head %}
  <style>
    .orgas th,
    .orgas td {
      line-height: 1.6;
      white-space: nowrap;
    }
  </style>
{%- endblock %}

{% block body %}

  <div class="row row--space-between block">
    <div>

      <h1 class="title">{{ page_title }} {{ render_extra_in_heading(orgas_with_birthdays|length) }}</h1>

    </div>
    <div>

      <div class="button-row is-right-aligned">
        {%- if has_current_user_permission('orga_team.administrate_memberships') %}
        <a class="button" href="{{ url_for('.grant_orga_status_form', brand_id=brand.id) }}">{{ render_icon('add') }} <span>{{ _('Grant organizer status') }}</span></a>
        {%- endif %}

        {%- if orgas_with_birthdays %}
        <a class="button" href="{{ url_for('.export_persons', brand_id=brand.id) }}" download="organizers_{{ brand.id }}.csv">{{ render_icon('download') }} <span>{{ _('Export') }} <small>{{ _('as Excel CSV')|dim }}</small></span></a>
        {%- else %}
        <button class="button" disabled>{{ render_icon('download') }} <span>{{ _('Export') }} <small>{{ _('as Excel CSV')|dim }}</small></span></button>
        {%- endif %}
      </div>

    </div>
  </div>

  {%- if orgas_with_birthdays %}
  <table class="itemlist is-vcentered is-wide orgas">
    <thead>
      <tr>
        <th>{{ _('Avatar') }}</th>
        <th>
          {{ _('Full name') }}<br>
          {{ _('Username') }}<br>
          {{ _('Date of birth') }}, {{ _('Age') }}
        </th>
        <th>
          {{ _('City') }}<br>
          {{ _('Email address') }}<br>
          {{ _('Phone number') }}
        </th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      {%- for user, birthday in orgas_with_birthdays %}
      <tr>
        <td>{{ render_user_avatar(user, size=48) }}</td>
        <td>
          <strong>{{ render_user_admin_link(user) }}</strong><br>
          {{ user.detail.full_name|fallback }}<br>
          {%- if birthday %}
            {{ render_icon('birthday') }}
            {{ birthday.date_of_birth|dateformat }}
            ({{ birthday.age }} {{ _('years') }})
          {%- else %}
            {{ (render_icon('birthday') ~ ' ' ~ _('not given'))|dim }}
          {%- endif %}
        </td>
        <td>
          {%- if user.email_address %}
          {{ render_icon('email') }} <a href="mailto:{{- user.email_address }}">{{ user.email_address|truncate(36, killwords=True, end='…') }}</a>
          {%- else %}
          {{ (render_icon('email') ~ ' ' ~ _('not given'))|dim }}
          {%- endif %}
          <br>
          {{ render_icon('location') }}
          {{ user.detail.street|fallback }}
          &middot;
          {% if user.detail.zip_code %}{{ user.detail.zip_code }} {% endif %}
          {{ user.detail.city|fallback }}
          &middot;
          {{ user.detail.country|fallback }}
          <br>
          {%- if user.detail.phone_number %}
            {{ render_icon('phone') }}
            {{ user.detail.phone_number }}
          {%- else %}
            {{ (render_icon('phone') ~ ' ' ~ _('not given'))|dim }}
          {%- endif %}
        </td>
        <td>
          {%- if has_current_user_permission('orga_team.administrate_memberships') %}
          <div class="dropdown">
            <button class="dropdown-toggle button is-compact">{{ render_icon('chevron-down') }}</button>
            <ol class="dropdown-menu dropdown-menu--right">
              <li><a class="dropdown-item" data-action="orga-status-revoke" href="{{ url_for('.revoke_orga_status', brand_id=brand.id, user_id=user.id) }}">{{ render_icon('remove') }} {{ _('Revoke organizer status') }}</a></li>
            </ol>
          </div>
          {%- endif %}
        </td>
      </tr>
      {%- endfor %}
      <tr>
    </tbody>
  </table>
  {%- else %}
  <div class="box">
    <div class="dimmed-box centered">{{ _('No users have organizer status.') }}</div>
  </div>
  {%- endif %}

{%- endblock %}

{% block scripts %}
    <script>
      onDomReady(() => {
        confirmed_delete_on_click_then_reload('[data-action="orga-status-revoke"]', '{{ _('Revoke organizer status?') }}');
      });
    </script>
{%- endblock %}