make ids unique, don't throw execption, store empty annotations
This commit is contained in:
parent
435b6965b7
commit
6d954c79dd
1 changed files with 2 additions and 3 deletions
|
@ -60,7 +60,7 @@ class Text(models.Model):
|
||||||
elif 'edit' in self.data:
|
elif 'edit' in self.data:
|
||||||
return self.get_edit_annotations(api)
|
return self.get_edit_annotations(api)
|
||||||
else:
|
else:
|
||||||
raise Exception('Text does not have item or edit.')
|
return []
|
||||||
|
|
||||||
def get_item_annotations(self, api):
|
def get_item_annotations(self, api):
|
||||||
query = {
|
query = {
|
||||||
|
@ -93,7 +93,7 @@ class Text(models.Model):
|
||||||
return self.get_clips(api, annotations)
|
return self.get_clips(api, annotations)
|
||||||
|
|
||||||
def get_clips(self, 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 = {
|
query = {
|
||||||
'itemsQuery': {
|
'itemsQuery': {
|
||||||
'conditions': [{
|
'conditions': [{
|
||||||
|
@ -133,7 +133,6 @@ class Text(models.Model):
|
||||||
self.annotations = annotations
|
self.annotations = annotations
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def json(self):
|
def json(self):
|
||||||
data = {}
|
data = {}
|
||||||
data['title'] = self.title
|
data['title'] = self.title
|
||||||
|
|
Loading…
Reference in a new issue