~homeworkprod/byceps

5ed7e36a74284f6b9dc84ae2604ab1c4a09b0486 — Jochen Kupperschmidt 8 months ago 82ca27b
Move ticket category index from seating blueprint to new ticketing blueprint
M byceps/blueprints/admin/seating/templates/admin/seating/index_for_party.html => byceps/blueprints/admin/seating/templates/admin/seating/index_for_party.html +1 -1
@@ 10,7 10,7 @@
  <table class="index">
    <tr>
      <td class="bignumber number">{{ category_count }}</td>
      <td style="vertical-align: middle;"><a href="{{ url_for('.seat_category_index', party_id=party.id) }}">Ticket-Kategorie{% if category_count != 1 %}n{% endif %}</a></td>
      <td style="vertical-align: middle;"><a href="{{ url_for('ticketing_category_admin.index', party_id=party.id) }}">Ticket-Kategorie{% if category_count != 1 %}n{% endif %}</a></td>
    </tr>
    <tr>
      <td class="bignumber number">{{ area_count }}</td>

M byceps/blueprints/admin/seating/templates/layout/admin/seating.html => byceps/blueprints/admin/seating/templates/layout/admin/seating.html +0 -5
@@ 18,11 18,6 @@
        id='areas',
        required_permission=SeatingPermission.view)
      .add_item(
        url_for('.seat_category_index', party_id=party.id),
        'Kategorien',
        id='seat_categories',
        required_permission=SeatingPermission.view)
      .add_item(
        url_for('.seat_group_index', party_id=party.id),
        'Gruppen',
        id='seat_groups',

M byceps/blueprints/admin/seating/views.py => byceps/blueprints/admin/seating/views.py +0 -19
@@ 76,25 76,6 @@ def area_index(party_id, page):
    }


@blueprint.route('/parties/<party_id>/seat_categories')
@permission_required(SeatingPermission.view)
@templated
def seat_category_index(party_id):
    """List seat categories for that party."""
    party = _get_party_or_404(party_id)

    categories_with_ticket_counts = list(
        ticketing_category_service.get_categories_with_ticket_counts_for_party(
            party.id
        ).items()
    )

    return {
        'party': party,
        'categories_with_ticket_counts': categories_with_ticket_counts,
    }


@blueprint.route('/parties/<party_id>/seat_groups')
@permission_required(SeatingPermission.view)
@templated

A byceps/blueprints/admin/ticketing/category/__init__.py => byceps/blueprints/admin/ticketing/category/__init__.py +0 -0
R byceps/blueprints/admin/seating/templates/admin/seating/seat_category_index.html => byceps/blueprints/admin/ticketing/category/templates/admin/ticketing/category/index.html +2 -2
@@ 1,7 1,7 @@
{% extends 'layout/admin/seating.html' %}
{% extends 'layout/admin/ticketing.html' %}
{% from 'macros/admin.html' import render_extra_in_heading %}
{% set current_page_party = party %}
{% set current_tab = 'seat_categories' %}
{% set current_tab = 'categories' %}
{% set title = '%s - Ticket-Kategorien'|format(party.title) %}

{% block body %}

A byceps/blueprints/admin/ticketing/category/views.py => byceps/blueprints/admin/ticketing/category/views.py +50 -0
@@ 0,0 1,50 @@
"""
byceps.blueprints.admin.ticketing.category.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2021 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

from flask import abort

from .....services.party import service as party_service
from .....services.ticketing import (
    category_service as ticketing_category_service,
)
from .....util.framework.blueprint import create_blueprint
from .....util.framework.templating import templated
from .....util.views import permission_required

from ...ticketing.authorization import TicketingPermission


blueprint = create_blueprint('ticketing_category_admin', __name__)


@blueprint.route('/for_party/<party_id>')
@permission_required(TicketingPermission.administrate)
@templated
def index(party_id):
    """List ticket categories for that party."""
    party = _get_party_or_404(party_id)

    categories_with_ticket_counts = list(
        ticketing_category_service.get_categories_with_ticket_counts_for_party(
            party.id
        ).items()
    )

    return {
        'party': party,
        'categories_with_ticket_counts': categories_with_ticket_counts,
    }


def _get_party_or_404(party_id):
    party = party_service.find_party(party_id)

    if party is None:
        abort(404)

    return party

M byceps/blueprints/admin/ticketing/templates/layout/admin/ticketing.html => byceps/blueprints/admin/ticketing/templates/layout/admin/ticketing.html +7 -2
@@ 8,17 8,22 @@
  render_main_tabs(
    Navigation(None)
      .add_item(
        url_for('.index_for_party', party_id=party.id),
        url_for('ticketing_admin.index_for_party', party_id=party.id),
        'Tickets',
        id='tickets',
        required_permission=TicketingPermission.view,
        icon='ticket')
      .add_item(
        url_for('.index_bundle_for_party', party_id=party.id),
        url_for('ticketing_admin.index_bundle_for_party', party_id=party.id),
        'Ticket-Bundles',
        id='bundles',
        required_permission=TicketingPermission.view,
        icon='ticket-bundle')
      .add_item(
        url_for('ticketing_category_admin.index', party_id=party.id),
        'Kategorien',
        id='categories',
        required_permission=TicketingPermission.administrate)
    , current_tab
  )
}}

M byceps/blueprints/blueprints.py => byceps/blueprints/blueprints.py +1 -0
@@ 108,6 108,7 @@ def _get_blueprints_admin() -> Iterator[BlueprintReg]:
        ('admin.snippet',                   '/admin/snippets'           ),
        ('admin.terms',                     '/admin/terms'              ),
        ('admin.ticketing',                 '/admin/ticketing'          ),
        ('admin.ticketing.category',        '/admin/ticketing/categories'   ),
        ('admin.ticketing.checkin',         '/admin/ticketing/checkin'  ),
        ('admin.tourney',                   None                        ),
        ('admin.tourney.category',          '/admin/tourney/categories' ),

M tests/integration/blueprints/admin/seating/test_views.py => tests/integration/blueprints/admin/seating/test_views.py +0 -6
@@ 16,12 16,6 @@ def test_area_index(seating_admin_client, party):
    assert response.status_code == 200


def test_seat_category_index(seating_admin_client, party):
    url = f'/admin/seating/parties/{party.id}/seat_categories'
    response = seating_admin_client.get(url)
    assert response.status_code == 200


def test_seat_group_index(seating_admin_client, party):
    url = f'/admin/seating/parties/{party.id}/seat_groups'
    response = seating_admin_client.get(url)

M tests/integration/blueprints/admin/ticketing/conftest.py => tests/integration/blueprints/admin/ticketing/conftest.py +1 -0
@@ 19,6 19,7 @@ from tests.helpers import login_user
def ticketing_admin(make_admin):
    permission_ids = {
        'admin.access',
        'ticketing.administrate',
        'ticketing.administrate_seat_occupancy',
        'ticketing.checkin',
        'ticketing.view',

M tests/integration/blueprints/admin/ticketing/test_views.py => tests/integration/blueprints/admin/ticketing/test_views.py +6 -0
@@ 32,3 32,9 @@ def test_bundle_view(ticketing_admin_client, bundle):
    url = f'/admin/ticketing/bundles/{bundle.id}'
    response = ticketing_admin_client.get(url)
    assert response.status_code == 200


def test_category_index(ticketing_admin_client, party):
    url = f'/admin/ticketing/categories/for_party/{party.id}'
    response = ticketing_admin_client.get(url)
    assert response.status_code == 200