remove falsy values from body

pull/11/head
Max Erenberg 2 years ago
parent 9f549ee58b
commit da3f1f49da
  1. 8
      ceod/api/positions.py
  2. 3
      ceod/transactions/members/UpdateMemberPositionsTransaction.py

@ -29,6 +29,12 @@ def update_positions():
required = cfg.get('positions_required')
available = cfg.get('positions_available')
# remove falsy values
body = {
positions: username for positions, username in body.items()
if username
}
for position in body.keys():
if position not in available:
return {
@ -36,7 +42,7 @@ def update_positions():
}, 400
for position in required:
if not body.get(position):
if position not in body:
return {
'error': f'missing required position: {position}'
}, 400

@ -28,8 +28,7 @@ class UpdateMemberPositionsTransaction(AbstractTransaction):
# Reverse the dict so it's easier to use (username -> positions)
self.positions = defaultdict(list)
for position, username in positions_reversed.items():
if username is not None:
self.positions[username].append(position)
self.positions[username].append(position)
# a cached Dict of the Users who need to be modified (username -> User)
self.users: Dict[str, IUser] = {}

Loading…
Cancel
Save