Event cancellation: Fix DivisionByZero when cancelling empty events

This commit is contained in:
Raphael Michel
2021-06-22 10:58:56 +02:00
parent ecf1a40a5e
commit fa8552e86f

View File

@@ -227,7 +227,7 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
if not self.request.called_directly and counter % max(10, total // 100) == 0:
self.update_state(
state='PROGRESS',
meta={'value': round(counter / total * 100, 2)}
meta={'value': round(counter / total * 100 if total else 0, 2)}
)
except LockTimeoutException:
logger.exception("Could not cancel order")
@@ -285,7 +285,7 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
if not self.request.called_directly and counter % max(10, total // 100) == 0:
self.update_state(
state='PROGRESS',
meta={'value': round(counter / total * 100, 2)}
meta={'value': round(counter / total * 100 if total else 0, 2)}
)
if send_waitinglist:
@@ -296,6 +296,6 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
if not self.request.called_directly and counter % max(10, total // 100) == 0:
self.update_state(
state='PROGRESS',
meta={'value': round(counter / total * 100, 2)}
meta={'value': round(counter / total * 100 if total else 0, 2)}
)
return failed