Skip to content

Commit

Permalink
Merge pull request #990 from hashtopolis/isssue/989
Browse files Browse the repository at this point in the history
Fix update priority on task does not apply to taskwrapper
  • Loading branch information
zyronix authored Oct 24, 2023
2 parents 40d73c7 + ec67586 commit 9f45eaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ci/apiv2/test_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hashtopolis import Task
from hashtopolis import Task, TaskWrapper
from utils import BaseTest


Expand Down Expand Up @@ -75,3 +75,15 @@ def test_task_with_file(self):
task = self.create_task(hashlist, extra_payload=extra_payload)
obj = Task.objects.get(pk=task.id, expand='files')
self.assertListEqual([x.id for x in files], [x.id for x in obj.files_set])

def test_task_update_priority(self):
task = self.create_test_object()
obj = TaskWrapper.objects.get(pk=task.taskWrapperId)
self.assertEqual(task.priority, obj.priority)

new_priority = task.priority + 1234
task.priority = new_priority
task.save()

obj = TaskWrapper.objects.get(pk=task.taskWrapperId)
self.assertEqual(new_priority, obj.priority)
7 changes: 7 additions & 0 deletions src/inc/apiv2/model/tasks.routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public function updateObject(object $object, $data, $processed = []): void {
TaskUtils::archiveTask($object->getId(), $this->getCurrentUser());
}

/* Update connected TaskWrapper priority as well */
$key = Task::PRIORITY;
if (array_key_exists($key, $data)) {
array_push($processed, $key);
TaskUtils::updatePriority($object->getId(), $data[Task::PRIORITY], $this->getCurrentUser());
}

parent::updateObject($object, $data, $processed);
}
}
Expand Down

0 comments on commit 9f45eaf

Please sign in to comment.