From 6d954c79dde490a9e5c1c3debb3d7fae17e05da2 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 23 Oct 2021 15:36:13 +0100 Subject: [PATCH] make ids unique, don't throw execption, store empty annotations --- app/text/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/text/models.py b/app/text/models.py index 16b08d3..9849047 100644 --- a/app/text/models.py +++ b/app/text/models.py @@ -60,7 +60,7 @@ class Text(models.Model): elif 'edit' in self.data: return self.get_edit_annotations(api) else: - raise Exception('Text does not have item or edit.') + return [] def get_item_annotations(self, api): query = { @@ -93,7 +93,7 @@ class Text(models.Model): return self.get_clips(api, annotations) def get_clips(self, api, annotations): - item_ids = [annot['id'].split('/')[0] for annot in annotations] + item_ids = {annot['id'].split('/')[0] for annot in annotations} query = { 'itemsQuery': { 'conditions': [{ @@ -133,7 +133,6 @@ class Text(models.Model): self.annotations = annotations super().save(*args, **kwargs) - def json(self): data = {} data['title'] = self.title