diff --git a/payments/models.py b/payments/models.py index ae78e8c7b..8958715cd 100644 --- a/payments/models.py +++ b/payments/models.py @@ -808,7 +808,8 @@ def get_price(self) -> Decimal: def set_state( self, new_state: str, log_message: str = None, - save: bool = True, update_reservation_state: bool = True + save: bool = True, update_reservation_state: bool = True, + **kwargs ) -> None: assert new_state in (Order.WAITING, Order.CONFIRMED, Order.REJECTED, Order.EXPIRED, Order.CANCELLED) @@ -843,9 +844,9 @@ def set_state( if update_reservation_state: if new_state == Order.CONFIRMED: - self.reservation.set_state(Reservation.CONFIRMED, None) + self.reservation.set_state(Reservation.CONFIRMED, kwargs.get('user', self.reservation.user)) elif new_state in (Order.REJECTED, Order.EXPIRED, Order.CANCELLED): - self.reservation.set_state(Reservation.CANCELLED, None) + self.reservation.set_state(Reservation.CANCELLED, kwargs.get('user', self.reservation.user)) if save: self.save() diff --git a/resources/api/reservation.py b/resources/api/reservation.py index 672a55dcf..5dcc011ef 100644 --- a/resources/api/reservation.py +++ b/resources/api/reservation.py @@ -1126,7 +1126,7 @@ def perform_destroy(self, instance): instance.set_state(Reservation.CANCELLED, self.request.user) if instance.has_order(): order = instance.get_order() - order.set_state(Order.CANCELLED, 'Order reservation was cancelled.') + order.set_state(Order.CANCELLED, 'Order reservation was cancelled.', user = self.request.user) def list(self, request, *args, **kwargs): response = super().list(request, *args, **kwargs)