remove falsy values from body
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
9f549ee58b
commit
da3f1f49da
|
@ -29,6 +29,12 @@ def update_positions():
|
||||||
required = cfg.get('positions_required')
|
required = cfg.get('positions_required')
|
||||||
available = cfg.get('positions_available')
|
available = cfg.get('positions_available')
|
||||||
|
|
||||||
|
# remove falsy values
|
||||||
|
body = {
|
||||||
|
positions: username for positions, username in body.items()
|
||||||
|
if username
|
||||||
|
}
|
||||||
|
|
||||||
for position in body.keys():
|
for position in body.keys():
|
||||||
if position not in available:
|
if position not in available:
|
||||||
return {
|
return {
|
||||||
|
@ -36,7 +42,7 @@ def update_positions():
|
||||||
}, 400
|
}, 400
|
||||||
|
|
||||||
for position in required:
|
for position in required:
|
||||||
if not body.get(position):
|
if position not in body:
|
||||||
return {
|
return {
|
||||||
'error': f'missing required position: {position}'
|
'error': f'missing required position: {position}'
|
||||||
}, 400
|
}, 400
|
||||||
|
|
|
@ -28,8 +28,7 @@ class UpdateMemberPositionsTransaction(AbstractTransaction):
|
||||||
# Reverse the dict so it's easier to use (username -> positions)
|
# Reverse the dict so it's easier to use (username -> positions)
|
||||||
self.positions = defaultdict(list)
|
self.positions = defaultdict(list)
|
||||||
for position, username in positions_reversed.items():
|
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)
|
# a cached Dict of the Users who need to be modified (username -> User)
|
||||||
self.users: Dict[str, IUser] = {}
|
self.users: Dict[str, IUser] = {}
|
||||||
|
|
Loading…
Reference in New Issue