예제 #1
0
def test_reverse_whole_session():
    session = cashdesk_session_before_factory()
    pp = preorder_position_factory(paid=True)
    trans = transaction_factory(session)
    transaction_position_factory(transaction=trans, product=product_factory(items=True))
    pos = redeem_preorder_ticket(secret=pp.secret)
    pos.transaction = trans
    pos.save()
    assert is_redeemed(pp)
    reverse_session(session)
    assert not is_redeemed(pp)
예제 #2
0
def reverse_session_view(request: HttpRequest, pk: int) -> Union[HttpRequest, HttpResponseRedirect]:
    session = get_object_or_404(CashdeskSession, pk=pk)

    if request.method == 'POST':
        try:
            reverse_session(session)
        except FlowError as e:
            messages.error(request, str(e))
        else:
            messages.success(request, _('All transactions in the session have been cancelled.'))
        return redirect('backoffice:session-detail', pk=pk)

    elif request.method == 'GET':
        return render(request, 'backoffice/reverse_session.html', {
            'session': session,
        })