diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index b2962597..fc0e5d98 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -80,7 +80,7 @@ class Annotation(models.Model): public_id = models.CharField(max_length=128, unique=True, null=True) #seconds start = models.FloatField(default=-1, db_index=True) - end = models.FloatField(default=-1) + end = models.FloatField(default=-1, db_index=True) layer = models.CharField(max_length=255, db_index=True) value = models.TextField() diff --git a/pandora/item/views.py b/pandora/item/views.py index bea18296..8d521b56 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -1075,14 +1075,16 @@ def item(request, id): data.append({'key': key.capitalize(), 'value': value}) clips = [] clip = {'in': 0, 'annotations': []} - for a in item.annotations.filter( - layer__in=models.Annotation.public_layers()).order_by('start', 'end', 'sortvalue'): - if clip['in'] < a.start: - if clip['annotations']: - clip['annotations'] = '
\n'.join(clip['annotations']) - clips.append(clip) - clip = {'in': a.start, 'annotations': []} - clip['annotations'].append(a.value) + #logged in users should have javascript. not adding annotations makes load faster + if request.user.is_anonymous(): + for a in item.annotations.filter( + layer__in=models.Annotation.public_layers()).order_by('start', 'end', 'sortvalue'): + if clip['in'] < a.start: + if clip['annotations']: + clip['annotations'] = '
\n'.join(clip['annotations']) + clips.append(clip) + clip = {'in': a.start, 'annotations': []} + clip['annotations'].append(a.value) ctx = { 'current_url': request.build_absolute_uri(request.get_full_path()), 'base_url': request.build_absolute_uri('/'),