diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 8b83a3db..e1e9d553 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -163,25 +163,28 @@ class Annotation(models.Model): self.sortvalue = None self.languages = None - if not self.clip or self.start != self.clip.start or self.end != self.clip.end: - self.clip, created = Clip.get_or_create(self.item, self.start, self.end) - with transaction.atomic(): + if not self.clip or self.start != self.clip.start or self.end != self.clip.end: + self.clip, created = Clip.get_or_create(self.item, self.start, self.end) + if set_public_id: self.set_public_id() super(Annotation, self).save(*args, **kwargs) - if self.clip: - self.clip.update_findvalue() - setattr(self.clip, self.layer, True) - self.clip.save(update_fields=[self.layer, 'sortvalue', 'findvalue']) + if self.clip: + Clip.objects.filter(**{ + 'id': self.clip.id, + self.layer: False + }).update(**{self.layer: True}) + # update clip.findvalue + self.clip.save() - # update matches in bulk if called from load_subtitles - if not delay_matches: - self.update_matches() - self.update_documents() - self.update_translations() + # update matches in bulk if called from load_subtitles + if not delay_matches: + self.update_matches() + self.update_documents() + self.update_translations() def update_matches(self): from place.models import Place diff --git a/pandora/clip/models.py b/pandora/clip/models.py index 8ae0cd11..d3639baa 100644 --- a/pandora/clip/models.py +++ b/pandora/clip/models.py @@ -60,7 +60,9 @@ class MetaClip(object): self.hue = self.saturation = self.lightness = 0 self.volume = 0 - def update_findvalue(self): + def save(self, *args, **kwargs): + if self.duration != self.end - self.start: + self.update_calculated_values() if not self.aspect_ratio and self.item: streams = self.item.streams() if streams: @@ -88,11 +90,6 @@ class MetaClip(object): self.findvalue = '\n'.join(list(filter(None, [a.findvalue for a in anns]))) for l in [k['id'] for k in settings.CONFIG['layers']]: setattr(self, l, l in anns_by_layer and bool(len(anns_by_layer[l]))) - - def save(self, *args, **kwargs): - if self.duration != self.end - self.start: - self.update_calculated_values() - self.update_findvalue() models.Model.save(self, *args, **kwargs) clip_keys = ('id', 'in', 'out', 'position', 'created', 'modified', diff --git a/pandora/document/fulltext.py b/pandora/document/fulltext.py index 0de8adca..1872b9ce 100644 --- a/pandora/document/fulltext.py +++ b/pandora/document/fulltext.py @@ -1,4 +1,3 @@ -import logging import os import subprocess import tempfile @@ -6,9 +5,6 @@ import tempfile from django.conf import settings -logger = logging.getLogger('pandora.' + __name__) - - def extract_text(pdf, page=None): if page is not None: page = str(page) @@ -70,8 +66,6 @@ class FulltextMixin: res = self.elasticsearch().delete(index=self._ES_INDEX, doc_type=self._ES_DOC_TYPE, id=self.id) except NotFoundError: pass - except: - logger.error('failed to delete fulltext document', exc_info=True) def update_fulltext(self): if self.has_fulltext_key(): diff --git a/static/js/utils.js b/static/js/utils.js index 067822e5..2b6833f7 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -559,7 +559,7 @@ pandora.uploadDroppedFiles = function(files) { var clips, type = getType(items); if (Ox.isUndefined(callback)) { callback = index; - index = pandora.$ui.editPanel && pandora.$ui.editPanel.getPasteIndex + index = pandora.$ui.editPanel ? pandora.$ui.editPanel.getPasteIndex() : void 0; }