Skip to content

Commit 44d7a09

Browse files
authored
Merge pull request #238 from hltcoe/improve_admin_stats_pages
Improve admin stats pages
2 parents ea40cda + cf31fe7 commit 44d7a09

6 files changed

Lines changed: 49 additions & 91 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Upgraded to Django 4.2
1010
- Made the main batch table sortable
1111
- Updated documentation on the API including the client
12+
- Updated theme for admin stats pages
1213
### Added
1314
- QuickStart guide for setting up a server
1415
- TURKLE_AUTO_ACCPET_DEFAULT setting

turkle/admin.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ def batch_stats(self, request, batch_id):
523523
mean_work_time = 'N/A'
524524
median_work_time = 'N/A'
525525

526-
return render(request, 'admin/turkle/batch_stats.html', {
526+
context = admin.site.each_context(request)
527+
context['title'] = f'Stats for Batch: {batch.name}'
528+
529+
context.update({
527530
'batch': batch,
528531
'batch_total_work_time': total_work_time,
529532
'batch_mean_work_time': mean_work_time,
@@ -534,6 +537,8 @@ def batch_stats(self, request, batch_id):
534537
'stats_users': stats_users,
535538
})
536539

540+
return render(request, 'admin/turkle/batch_stats.html', context)
541+
537542
def cancel_batch(self, request, batch_id):
538543
try:
539544
batch = Batch.objects.get(id=batch_id)
@@ -1111,7 +1116,10 @@ def project_stats(self, request, project_id):
11111116
mean_work_time = 'N/A'
11121117
median_work_time = 'N/A'
11131118

1114-
return render(request, 'admin/turkle/project_stats.html', {
1119+
context = admin.site.each_context(request)
1120+
context['title'] = f'Stats for Project: {project.name}'
1121+
1122+
context.update({
11151123
'project': project,
11161124
'project_total_completed_assignments': len(tasks),
11171125
'project_total_completed_assignments_1_day': tca_1_day,
@@ -1131,6 +1139,8 @@ def project_stats(self, request, project_id):
11311139
'uncompleted_tas_inactive_batches': uncompleted_tas_inactive_batches,
11321140
})
11331141

1142+
return render(request, 'admin/turkle/project_stats.html', context)
1143+
11341144
def publish_tasks(self, instance):
11351145
publish_tasks_url = '%s?project=%d' % (
11361146
reverse('admin:turkle_batch_add'),

turkle/templates/admin/base_bootcamp.html

Lines changed: 0 additions & 57 deletions
This file was deleted.

turkle/templates/admin/stats.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% extends "admin/base_site.html" %}
2+
{% load static %}
3+
4+
{% block extrahead %}
5+
{{ block.super }}
6+
<script type="text/javascript" src="{% static 'turkle/jquery-3.3.1.min.js' %}"></script>
7+
<script type="text/javascript" src="{% static 'turkle/datatables/datatables.min.js' %}"></script>
8+
<script type="text/javascript" src="{% static 'turkle/d3-3.5.17.min.js' %}"></script>
9+
<script type="text/javascript" src="{% static 'turkle/cal-heatmap-3.6.2.min.js' %}"></script>
10+
<link href="{% static 'turkle/datatables/datatables.bootstrap4.min.css' %}" rel="stylesheet" type="text/css"/>
11+
<link href="{% static 'turkle/cal-heatmap.css' %}" rel="stylesheet" type="text/css"/>
12+
{% endblock %}

turkle/templates/admin/turkle/batch_stats.html

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
{% extends "admin/base_bootcamp.html" %}
1+
{% extends "admin/stats.html" %}
22
{% load static %}
33

4-
{% block header %}
5-
<script type="text/javascript" src="{% static 'turkle/jquery-3.3.1.min.js' %}"></script>
6-
<script type="text/javascript" src="{% static 'turkle/datatables/datatables.min.js' %}"></script>
7-
<script type="text/javascript" src="{% static 'turkle/d3-3.5.17.min.js' %}"></script>
8-
<script type="text/javascript" src="{% static 'turkle/cal-heatmap-3.6.2.min.js' %}"></script>
9-
<link href="{% static 'turkle/datatables/datatables.bootstrap4.min.css' %}" rel="stylesheet" type="text/css"/>
10-
<link href="{% static 'turkle/cal-heatmap.css' %}" rel="stylesheet" type="text/css"/>
4+
{% block extrahead %}
5+
{{ block.super }}
116
<style>
127
#activity-calendar-container {
138
margin-bottom: 1em;
@@ -54,14 +49,18 @@
5449
</script>
5550
{% endblock %}
5651

57-
{% block body %}
52+
{% block breadcrumbs %}
53+
<div class="breadcrumbs">
54+
<a href="{% url 'admin:index' %}">Home</a>
55+
&rsaquo; <a href="{% url 'admin:app_list' app_label='turkle' %}">Turkle</a>
56+
&rsaquo; <a href="{% url 'admin:turkle_batch_changelist' %}">Batches</a>
57+
&rsaquo; Stats
58+
</div>
59+
{% endblock %}
5860

61+
{% block content %}
5962
<div class="container mt-2">
6063

61-
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
62-
63-
<h2>Batch Statistics</h2>
64-
6564
<div>
6665
<table class="table table-sm table-bordered thead-light">
6766
<tr>
@@ -129,12 +128,6 @@ <h2>Batch Statistics</h2>
129128
<th>Median Time / Assignment</th>
130129
<td>{{ batch_median_work_time}}</td>
131130
</tr>
132-
<!--
133-
<tr>
134-
<th></th>
135-
<td></td>
136-
</tr>
137-
-->
138131
</table>
139132
</div>
140133

turkle/templates/admin/turkle/project_stats.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
{% extends "admin/base_bootcamp.html" %}
1+
{% extends "admin/stats.html" %}
22
{% load static %}
33

4-
{% block header %}
5-
<script type="text/javascript" src="{% static 'turkle/jquery-3.3.1.min.js' %}"></script>
6-
<script type="text/javascript" src="{% static 'turkle/datatables/datatables.min.js' %}"></script>
7-
<script type="text/javascript" src="{% static 'turkle/d3-3.5.17.min.js' %}"></script>
8-
<script type="text/javascript" src="{% static 'turkle/cal-heatmap-3.6.2.min.js' %}"></script>
9-
<link href="{% static 'turkle/datatables/datatables.bootstrap4.min.css' %}" rel="stylesheet" type="text/css"/>
10-
<link href="{% static 'turkle/cal-heatmap.css' %}" rel="stylesheet" type="text/css"/>
4+
{% block extrahead %}
5+
{{ block.super }}
116
<style>
127
.substat td {
138
padding-left: 2em;
@@ -58,14 +53,18 @@
5853
</script>
5954
{% endblock %}
6055

61-
{% block body %}
56+
{% block breadcrumbs %}
57+
<div class="breadcrumbs">
58+
<a href="{% url 'admin:index' %}">Home</a>
59+
&rsaquo; <a href="{% url 'admin:app_list' app_label='turkle' %}">Turkle</a>
60+
&rsaquo; <a href="{% url 'admin:turkle_project_changelist' %}">Projects</a>
61+
&rsaquo; Stats
62+
</div>
63+
{% endblock %}
6264

65+
{% block content %}
6366
<div class="container mt-2">
6467

65-
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
66-
67-
<h2>Project Statistics</h2>
68-
6968
<div>
7069
<table class="table table-sm table-bordered thead-light">
7170
<tr>

0 commit comments

Comments
 (0)