added fixes for bug plan 1.0.6RC01
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 5m43s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 5m43s
This commit is contained in:
@@ -3,11 +3,12 @@ from tinydb import Query
|
||||
|
||||
from api.utils import send_event_for_current_user, get_validated_user_id
|
||||
from events.types.child_tasks_set import ChildTasksSet
|
||||
from db.db import task_db, child_db
|
||||
from db.db import task_db, child_db, pending_confirmations_db
|
||||
from db.child_overrides import delete_overrides_for_entity
|
||||
from events.types.event import Event
|
||||
from events.types.event_types import EventType
|
||||
from events.types.task_modified import TaskModified
|
||||
from events.types.child_chore_confirmation import ChildChoreConfirmation
|
||||
from models.task import Task
|
||||
|
||||
task_api = Blueprint('task_api', __name__)
|
||||
@@ -176,7 +177,23 @@ def edit_task(id):
|
||||
|
||||
if not is_dirty:
|
||||
return jsonify({'error': 'No valid fields to update'}), 400
|
||||
|
||||
|
||||
# Reset pending chore confirmations when task is modified (points, type, etc.)
|
||||
# Completed (approved) chores stay in completed state
|
||||
if 'points' in data or 'type' in data:
|
||||
PendingQuery = Query()
|
||||
pending_chores = pending_confirmations_db.search(
|
||||
(PendingQuery.entity_id == id) & (PendingQuery.entity_type == 'chore') &
|
||||
(PendingQuery.status == 'pending')
|
||||
)
|
||||
for pc in pending_chores:
|
||||
pending_confirmations_db.remove(
|
||||
(PendingQuery.child_id == pc['child_id']) & (PendingQuery.entity_id == id) &
|
||||
(PendingQuery.entity_type == 'chore') & (PendingQuery.status == 'pending')
|
||||
)
|
||||
send_event_for_current_user(Event(EventType.CHILD_CHORE_CONFIRMATION.value,
|
||||
ChildChoreConfirmation(pc['child_id'], id, ChildChoreConfirmation.OPERATION_RESET)))
|
||||
|
||||
if task.user_id is None: # public task
|
||||
new_task = Task(name=task.name, points=task.points, type=task.type, image_id=task.image_id, user_id=user_id)
|
||||
task_db.insert(new_task.to_dict())
|
||||
|
||||
Reference in New Issue
Block a user