~homeworkprod/byceps

4473a80158e07031227ee8d822acb4bfcfc552e1 — Jochen Kupperschmidt 4 years ago e5d7558
Explicitly retrieve party by ID to obtain details
M byceps/blueprints/party/views.py => byceps/blueprints/party/views.py +3 -1
@@ 36,8 36,10 @@ def before_request():
@templated
def info():
    """Show information about the current party."""
    party = party_service.find_party(g.party_id)

    return {
        'party': g.party,
        'party': party.to_tuple(),
    }



M byceps/blueprints/shop/orders/views.py => byceps/blueprints/shop/orders/views.py +6 -4
@@ 8,6 8,7 @@ byceps.blueprints.shop.orders.views

from flask import abort, g

from ....services.party import service as party_service
from ....services.shop.order import service as order_service
from ....services.user import service as user_service
from ....util.framework.blueprint import create_blueprint


@@ 25,13 26,14 @@ blueprint = create_blueprint('shop_orders', __name__)
def index():
    """List orders placed by the current user for the current party."""
    current_user = g.current_user
    current_party = g.party

    orders = order_service.get_orders_placed_by_user_for_party(current_user.id,
                                                               current_party.id)
    party = party_service.find_party(g.party_id)

    orders = order_service.get_orders_placed_by_user_for_party(
        current_user.id, party.id)

    return {
        'party_title': current_party.title,
        'party_title': party.title,
        'orders': orders,
    }


M byceps/blueprints/ticketing/views.py => byceps/blueprints/ticketing/views.py +5 -3
@@ 8,6 8,7 @@ byceps.blueprints.ticketing.views

from flask import abort, g

from ...services.party import service as party_service
from ...services.ticketing import ticket_service
from ...util.framework.blueprint import create_blueprint
from ...util.iterables import find


@@ 22,16 23,17 @@ blueprint = create_blueprint('ticketing', __name__)
def index_mine():
    """List tickets related to the current user."""
    current_user = _get_current_user_or_403()
    current_party = g.party

    party = party_service.find_party(g.party_id)

    tickets = ticket_service.find_tickets_related_to_user_for_party(
        current_user.id, current_party.id)
        current_user.id, party.id)

    current_user_uses_any_ticket = find(
        lambda t: t.used_by_id == current_user.id, tickets)

    return {
        'party_title': current_party.title,
        'party_title': party.title,
        'tickets': tickets,
        'current_user_uses_any_ticket': current_user_uses_any_ticket,
    }