Skip to content
Snippets Groups Projects
Commit fa193be2 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #10898: do not allow task_id or resource_id of claim to be changed

parent 263e254c
No related branches found
No related tags found
No related merge requests found
......@@ -634,6 +634,16 @@ BEGIN
IF NEW.status_id = claim_claimed_status_id AND OLD.claim_size <> NEW.claim_size THEN
RAISE EXCEPTION 'cannot update claim size on claimed claim; old:% new:%', OLD, NEW;
END IF;
-- bounce any task_id updates
IF OLD.task_id <> NEW.task_id THEN
RAISE EXCEPTION 'cannot change the task to which a claim belongs; old:% new:%', OLD, NEW;
END IF;
-- bounce any resource_id updates
IF OLD.resource_id <> NEW.resource_id THEN
RAISE EXCEPTION 'cannot change the resource to which a claim belongs; old:% new:%', OLD, NEW;
END IF;
END IF;
--only check claim if status and/or claim_size and/or start/end time changed
......
......@@ -1119,6 +1119,13 @@ class ResourceAssignmentDatabaseTest(unittest.TestCase):
self.assertEqual(set([task_id1]), set(t['id'] for t in
self.radb.get_conflicting_overlapping_tasks(t2_claim_ids[0])))
#try to connect this claim to task1, should fail
self.assertFalse(self.radb.updateResourceClaims(t2_claim_ids, task_id=task_id1))
self.assertEqual(task_id2, t2_claims[0]['task_id'])
#try to connect this claim to other resource, should fail
self.assertFalse(self.radb.updateResourceClaims(t2_claim_ids, resource_id=118))
self.assertEqual(117, t2_claims[0]['resource_id'])
# try to update the task status to scheduled, should not succeed, since it's claims are not 'claimed' yet.
self.assertFalse(self.radb.updateTask(task_id2, task_status='scheduled'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment