aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-03-27 15:29:56 +0000
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-03-27 15:29:56 +0000
commit9bab970043330c9f27f4b29a55f046a3b701f026 (patch)
tree8e50f32af741d9c3b38a7681d416e7b7d460b060
parentformatting (diff)
downloadAnnotateChange-9bab970043330c9f27f4b29a55f046a3b701f026.tar.gz
AnnotateChange-9bab970043330c9f27f4b29a55f046a3b701f026.zip
Allow admin to view annotations
-rw-r--r--app/admin/routes.py17
-rw-r--r--app/templates/admin/annotations.html22
-rw-r--r--app/templates/admin/index.html4
3 files changed, 43 insertions, 0 deletions
diff --git a/app/admin/routes.py b/app/admin/routes.py
index f8d72d2..bed0d18 100644
--- a/app/admin/routes.py
+++ b/app/admin/routes.py
@@ -168,6 +168,23 @@ def add_dataset():
return render_template("admin/add.html", title="Add Dataset", form=form)
+@bp.route("/annotations", methods=("GET",))
+@admin_required
+def view_annotations():
+ annotations = (
+ Annotation.query.join(Task, Annotation.task)
+ .join(User, Task.user)
+ .join(Dataset, Task.dataset)
+ .order_by(Dataset.name, User.username, Annotation.cp_index)
+ .all()
+ )
+ return render_template(
+ "admin/annotations.html",
+ title="View Annotations",
+ annotations=annotations,
+ )
+
+
@bp.route("/", methods=("GET",))
@admin_required
def index():
diff --git a/app/templates/admin/annotations.html b/app/templates/admin/annotations.html
new file mode 100644
index 0000000..4807b8e
--- /dev/null
+++ b/app/templates/admin/annotations.html
@@ -0,0 +1,22 @@
+{% extends "base.html" %}
+
+{% block app_content %}
+<h1>View Annotations</h1>
+<article class="overview">
+ <table class="table table-striped">
+ <thead class="thead-dark">
+ <th scope="col">Dataset</th>
+ <th scope="col">Username</th>
+ <th scope="col">Changepoint Index</th>
+ </thead>
+ {% for ann in annotations %}
+ <tr>
+ <td>{{ ann.task.dataset.name }}</td>
+ <td>{{ ann.task.user.username }}</td>
+ <td>{% if ann.cp_index is none %}No CP{% else %}{{ ann.cp_index }}{% endif %}</td>
+ </tr>
+ {% endfor %}
+ </tr>
+ </table>
+</article>
+{% endblock %}
diff --git a/app/templates/admin/index.html b/app/templates/admin/index.html
index c6b1f25..a8a8c73 100644
--- a/app/templates/admin/index.html
+++ b/app/templates/admin/index.html
@@ -18,5 +18,9 @@
<a href="{{ url_for("admin.manage_datasets") }}">View and
manage datasets</a>
</li>
+ <li>
+ <a href="{{ url_for("admin.view_annotations") }}">View
+ annotations</a>
+ </li>
</ul>
{% endblock %}