Commit 8b83060e91558eedc32f7378352de609f81217aa

Fix update route accepting duplicate paragraph ids in certain cases
timApp/documentmodel/document.py
(4 / 0)
  
771771 'This is probably a TIM bug; please report it. '
772772 f'Additional information: {e}')
773773 blocks = dp_orig.get_blocks()
774 new_ids = set(p['id'] for p in new_pars) - set(p['id'] for p in blocks)
775 conflicting_ids = new_ids & set(self.get_par_ids())
776 if conflicting_ids:
777 raise ValidationException(f'Duplicate paragraph id(s): {", ".join(conflicting_ids)}')
774778 old_pars = [DocParagraph.from_dict(doc=self, d=d)
775779 for d in blocks]
776780 return self._perform_update(new_pars, old_pars)
timApp/tests/server/test_editing.py
(9 / 0)
  
138138 self.login_test1()
139139 d = self.create_doc()
140140 self.new_par(d.document, 'test', next_id='xxx', expect_status=400)
141
142 def test_invalid_update(self):
143 self.login_test1()
144 d = self.create_doc(initial_par='test')
145 par = d.document.get_paragraphs()[0]
146 md = d.document.export_markdown()
147 self.json_post(f'/update/{d.id}', {'fulltext': md, 'original': ''}, expect_status=400,
148 expect_content={'error': f'Duplicate paragraph id(s): {par.get_id()}'})
149 self.get(d.url)