mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
Fix up reset ui
This commit is contained in:
@@ -24,6 +24,7 @@ from CTFd.models import (
|
||||
Solves,
|
||||
Submissions,
|
||||
Teams,
|
||||
Tracking,
|
||||
Unlocks,
|
||||
Users,
|
||||
db,
|
||||
@@ -214,6 +215,7 @@ def reset():
|
||||
Submissions.query.delete()
|
||||
Awards.query.delete()
|
||||
Unlocks.query.delete()
|
||||
Tracking.query.delete()
|
||||
|
||||
if require_setup:
|
||||
set_config("setup", False)
|
||||
|
||||
@@ -15,7 +15,12 @@
|
||||
<form method="POST" id="reset-ctf-form">
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<p>
|
||||
Resetting your CTF will delete the selected data <strong>PERMANENTLY</strong>.
|
||||
Resetting your CTFd instance allows you to bulk delete data to prepare it for other events,
|
||||
classes, or otherwise get it to a clean state.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Resetting your CTFd instance will delete the selected data <strong>PERMANENTLY</strong>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -25,41 +30,70 @@
|
||||
<span>
|
||||
<strong>
|
||||
Create backups of all data you need by <a href="{{ url_for('admin.config', _anchor='backup') }}">creating a CTFd Export</a>
|
||||
or by copying the database and CTFd source code folder.
|
||||
</strong>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-check pb-1">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="accounts"> Accounts (Users, Teams, Submissions)
|
||||
</label>
|
||||
<div class="form-group pb-2">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="accounts"> Accounts
|
||||
</label>
|
||||
</div>
|
||||
<span class="text-muted">
|
||||
Deletes all user and team accounts and their associated information<br>
|
||||
<small>(Users, Teams, Submissions, Tracking)</small>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="form-check pb-1">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="submissions"> Submissions (Submissions, Awards, Unlocks)
|
||||
</label>
|
||||
<div class="form-group pb-2">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="submissions"> Submissions
|
||||
</label>
|
||||
</div>
|
||||
<span class="text-muted">
|
||||
Deletes all records that accounts gained points or took an action<br>
|
||||
<small>(Submissions, Awards, Unlocks, Tracking)</small>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="form-check pb-1">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="challenges"> Challenges (Challenges, Flags, Hints, Tags, Hints)
|
||||
</label>
|
||||
<div class="form-group pb-2">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="challenges"> Challenges
|
||||
</label>
|
||||
</div>
|
||||
<span class="text-muted">
|
||||
Deletes all challenges and associated data<br>
|
||||
<small>(Challenges, Flags, Hints, Tags, Challenge Files)</small>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="form-check pb-1">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="pages"> Pages (Pages)
|
||||
</label>
|
||||
<div class="form-group pb-2">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="pages"> Pages
|
||||
</label>
|
||||
</div>
|
||||
<span class="text-muted">
|
||||
Deletes all pages and their associated files<br>
|
||||
<small>(Pages, Page Files)</small>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="form-check pb-1">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="notifications"> Notifications (Notifications)
|
||||
</label>
|
||||
<div class="form-group pb-2">
|
||||
<div class="form-check">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="notifications"> Notifications
|
||||
</label>
|
||||
</div>
|
||||
<span class="text-muted">
|
||||
Deletes all notifications<br>
|
||||
<small>(Notifications)</small>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
@@ -78,20 +78,6 @@ def test_reset():
|
||||
|
||||
client = login_as_user(app, name="admin", password="password")
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "submissions": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
assert r.location.endswith("/admin/statistics")
|
||||
assert Submissions.query.count() == 0
|
||||
assert Solves.query.count() == 0
|
||||
assert Fails.query.count() == 0
|
||||
assert Awards.query.count() == 0
|
||||
assert Unlocks.query.count() == 0
|
||||
assert Users.query.count() == 11
|
||||
assert Challenges.query.count() == 10
|
||||
assert Flags.query.count() == 10
|
||||
assert Tracking.query.count() == 11
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "pages": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
@@ -123,6 +109,20 @@ def test_reset():
|
||||
assert Users.query.count() == 11
|
||||
assert Tracking.query.count() == 11
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "submissions": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
assert r.location.endswith("/admin/statistics")
|
||||
assert Submissions.query.count() == 0
|
||||
assert Solves.query.count() == 0
|
||||
assert Fails.query.count() == 0
|
||||
assert Awards.query.count() == 0
|
||||
assert Unlocks.query.count() == 0
|
||||
assert Users.query.count() == 11
|
||||
assert Challenges.query.count() == 0
|
||||
assert Flags.query.count() == 0
|
||||
assert Tracking.query.count() == 0
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "accounts": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
@@ -187,21 +187,6 @@ def test_reset_team_mode():
|
||||
|
||||
client = login_as_user(app, name="admin", password="password")
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "submissions": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
assert r.location.endswith("/admin/statistics")
|
||||
assert Submissions.query.count() == 0
|
||||
assert Solves.query.count() == 0
|
||||
assert Fails.query.count() == 0
|
||||
assert Awards.query.count() == 0
|
||||
assert Unlocks.query.count() == 0
|
||||
assert Teams.query.count() == 10
|
||||
assert Users.query.count() == 51
|
||||
assert Challenges.query.count() == 10
|
||||
assert Flags.query.count() == 10
|
||||
assert Tracking.query.count() == 11
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "pages": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
@@ -236,6 +221,21 @@ def test_reset_team_mode():
|
||||
assert Users.query.count() == 51
|
||||
assert Tracking.query.count() == 11
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "submissions": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
assert r.location.endswith("/admin/statistics")
|
||||
assert Submissions.query.count() == 0
|
||||
assert Solves.query.count() == 0
|
||||
assert Fails.query.count() == 0
|
||||
assert Awards.query.count() == 0
|
||||
assert Unlocks.query.count() == 0
|
||||
assert Teams.query.count() == 10
|
||||
assert Users.query.count() == 51
|
||||
assert Challenges.query.count() == 0
|
||||
assert Flags.query.count() == 0
|
||||
assert Tracking.query.count() == 0
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {"nonce": sess.get("nonce"), "accounts": "on"}
|
||||
r = client.post("/admin/reset", data=data)
|
||||
|
||||
Reference in New Issue
Block a user