<commit_before>"""
byceps.blueprints.seating.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from typing import Dict, Sequence

from flask import abort, g

from ...services.party import service as party_service
from ...services.seating import area_service as seating_area_service
from ...services.seating.models.seat import Seat
from ...services.seating import seat_service
from ...services.seating.transfer.models import SeatID
from ...services.ticketing.models.ticket import Ticket
from ...services.ticketing import (
    exceptions as ticket_exceptions,
    ticket_seat_management_service,
    ticket_service,
)
from ...services.ticketing.transfer.models import TicketID
from ...services.user import service as user_service
from ...services.user.transfer.models import User
from ...typing import UserID
from ...util.framework.blueprint import create_blueprint
from ...util.framework.flash import flash_error, flash_success
from ...util.framework.templating import templated
from ...util.views import respond_no_content

from ..authentication.decorators import login_required


blueprint = create_blueprint('seating', __name__)


@blueprint.route('/')
@templated
def index():
    """List areas."""
    if g.party_id is None:
        # No party is configured for the current site.
        abort(404)

    areas = seating_area_service.get_areas_for_party(g.party_id)

    return {
        'areas': areas,
    }


@blueprint.route('/areas/<slug>')
@templated
def view_area(slug):
    """View area."""
    if g.party_id is None:
        # No party is configured for the current site.
        abort(404)

    area = seating_area_service.find_area_for_party_by_slug(g.party_id, slug)
    if area is None:
        abort(404)

    seat_management_enabled = _is_seat_management_enabled()

    seats = seat_service.get_seats_with_tickets_for_area(area.id)

    if seat_management_enabled:
        tickets = ticket_service.find_tickets_for_seat_manager(
            g.current_user.id, g.party_id
        )
    else:
        tickets = None

    users_by_id = _get_users(seats, tickets)

    return {
        'area': area,
        'seat_management_enabled': seat_management_enabled,
        'seats': seats,
        'tickets': tickets,
        'users_by_id': users_by_id,
    }

<commit_msg>Fall back to empty data structure<commit_after>"""
byceps.blueprints.seating.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from typing import Dict, Sequence

from flask import abort, g

from ...services.party import service as party_service
from ...services.seating import area_service as seating_area_service
from ...services.seating.models.seat import Seat
from ...services.seating import seat_service
from ...services.seating.transfer.models import SeatID
from ...services.ticketing.models.ticket import Ticket
from ...services.ticketing import (
    exceptions as ticket_exceptions,
    ticket_seat_management_service,
    ticket_service,
)
from ...services.ticketing.transfer.models import TicketID
from ...services.user import service as user_service
from ...services.user.transfer.models import User
from ...typing import UserID
from ...util.framework.blueprint import create_blueprint
from ...util.framework.flash import flash_error, flash_success
from ...util.framework.templating import templated
from ...util.views import respond_no_content

from ..authentication.decorators import login_required


blueprint = create_blueprint('seating', __name__)


@blueprint.route('/')
@templated
def index():
    """List areas."""
    if g.party_id is None:
        # No party is configured for the current site.
        abort(404)

    areas = seating_area_service.get_areas_for_party(g.party_id)

    return {
        'areas': areas,
    }


@blueprint.route('/areas/<slug>')
@templated
def view_area(slug):
    """View area."""
    if g.party_id is None:
        # No party is configured for the current site.
        abort(404)

    area = seating_area_service.find_area_for_party_by_slug(g.party_id, slug)
    if area is None:
        abort(404)

    seat_management_enabled = _is_seat_management_enabled()

    seats = seat_service.get_seats_with_tickets_for_area(area.id)

    if seat_management_enabled:
        tickets = ticket_service.find_tickets_for_seat_manager(
            g.current_user.id, g.party_id
        )
    else:
        tickets = []

    users_by_id = _get_users(seats, tickets)

    return {
        'area': area,
        'seat_management_enabled': seat_management_enabled,
        'seats': seats,
        'tickets': tickets,
        'users_by_id': users_by_id,
    }


{'fraction_non_alphanumeric': 0.10922946655376799, 'fraction_numerical': 0.0071972904318374255, 'mean_word_length': 3.534548944337812, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4380173', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1418, 'n_words': 360}