Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/apps/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ def get_context_data(self, *args, **kwargs):
if not self.request.user.is_staff:
raise HttpResponse(status=404)

show_child_submissions = self.request.GET.get('show_child_submissions', False)

qs = Submission.objects.all()
qs = qs.filter(created_when__gte=now() - timedelta(days=2))
if not show_child_submissions:
qs = qs.filter(parent__isnull=True)
qs = qs.order_by('-created_when')
qs = qs.select_related('phase__competition', 'owner')

context = super().get_context_data(*args, **kwargs)
context['submissions'] = qs[:250]
context['show_child_submissions'] = show_child_submissions

for submission in context['submissions']:
# Get filesize from each submissions's data
Expand Down
32 changes: 32 additions & 0 deletions src/templates/pages/server_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
{% block content %}
<div class="ui container">
<h1>Recent submissions (up to 250 or 2 days old)</h1>
<label>
<input type="checkbox" id="show_child_checkbox" {% if show_child_submissions %}checked{% endif %}> Show child submissions
</label>
<span class="ui mini circular icon button"
data-tooltip="Child submissions are created when a competition has multiple tasks (one child for each task)."
data-position="top center">
<i class="question icon"></i>
</span>
<table class="ui table">
<thead>
<th>Competition</th>
<th>Submission PK</th>
{% if show_child_submissions %}
<th>Parent PK</th>
{% endif %}
<th>Size</th>
<th>Submitter</th>
<th>Queue</th>
Expand All @@ -28,6 +39,9 @@ <h1>Recent submissions (up to 250 or 2 days old)</h1>
<tr>
<td><a class="link-no-deco" target="_blank" href="./competitions/{{ submission.phase.competition.id }}">{{ submission.phase.competition.title }}</a></td>
<td>{{ submission.pk }}</td>
{% if show_child_submissions %}
<td>{{ submission.parent.pk }}</td>
{% endif %}
<td>{{ submission.file_size }}</td>
<td><a target="_blank" href="/profiles/user/{{ submission.owner.username }}">{{ submission.owner.username }}</a></td>
<td>{{ submission.competition_queue }}</td>
Expand Down Expand Up @@ -77,4 +91,22 @@ <h1>Monitor queues</h1>
</div>
</div>
</div>

<script>
document.addEventListener("DOMContentLoaded", function() {
const checkbox = document.getElementById("show_child_checkbox");

checkbox.addEventListener("change", function() {
const isChecked = checkbox.checked;
const url = new URL(window.location);
if (isChecked) {
url.searchParams.set('show_child_submissions', true);
} else {
url.searchParams.delete('show_child_submissions');
}
console.log(url)
window.location.href = url.toString();
});
});
</script>
{% endblock %}