diff --git a/cms/server/admin/templates/macro/pages.html b/cms/server/admin/templates/macro/pages.html
new file mode 100644
index 0000000000..fd6884cca7
--- /dev/null
+++ b/cms/server/admin/templates/macro/pages.html
@@ -0,0 +1,40 @@
+{% macro selector(page_url, page, pages) -%}
+{#
+Show a page selector for a paginated view.
+
+page_url (Url): the URL instance referring to the page displaying the table.
+page (int): 0-based number of the current page.
+pages (int): total number of pages.
+#}
+
+ {% if pages > 1 %}
+
+ Pages:
+ {% if pages <= 20 %}
+ {{ range_selector(page_url, page, pages, 0, pages) }}
+ {% else %}
+ {% if page != 0 %}
+
First
+ {% endif %}
+ {{ range_selector(page_url, page, pages, page - 2, pages + 3) }}
+ {% if page != pages - 1 %}
+
Last
+ {% endif %}
+ {% endif %}
+
+ {% endif %}
+{%- endmacro %}
+
+
+{% macro range_selector(page_url, page, pages, start, end) -%}
+{#
+Show a page range selector from start (included) to end (excluded).
+#}
+ {% for i in range([0, start]|max, [pages, end]|min) %}
+ {% if i != page %}
+ {{ i + 1 }}
+ {% else %}
+ {{ i + 1 }}
+ {% endif %}
+ {% endfor %}
+{%- endmacro %}
diff --git a/cms/server/admin/templates/fragments/reevaluation_buttons.html b/cms/server/admin/templates/macro/reevaluation_buttons.html
similarity index 87%
rename from cms/server/admin/templates/fragments/reevaluation_buttons.html
rename to cms/server/admin/templates/macro/reevaluation_buttons.html
index 121d366230..7e769d0cd9 100644
--- a/cms/server/admin/templates/fragments/reevaluation_buttons.html
+++ b/cms/server/admin/templates/macro/reevaluation_buttons.html
@@ -1,8 +1,9 @@
-{% macro ReevaluationButtons(next_page,
- submission_id=None,
- dataset_id=None,
- participation_id=None,
- contest_id=None) %}
+{% macro reevaluation_buttons(allowed,
+ next_page,
+ submission_id=None,
+ dataset_id=None,
+ participation_id=None,
+ contest_id=None) %}
{#
Render reevaluation buttons for the given filters.
@@ -16,6 +17,7 @@
- contest_id: reevaluate all submission results of the contest (of all
participations and tasks, for all datasets).
+allowed (bool): whether the logged in admin is allowed to reevaluate.
next_page (str): the URL to redirect to after the invalidation request
has been sent.
submission_id (int|None): id of the submission to invalidate.
@@ -42,7 +44,7 @@
'level': 'compilation'},
function(response) { utils.redirect_if_ok('{{ next_page }}', response); }
);"
-{% if not admin.permission_all %}
+{% if not allowed %}
disabled
{% endif %}
title="Compilation" >C
@@ -55,7 +57,7 @@
'level': 'evaluation'},
function(response) { utils.redirect_if_ok('{{ next_page }}', response); }
);"
-{% if not admin.permission_all %}
+{% if not allowed %}
disabled
{% endif %}
title="Evaluation" >E
@@ -68,7 +70,7 @@
},
function(response) { utils.redirect_if_ok('{{ next_page }}', response); }
);"
-{% if not admin.permission_all %}
+{% if not allowed %}
disabled
{% endif %}
title="Score" >S
diff --git a/cms/server/admin/templates/fragments/submission_row.html b/cms/server/admin/templates/macro/submission.html
similarity index 69%
rename from cms/server/admin/templates/fragments/submission_row.html
rename to cms/server/admin/templates/macro/submission.html
index e384d49b14..75a81f4620 100644
--- a/cms/server/admin/templates/fragments/submission_row.html
+++ b/cms/server/admin/templates/macro/submission.html
@@ -1,8 +1,64 @@
-{# This snippet shows a row of a submission table using the variable s as input #}
+{% import "macro/reevaluation_buttons.html" as macro_reevaluation_buttons %}
+{% import 'macro/pages.html' as macro_pages %}
+
+
+{% macro rows(admin, url, page_url, submissions, page, pages, dataset=none) -%}
+{#
+Render a table of submission data.
+
+admin (Admin): the logged in admin.
+url (Url): the URL instance referring to the root of AWS.
+page_url (Url): the URL instance referring to the page displaying the table.
+submissions ([Submissions]): the list of submissions to display in the table
+ (current page only).
+page (int): 0-based number of the current page.
+pages (int): total number of pages.
+dataset (Dataset|None): the dataset to show results for, or if not defined use
+ the active one.
+#}
+{% if pages == 0 %}
+No submissions found.
-{% if shown_dataset is defined %}
- {% set dataset = shown_dataset %}
{% else %}
+
+{{ macro_pages.selector(page_url, page, pages) }}
+
+
+
+
+ | Time |
+ User |
+ Task |
+ Status |
+ Files |
+ Token |
+ Official |
+ Comment |
+ Reevaluate |
+
+
+
+ {% for s in submissions|sort(attribute="timestamp")|reverse %}
+ {{ row(admin, url, s, dataset) }}
+ {% endfor %}
+
+
+{% endif %}
+{%- endmacro %}
+
+
+{% macro row(admin, url, s, dataset=None) -%}
+{#
+Render a table's row containing a submission data.
+
+admin (Admin): the logged in admin.
+url (Url): the URL instance referring to the root of AWS.
+s (Submission): the submission to render.
+dataset (Dataset|None): the dataset to show results for, or if not defined use
+ the active one.
+#}
+
+{% if dataset is none %}
{% set dataset = s.task.active_dataset %}
{% endif %}
@@ -113,9 +169,12 @@ Compilation output
{# TODO: trim long outputs and add facility to see ra
{{ s.short_comment }}
- {{ ReevaluationButtons(
+ {{ macro_reevaluation_buttons.reevaluation_buttons(
+ admin.permission_all,
url("submission", s.id, dataset.id),
submission_id=s.id,
dataset_id=dataset.id) }}
|
+
+{%- endmacro %}
diff --git a/cms/server/admin/templates/participation.html b/cms/server/admin/templates/participation.html
index f31b0576f5..f4e5e22eee 100644
--- a/cms/server/admin/templates/participation.html
+++ b/cms/server/admin/templates/participation.html
@@ -1,4 +1,7 @@
+{% import "macro/reevaluation_buttons.html" as macro_reevaluation_buttons %}
+
{% extends "base.html" %}
+{% import 'macro/submission.html' as macro_submission %}
{% block js %}
function question_reply_toggle(element, invoker)
@@ -36,13 +39,19 @@ Submissions
Reevaluate all {{ submission_count }} submissions for this user in this contest (for all datasets)
- {{ ReevaluationButtons(
+ {{ macro_reevaluation_buttons.reevaluation_buttons(
+ admin.permission_all,
url("contest", contest.id, "user", participation.user_id, "edit"),
participation_id=participation.id) }}
- {% set page_url = url["contest"][contest.id]["user"][selected_user.id]["edit"] %}
- {% include "fragments/submission_rows.html" %}
+ {{ macro_submission.rows(
+ admin,
+ url,
+ url["contest"][contest.id]["user"][selected_user.id]["edit"],
+ submissions,
+ submission_page,
+ submission_pages) }}
diff --git a/cms/server/admin/templates/submission.html b/cms/server/admin/templates/submission.html
index 22806ee7b6..c052b91ff5 100644
--- a/cms/server/admin/templates/submission.html
+++ b/cms/server/admin/templates/submission.html
@@ -1,3 +1,5 @@
+{% import "macro/reevaluation_buttons.html" as macro_reevaluation_buttons %}
+
{% extends "base.html" %}
{% block core %}
@@ -164,7 +166,8 @@ Submission details
| Reevaluate |
- {{ ReevaluationButtons(
+ {{ macro_reevaluation_buttons.reevaluation_buttons(
+ admin.permission_all,
url("submission", s.id, shown_dataset.id),
submission_id=s.id,
dataset_id=shown_dataset.id) }}
|