~homeworkprod/byceps

1a260ba08bb0a5dec62f40a7fd5e7553932adaec — Jochen Kupperschmidt a month ago e98920e
Display ticket sales progress bar for parties on admin dashboards
M byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_parties.html => byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_parties.html +21 -2
@@ 1,18 1,37 @@
{% from 'macros/admin/brand.html' import render_brand_avatar %}
{% from 'macros/admin/dashboard.html' import render_cell %}
{% from 'macros/datetime.html' import render_date %}
{% from 'macros/misc.html' import render_tag %}


<div class="dashboard-section-title">Aktive Partys</div>

<div class="grid">

{%- if active_parties %}
  {%- for party in active_parties %}
{%- if active_parties_with_ticket_stats %}
  {%- for party, ticket_sale_stats in active_parties_with_ticket_stats %}
    {%- call render_cell(href=url_for('admin_dashboard.view_party', party_id=party.id)) %}
  <div style="float: left; margin-right: 0.5rem;">{{ render_brand_avatar(party.brand, '32') }}</div>
  <div>{{ party.title }}</div>
  <div class="supplement">{{ render_date(party.starts_at, smart=False) }}–{{ render_date(party.ends_at, smart=False) }}</div>

      {%- with tickets_total_max_specified = (ticket_sale_stats.tickets_max is not none) %}
  <div class="progress" style="height: 0.25rem; margin-top: 1rem;">
        {%- if tickets_total_max_specified %}
    <div class="progress-bar color-success" style="width: calc(100% * {{ ticket_sale_stats.tickets_sold }} / {{ ticket_sale_stats.tickets_max }});"></div>
        {%- endif %}
  </div>
  <div style="color: #999999; font-size: 0.6875rem; text-align: right;">
    <strong>{{ ticket_sale_stats.tickets_sold|separate_thousands }}</strong>
    von
    <strong>{{ ticket_sale_stats.tickets_max|separate_thousands if tickets_total_max_specified else '?' }}</strong>
    Tickets verkauft
        {%- if tickets_total_max_specified and ticket_sale_stats.tickets_sold >= ticket_sale_stats.tickets_max %}
    <div class="centered">{{ render_tag('ausverkauft') }}</div>
        {%- endif %}
  </div>
      {%- endwith %}

    {%- endcall %}
  {%- endfor %}
{%- else %}

M byceps/blueprints/admin/dashboard/views.py => byceps/blueprints/admin/dashboard/views.py +12 -2
@@ 50,7 50,12 @@ permission_registry.register_enum(AdminDashboardPermission)
def view_global():
    """View dashboard for global entities."""
    current_sites = site_service.get_current_sites(include_brands=True)

    active_parties = party_service.get_active_parties(include_brands=True)
    active_parties_with_ticket_stats = [
        (party, ticket_service.get_ticket_sale_stats(party.id))
        for party in active_parties
    ]

    brands = brand_service.get_all_brands()
    party_count = party_service.count_parties()


@@ 73,7 78,7 @@ def view_global():

    return {
        'current_sites': current_sites,
        'active_parties': active_parties,
        'active_parties_with_ticket_stats': active_parties_with_ticket_stats,

        'brands': brands,
        'party_count': party_count,


@@ 101,9 106,14 @@ def view_brand(brand_id):
    current_sites = site_service.get_current_sites(
        brand_id=brand.id, include_brands=True
    )

    active_parties = party_service.get_active_parties(
        brand_id=brand.id, include_brands=True
    )
    active_parties_with_ticket_stats = [
        (party, ticket_service.get_ticket_sale_stats(party.id))
        for party in active_parties
    ]

    party_count = party_service.count_parties_for_brand(brand.id)



@@ 137,7 147,7 @@ def view_brand(brand_id):
        'brand': brand,

        'current_sites': current_sites,
        'active_parties': active_parties,
        'active_parties_with_ticket_stats': active_parties_with_ticket_stats,

        'party_count': party_count,