Made changes to CSS and merged together.
This commit is contained in:
@@ -58,16 +58,42 @@ def edit_child(id):
|
||||
result = child_db.search(ChildQuery.id == id)
|
||||
if not result:
|
||||
return jsonify({'error': 'Child not found'}), 404
|
||||
child = result[0]
|
||||
child = Child.from_dict(result[0])
|
||||
|
||||
if name is not None:
|
||||
child['name'] = name
|
||||
child.name = name
|
||||
if age is not None:
|
||||
child['age'] = age
|
||||
child.age = age
|
||||
if points is not None:
|
||||
child['points'] = points
|
||||
child.points = points
|
||||
if image is not None:
|
||||
child['image_id'] = image
|
||||
child_db.update(child, ChildQuery.id == id)
|
||||
child.image_id = image
|
||||
|
||||
# Check if points changed and handle pending rewards
|
||||
if points is not None:
|
||||
PendingQuery = Query()
|
||||
pending_rewards = pending_reward_db.search(PendingQuery.child_id == id)
|
||||
|
||||
RewardQuery = Query()
|
||||
for pr in pending_rewards:
|
||||
pending = PendingReward.from_dict(pr)
|
||||
reward_result = reward_db.get(RewardQuery.id == pending.reward_id)
|
||||
if reward_result:
|
||||
reward = Reward.from_dict(reward_result)
|
||||
# If child can no longer afford the reward, remove the pending request
|
||||
if child.points < reward.cost:
|
||||
pending_reward_db.remove(
|
||||
(PendingQuery.child_id == id) & (PendingQuery.reward_id == reward.id)
|
||||
)
|
||||
send_event_to_user(
|
||||
"user123",
|
||||
Event(
|
||||
EventType.CHILD_REWARD_REQUEST.value,
|
||||
ChildRewardRequest(id, reward.id, ChildRewardRequest.REQUEST_CANCELLED)
|
||||
)
|
||||
)
|
||||
|
||||
child_db.update(child.to_dict(), ChildQuery.id == id)
|
||||
send_event_to_user("user123", Event(EventType.CHILD_MODIFIED.value, ChildModified(id, ChildModified.OPERATION_EDIT)))
|
||||
return jsonify({'message': f'Child {id} updated.'}), 200
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# file: config/version.py
|
||||
import os
|
||||
|
||||
BASE_VERSION = "1.0.2" # update manually when releasing features
|
||||
BASE_VERSION = "1.0.3" # update manually when releasing features
|
||||
|
||||
def get_full_version() -> str:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user