update
This commit is contained in:
@@ -39,11 +39,11 @@ def update_user(
|
||||
now_ = now()
|
||||
user = SimpleNamespace(**obj)
|
||||
# Get the user's CPF, if it exists.
|
||||
old_cpf = persistence_layer.collection.get_item(
|
||||
curr_cpf = persistence_layer.collection.get_item(
|
||||
KeyPair(
|
||||
pk=user.id,
|
||||
sk=SortKey('0', path_spec='cpf'),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
with persistence_layer.transact_writer() as transact:
|
||||
@@ -73,7 +73,7 @@ def update_user(
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
|
||||
if user.cpf != old_cpf:
|
||||
if user.cpf != curr_cpf:
|
||||
transact.put(
|
||||
item={
|
||||
'id': 'cpf',
|
||||
@@ -85,9 +85,9 @@ def update_user(
|
||||
exc_cls=CPFConflictError,
|
||||
)
|
||||
|
||||
# Ensures that the old CPF is discarded
|
||||
if old_cpf:
|
||||
transact.delete(key=KeyPair('cpf', old_cpf))
|
||||
# Ensures that the old CPF is discarded
|
||||
if curr_cpf:
|
||||
transact.delete(key=KeyPair('cpf', curr_cpf))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user