From 44d1ea300bbde367d3fe90b5281ce13c005ff378 Mon Sep 17 00:00:00 2001 From: CodeKevin Date: Fri, 5 Feb 2016 19:29:44 -0500 Subject: [PATCH] Allowing for deletion of solves and wrong keys --- CTFd/admin.py | 11 ++- CTFd/templates/admin/correct_keys.html | 65 ++++++------ CTFd/templates/admin/team.html | 131 ++++++++++++++++++++----- CTFd/templates/admin/wrong_keys.html | 78 ++++++++++++++- 4 files changed, 222 insertions(+), 63 deletions(-) diff --git a/CTFd/admin.py b/CTFd/admin.py index aef2e981..ffc339fe 100644 --- a/CTFd/admin.py +++ b/CTFd/admin.py @@ -485,6 +485,15 @@ def delete_solve(teamid, chalid): return '1' +@admin.route('/admin/wrong_keys///delete', methods=['POST']) +@admins_only +def delete_wrong_key(teamid, chalid): + wrong_key = WrongKeys.query.filter_by(team=teamid, chalid=chalid).first() + db.session.delete(wrong_key) + db.session.commit() + return '1' + + @admin.route('/admin/statistics', methods=['GET']) @admins_only def admin_stats(): @@ -516,7 +525,7 @@ def admin_wrong_key(page='1'): page_start = results_per_page * ( page - 1 ) page_end = results_per_page * ( page - 1 ) + results_per_page - wrong_keys = WrongKeys.query.add_columns(WrongKeys.flag, WrongKeys.team, WrongKeys.date,\ + wrong_keys = WrongKeys.query.add_columns(WrongKeys.chalid, WrongKeys.flag, WrongKeys.team, WrongKeys.date,\ Challenges.name.label('chal_name'), Teams.name.label('team_name')).\ join(Challenges).join(Teams).order_by('team_name ASC').slice(page_start, page_end).all() diff --git a/CTFd/templates/admin/correct_keys.html b/CTFd/templates/admin/correct_keys.html index 3d20b063..7d3cc590 100644 --- a/CTFd/templates/admin/correct_keys.html +++ b/CTFd/templates/admin/correct_keys.html @@ -18,7 +18,7 @@

Delete Key

- +
- + - {% endfor %} @@ -71,33 +70,37 @@ {% endblock %} {% block scripts %} - + + + + + $('.fa-times').click(function(){ + var elem = $(this).parent().parent(); + var chal = elem.find('.chal').attr('id'); + var chal_name = elem.find('.chal').text().trim(); + var team = elem.find('.team').attr('id'); + var team_name = elem.find('.team').text().trim(); + load_confirm_modal(team, chal, team_name, chal_name) + }); + {% endblock %} diff --git a/CTFd/templates/admin/team.html b/CTFd/templates/admin/team.html index 1fbccde7..1e8042ab 100644 --- a/CTFd/templates/admin/team.html +++ b/CTFd/templates/admin/team.html @@ -1,9 +1,44 @@ {% extends "admin/base.html" %} +{% block stylesheets %} + +{% endblock %} + {% block content %}
+ + +

{{ team.name }}

{{ team.email }}

@@ -23,40 +58,45 @@

Team @@ -50,10 +50,9 @@
{{ solve.team_name }} {{ solve.chal_name }}{{ solve.date }}{{ solve.date|unix_time_millis }} {{ solve.flag }}
-

Solves

+

IP Addresses

- - - - - - - + + + + - {% for solve in solves %} + {% for addr in addrs %} - - - - - + + {% endfor %}
ChallengeSubmittedCategoryValueTime
IP AddressLast Seen
{{ solve.chal.name }}{{ solve.flag }}{{ solve.chal.category }}{{ solve.chal.value }}{{ solve.date|unix_time_millis }}{{ addr.ip|long2ip }}{{ addr.date|unix_time_millis }}
-

IP Addresses

+

Solves

- - + + + + + + - {% for addr in addrs %} - + {% for solve in solves %} + + + + + + + + {% endfor %}
IP AddressLast SeenChallengeSubmittedCategoryValueTimeDelete
{{ addr.ip|long2ip }}{{ addr.date|unix_time_millis }}
{{ solve.chal.name }}{{ solve.flag }}{{ solve.chal.category }}{{ solve.chal.value }}{{ solve.date|unix_time_millis }}
@@ -65,17 +105,19 @@

Wrong Keys

- Challenge - Submitted - Time + Challenge + Submitted + Time + Delete {% for wrong_key in wrong_keys %} - - {{ wrong_key.chal.name }} - {{ wrong_key.flag }} - {{ wrong_key.date|unix_time_millis }} + + {{ wrong_key.chal.name }} + {{ wrong_key.flag }} + {{ wrong_key.date|unix_time_millis }} + {% endfor %} @@ -90,4 +132,41 @@ + {% endblock %} diff --git a/CTFd/templates/admin/wrong_keys.html b/CTFd/templates/admin/wrong_keys.html index a6fc6d66..05cdc00e 100644 --- a/CTFd/templates/admin/wrong_keys.html +++ b/CTFd/templates/admin/wrong_keys.html @@ -1,10 +1,43 @@ {% extends "admin/base.html" %} +{% block stylesheets %} + +{% endblock %} + {% block content %}

Incorrect Key Submissions

- + +
+ {% for wrong_key in wrong_keys %} - - + + - + {% endfor %} @@ -42,4 +77,37 @@ {% endblock %} {% block scripts %} + + + + + {% endblock %}
Team @@ -15,16 +48,18 @@ Submitted Key Delete +
{{ wrong_key.team_name }} - {{ wrong_key.chal_name }}{{ wrong_key.date }}{{ wrong_key.team_name }} + {{ wrong_key.chal_name }}{{ wrong_key.date|unix_time_millis }} {{ wrong_key.flag }}