~homeworkprod/byceps

b309c8bdffdc4aa3645d69bf8e7920e381182a10 — Jochen Kupperschmidt a month ago 1d39782
Remove brand-based persons admin overview
M byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html => byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html +1 -1
@@ 23,7 23,7 @@
{%- include 'admin/dashboard/_brands.html' %}
    {%- endcall %}
    {{ render_bigstats_cell(party_count, 'Partys', href=url_for('party_admin.index'), icon_name='date') }}
    {{ render_bigstats_cell(orga_count, 'Organisatoren', href=url_for('orga_admin.persons'), icon_name='users') }}
    {{ render_bigstats_cell(orga_count, 'Organisatoren', icon_name='users') }}
    {{ render_bigstats_cell(user_count|separate_thousands, 'Benutzer', href=url_for('user_admin.index'), icon_name='users') }}
    {{ render_bigstats_cell(recent_users_count, 'neue Benutzer in den letzten 7 Tagen', href=url_for('user_admin.index'), icon_name='users', color='#008800') }}
    {{ render_bigstats_cell(uninitialized_user_count, 'noch nicht aktivierte Benutzer', href=url_for('user_admin.index', only='uninitialized'), icon_name='users', color='#1199ff') }}

D byceps/blueprints/admin/orga/templates/admin/orga/persons.html => byceps/blueprints/admin/orga/templates/admin/orga/persons.html +0 -27
@@ 1,27 0,0 @@
{% extends 'layout/admin/base.html' %}
{% from 'macros/admin/brand.html' import render_brand_avatar %}
{% set current_page = 'orga_admin.persons' %}
{% set title = 'Organisatoren' %}

{% block body %}

  <h1>{{ title }}</h1>

  {%- if brands_with_person_counts %}
  <p>Marke wählen:</p>
  <ol class="index fully-linked">
    {%- for brand, person_count in brands_with_person_counts|sort(attribute='0.title') %}
    <li>
      <a href="{{ url_for('.persons_for_brand', brand_id=brand.id) }}">
        <div style="float: left; margin-right: 0.5rem;">{{ render_brand_avatar(brand, '32') }}</div>
        <strong>{{ brand.title }}</strong><br>
        {{ '%d %s'|format(person_count, 'Person' if (person_count == 1) else 'Personen')|dim }}
      </a>
    </li>
    {%- endfor %}
  </ol>
  {%- else %}
  <div class="dimmed-box centered">Es sind keine Marken hinterlegt.</div>
  {%- endif %}

{%- endblock %}

M byceps/blueprints/admin/orga/templates/admin/orga/persons_for_brand.html => byceps/blueprints/admin/orga/templates/admin/orga/persons_for_brand.html +0 -5
@@ 24,11 24,6 @@

{% block body %}

  <nav class="breadcrumbs">
    <ol>
      <li><a href="{{ url_for('.persons') }}">{{ brand.title }}</a></li>
    </ol>
  </nav>
  <h1>{{ title }} {{ render_extra_in_heading(orgas_with_birthdays|length) }}</h1>

  <div class="button-row button-row--right">

M byceps/blueprints/admin/orga/views.py => byceps/blueprints/admin/orga/views.py +0 -12
@@ 38,18 38,6 @@ permission_registry.register_enum(OrgaDetailPermission)
permission_registry.register_enum(OrgaTeamPermission)


@blueprint.route('/persons')
@permission_required(OrgaDetailPermission.view)
@templated
def persons():
    """List brands to choose from."""
    brands_with_person_counts = orga_service.get_brands_with_person_counts()

    return {
        'brands_with_person_counts': brands_with_person_counts,
    }


@blueprint.route('/persons/<brand_id>')
@permission_required(OrgaDetailPermission.view)
@templated

M byceps/services/orga/service.py => byceps/services/orga/service.py +1 -12
@@ 6,7 6,7 @@ byceps.services.orga.service
:License: Revised BSD (see `LICENSE` file for details)
"""

from typing import Dict, Iterator, Optional, Sequence, Tuple
from typing import Dict, Optional, Sequence

from ...database import db
from ...typing import BrandID, UserID


@@ 19,17 19,6 @@ from ..user.models.user import User as DbUser
from .models import OrgaFlag as DbOrgaFlag


def get_brands_with_person_counts() -> Iterator[Tuple[DbBrand, int]]:
    """Yield (brand, person count) pairs."""
    brands = brand_service.get_all_brands()

    person_counts_by_brand_id = get_person_count_by_brand_id()

    for brand in brands:
        person_count = person_counts_by_brand_id[brand.id]
        yield brand, person_count


def get_person_count_by_brand_id() -> Dict[BrandID, int]:
    """Return organizer count (including 0) per brand, indexed by brand ID."""
    brand_ids_and_orga_flag_counts = db.session \