~homeworkprod/byceps

d01d294a0f6e23b9c8c4692b52425791d85daa2f — Jochen Kupperschmidt 6 months ago 50d05ff
Show active brands (as avatars) on global admin dashboard
A byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_brands.html => byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_brands.html +25 -0
@@ 0,0 1,25 @@
{% from 'macros/admin/brand.html' import render_brand_avatar %}
{% from 'macros/admin/dashboard.html' import render_cell %}


<div class="dashboard-section-title">{{ _('Active Brands') }}</div>

<div class="flex-grid">

{%- if active_brands %}
  {%- for brand in active_brands|sort(attribute='title') %}
    {%- call render_cell(href=url_for('brand_admin.view', brand_id=brand.id), additional_classes='less-padding') %}
  <div title="{{ brand.title }}">{{ render_brand_avatar(brand, '64') }}</div>
    {%- endcall %}
  {%- endfor %}
{%- else %}
  {%- call render_cell() %}
  <div style="display: grid; height: 100%; place-items: center;">{{ _('No active brands')|dim }}</div>
  {%- endcall %}
{%- endif %}

{%- call render_cell(href=url_for('brand_admin.index')) %}
  <div style="display: grid; height: 100%; place-items: center;">{{ _('All brands') }} &rarr;</div>
{%- endcall %}

</div>

M byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html => byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html +2 -0
@@ 10,6 10,8 @@

{% block body %}

{%- include 'admin/dashboard/_active_brands.html' %}

{%- include 'admin/dashboard/_current_sites.html' %}

{%- include 'admin/dashboard/_active_parties.html' %}

M byceps/blueprints/admin/dashboard/views.py => byceps/blueprints/admin/dashboard/views.py +3 -0
@@ 50,6 50,8 @@ register_permission_enum(AdminDashboardPermission)
@templated
def view_global():
    """View dashboard for global entities."""
    active_brands = brand_service.get_active_brands()

    current_sites = site_service.get_current_sites(include_brands=True)

    active_parties = party_service.get_active_parties(include_brands=True)


@@ 82,6 84,7 @@ def view_global():
    )

    return {
        'active_brands': active_brands,
        'current_sites': current_sites,
        'active_parties_with_ticket_stats': active_parties_with_ticket_stats,
        'active_shops_with_open_orders_counts': active_shops_with_open_orders_counts,

M byceps/services/brand/service.py => byceps/services/brand/service.py +9 -0
@@ 92,6 92,15 @@ def get_all_brands() -> list[Brand]:
    return [_db_entity_to_brand(brand) for brand in brands]


def get_active_brands() -> set[Brand]:
    """Return active (i.e. non-archived) brands."""
    brands = DbBrand.query \
        .filter_by(archived=False) \
        .all()

    return {_db_entity_to_brand(brand) for brand in brands}


def count_brands() -> int:
    """Return the number of brands."""
    return DbBrand.query.count()

M byceps/static/style/admin_dashboard.css => byceps/static/style/admin_dashboard.css +18 -0
@@ 7,6 7,19 @@
  text-transform: uppercase;
}

.flex-grid {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: var(--inner-gutter);
  margin-left: calc(var(--inner-gutter) * -1);
  margin-top: calc(var(--inner-gutter) * -1);
}

.flex-grid .cell {
  margin-left: var(--inner-gutter);
  margin-top: var(--inner-gutter);
}

.grid {
  display: grid;
  gap: var(--inner-gutter);


@@ 37,6 50,11 @@
  overflow: hidden;
}

.cell.less-padding .box {
  height: auto;
  padding: 0.25rem;
}

.dashboard h2 {
  font-size: 0.75rem; /* 12px / 16px */
  font-weight: normal;

M byceps/translations/de/LC_MESSAGES/messages.mo => byceps/translations/de/LC_MESSAGES/messages.mo +0 -0
M byceps/translations/de/LC_MESSAGES/messages.po => byceps/translations/de/LC_MESSAGES/messages.po +17 -5
@@ 314,7 314,7 @@ msgstr "Name"
#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_brand.html:41
#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_global.html:27
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_brand.html:21
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:25
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:27
msgid "Parties"
msgstr "Partys"



@@ 442,7 442,7 @@ msgid "More"
msgstr "Mehr"

#: byceps/blueprints/admin/core/templates/layout/admin/_navigation_global.html:15
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:26
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:28
#: byceps/blueprints/admin/user/templates/admin/user/create_account_form.html:9
#: byceps/blueprints/admin/user/templates/layout/admin/user.html:37
msgid "Users"


@@ 490,6 490,18 @@ msgstr "Newsposts"
msgid "Storefront"
msgstr "Storefront"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_brands.html:5
msgid "Active Brands"
msgstr "Aktive Marken"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_brands.html:17
msgid "No active brands"
msgstr "Keine aktiven Marken"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_brands.html:22
msgid "All brands"
msgstr "Alle Marken"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/_active_parties.html:7
msgid "Active Parties"
msgstr "Aktive Partys"


@@ 567,7 579,7 @@ msgid "All users"
msgstr "Alle Benutzer"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_brand.html:18
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:19
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:21
msgid "Overview"
msgstr "Übersicht"



@@ 584,11 596,11 @@ msgstr "Erforderliche Zustimmungen"
msgid "None required"
msgstr "Keine erforderlich"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:27
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:29
msgid "new users in the last 7 days"
msgstr "neue Benutzer in den letzten 7 Tagen"

#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:28
#: byceps/blueprints/admin/dashboard/templates/admin/dashboard/view_global.html:30
msgid "uninitialized users"
msgstr "noch nicht aktivierte Benutzer"