forked from 0x2620/pandora
only include static annotations for anonymous users
This commit is contained in:
parent
aff011cf28
commit
8530fa6f66
2 changed files with 11 additions and 9 deletions
|
@ -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()
|
||||
|
|
|
@ -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'] = '<br />\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'] = '<br />\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('/'),
|
||||
|
|
Loading…
Reference in a new issue