~homeworkprod/byceps-bungalows

207bfbc2ca06da94188abe176592b47174d55ae4 — Jochen Kupperschmidt 3 months ago 3561891
Fix redirection error after removal of bungalow offer on offer view
M byceps/blueprints/admin/bungalow/templates/admin/bungalow/index_for_party.html => byceps/blueprints/admin/bungalow/templates/admin/bungalow/index_for_party.html +1 -1
@@ 145,7 145,7 @@
      onDomReady(() => {
        post_on_click_then_reload('[data-action="set-distributes-network"]');
        delete_on_click_then_reload('[data-action="unset-distributes-network"]');
        confirmed_post_on_click_then_reload('[data-action="offer-delete"]', 'Bungalow nicht mehr anbieten?');
        confirmed_delete_on_click('[data-action="offer-delete"]', 'Bungalow nicht mehr anbieten?');
      });
    </script>
{%- endblock %}

M byceps/blueprints/admin/bungalow/templates/admin/bungalow/offer_view.html => byceps/blueprints/admin/bungalow/templates/admin/bungalow/offer_view.html +1 -1
@@ 248,7 248,7 @@
      onDomReady(() => {
        post_on_click_then_reload('[data-action="set-distributes-network"]');
        delete_on_click_then_reload('[data-action="unset-distributes-network"]');
        confirmed_post_on_click_then_reload('[data-action="offer-delete"]', 'Bungalow nicht mehr anbieten?');
        confirmed_delete_on_click('[data-action="offer-delete"]', 'Bungalow nicht mehr anbieten?');
      });
    </script>
{%- endblock %}

M byceps/blueprints/admin/bungalow/views.py => byceps/blueprints/admin/bungalow/views.py +9 -4
@@ 9,7 9,7 @@ byceps.blueprints.admin.bungalow.views
from collections.abc import Iterable, Iterator
from datetime import datetime

from flask import abort, g, request
from flask import abort, g, request, url_for
from flask_babel import gettext

from byceps.events.shop import ShopOrderCanceledEvent, ShopOrderPaidEvent


@@ 61,6 61,7 @@ from byceps.util.views import (
    permission_required,
    redirect_to,
    respond_no_content,
    respond_no_content_with_location,
    textified,
)



@@ 427,18 428,22 @@ def _get_buildings_for_party(party: Party) -> list[BungalowBuilding]:
    ]


@blueprint.post('/offers/<bungalow_id>')
@blueprint.delete('/offers/<bungalow_id>')
@permission_required('bungalow_offer.delete')
@respond_no_content
@respond_no_content_with_location
def offer_delete(bungalow_id):
    """Remove the bungalow offer."""
    bungalow = _get_bungalow_or_404(bungalow_id)

    try:
        bungalow_offer_service.delete_offer(bungalow_id)
        bungalow_offer_service.delete_offer(bungalow.id)
    except ValueError as e:
        abort(400, str(e))

    flash_success('Der Bungalow wird nun nicht mehr angeboten.')

    return url_for('.index_for_party', party_id=bungalow.party_id)


@blueprint.get('/<party_id>/occupants')
@permission_required('bungalow.view')