implement pairlock side further

This commit is contained in:
Matthias
2022-04-24 11:23:26 +02:00
parent 420836b1b2
commit fc201bb4ff
6 changed files with 28 additions and 16 deletions

View File

@@ -54,8 +54,9 @@ class ProtectionManager():
if protection_handler.has_global_stop:
lock = protection_handler.global_stop(date_now=now, side=side)
if lock and lock.until:
if not PairLocks.is_global_lock(lock.until):
result = PairLocks.lock_pair('*', lock.until, lock.reason, now=now)
if not PairLocks.is_global_lock(lock.until, lock.lock_side):
result = PairLocks.lock_pair(
'*', lock.until, lock.reason, now=now, side=lock.lock_side)
return result
def stop_per_pair(self, pair, now: Optional[datetime] = None,
@@ -68,6 +69,7 @@ class ProtectionManager():
lock = protection_handler.stop_per_pair(
pair=pair, date_now=now, side=side)
if lock and lock.until:
if not PairLocks.is_pair_locked(pair, lock.until):
result = PairLocks.lock_pair(pair, lock.until, lock.reason, now=now)
if not PairLocks.is_pair_locked(pair, lock.until, lock.lock_side):
result = PairLocks.lock_pair(
pair, lock.until, lock.reason, now=now, side=lock.lock_side)
return result