to E: or not to E:

This commit is contained in:
j 2021-10-29 15:04:34 +01:00
parent b801c52847
commit 8997e05128
2 changed files with 22 additions and 3 deletions

View file

@ -339,7 +339,18 @@ function loadAnnotations(config) {
return !(config.user && annotation.user != config.user) return !(config.user && annotation.user != config.user)
}) })
loadClips(annotations).then(annotations => { loadClips(annotations).then(annotations => {
config.annotations = annotations config.annotations = annotations.filter(annotation => {
if (config.only_e) {
if (annotation.value.slice(0, 2) == 'E:') {
annotation.value = annotation.value.slice(2).trim()
return true
} else {
return false
}
} else {
return annotation.value.slice(0, 2) != 'E:'
}
})
renderAnnotations(config) renderAnnotations(config)
}) })
}) })
@ -358,7 +369,9 @@ function loadAnnotations(config) {
annotations.push(annotation) annotations.push(annotation)
} }
} else { } else {
annotations.push(annotation) if (annotation.value.slice(0, 2) != 'E:') {
annotations.push(annotation)
}
} }
}) })
}) })

View file

@ -79,6 +79,12 @@ class Text(models.Model):
user = self.data.get('user', None) user = self.data.get('user', None)
if user: if user:
annotations = list(filter(lambda annot: annot['user'] == user, annotations)) annotations = list(filter(lambda annot: annot['user'] == user, annotations))
if self.data.get('only_e'):
annotations = [e for e in annotations if e['value'].startswith('E:')]
for e in annotations:
e['value'] = e['value'][2:].strip()
else:
annotations = [e for e in annotations if not e['value'].startswith('E:')]
return self.get_clips(api, annotations) return self.get_clips(api, annotations)
def get_edit_annotations(self, api): def get_edit_annotations(self, api):
@ -101,7 +107,7 @@ class Text(models.Model):
if annotation['value'].startswith('E:'): if annotation['value'].startswith('E:'):
annotation['value'] = annotation['value'][2:].strip() annotation['value'] = annotation['value'][2:].strip()
annotations.append(annotation) annotations.append(annotation)
else: elif not annotation['value'].startswith('E:'):
annotations.append(annotation) annotations.append(annotation)
return self.get_clips(api, annotations) return self.get_clips(api, annotations)