diff --git a/app/models.py b/app/models.py index eef4449..90b6a32 100644 --- a/app/models.py +++ b/app/models.py @@ -302,3 +302,6 @@ def load_json(self, data): def editable_by(self, user): return user.is_authenticated() and user.id == self.user_id + + def is_closed(self): + return self.state == Annotation.STATE_CLOSED diff --git a/app/views.py b/app/views.py index 9dfebb8..a5f16b6 100644 --- a/app/views.py +++ b/app/views.py @@ -20,6 +20,7 @@ from .auth import lm from .models import Annotation +from .models import AudioAnnotation from .models import Comment from .models import db from .models import Document @@ -125,8 +126,15 @@ def view_list(id): """ id = kore_id(id) doc = Document.query.get_or_404(id) - annotations = Annotation.query.filter_by(doc=id) - return render_template('list.html', + if doc.filetype == 'pdf' or doc.filetype == 'image': + annotations = Annotation.query.filter_by(doc=id) + template = 'list.html' + elif doc.filetype == 'audio': + annotations = AudioAnnotation.query.filter_by(doc_id=id) + template = 'list_audio.html' + else: + assert False, 'Unknown filetype: {}'.format(doc.filetype) + return render_template(template, doc=doc, annotations=annotations, ) diff --git a/static/coffee/audioplayer.coffee b/static/coffee/audioplayer.coffee index 48e5bdb..a680711 100644 --- a/static/coffee/audioplayer.coffee +++ b/static/coffee/audioplayer.coffee @@ -129,7 +129,11 @@ class AudioPlayer @ctx.fillRect wf, 0, aw, size for annotation in @annotations - @ctx.fillStyle = "orange" + switch annotation.state + when 'open' + @ctx.fillStyle = "orange" + when 'closed' + @ctx.fillStyle = "lightgreen" annStart = @secondsToPixels annotation.start annSize = @secondsToPixels annotation.length @ctx.fillRect wf, annStart, aw, annSize diff --git a/static/coffee/listview.coffee b/static/coffee/listview.coffee index cc0d5cd..f64505f 100644 --- a/static/coffee/listview.coffee +++ b/static/coffee/listview.coffee @@ -1,9 +1,9 @@ -list_view_init = -> +list_view_init = (base) -> $('.ann-state-checkbox').click -> annid = $(this).data 'annid' state = if @checked then 'closed' else 'open' $.ajax - url: '/annotation/' + annid + url: base + annid type: 'PUT' data: state: state diff --git a/templates/list.html b/templates/list.html index 7486c18..8956c72 100644 --- a/templates/list.html +++ b/templates/list.html @@ -37,6 +37,6 @@ {% endblock %} {% block js_end %} {% endblock %} diff --git a/templates/list_audio.html b/templates/list_audio.html new file mode 100644 index 0000000..a1b777d --- /dev/null +++ b/templates/list_audio.html @@ -0,0 +1,42 @@ +{% from 'macros.html' import annotation_state %} +{% extends "base.html" %} +{% block content %} + +
+ + + + + + + + + + {% for ann in annotations %} + + + + + + {% endfor %} + +
TimeTextDone?
{{ann.start|round(1)}} s{{ann.text}}{{annotation_state(ann)}}
+
+
+ +
+ +{% endblock %} +{% block js_end %} + +{% endblock %}