mirror of https://github.com/JohnHammond/CTFd.git
Add a basic layout for improved table granular reset
parent
b8b14a568e
commit
8a255f8b41
|
@ -14,10 +14,13 @@ from flask import (
|
|||
url_for,
|
||||
)
|
||||
|
||||
from CTFd.cache import cache, clear_config
|
||||
from CTFd.cache import cache, clear_config, clear_standings, clear_pages
|
||||
from CTFd.models import (
|
||||
Awards,
|
||||
Challenges,
|
||||
Configs,
|
||||
Notifications,
|
||||
Pages,
|
||||
Solves,
|
||||
Submissions,
|
||||
Teams,
|
||||
|
@ -176,19 +179,52 @@ def config():
|
|||
@admins_only
|
||||
def reset():
|
||||
if request.method == "POST":
|
||||
# Truncate Users, Teams, Submissions, Solves, Notifications, Awards, Unlocks, Tracking
|
||||
Tracking.query.delete()
|
||||
Solves.query.delete()
|
||||
Submissions.query.delete()
|
||||
Awards.query.delete()
|
||||
Unlocks.query.delete()
|
||||
Users.query.delete()
|
||||
Teams.query.delete()
|
||||
set_config("setup", False)
|
||||
require_setup = False
|
||||
logout = False
|
||||
next_url = url_for("admin.statistics")
|
||||
|
||||
data = request.form
|
||||
|
||||
if data.get("pages"):
|
||||
Pages.query.delete()
|
||||
# PageFiles
|
||||
|
||||
if data.get("notifications"):
|
||||
Notifications.query.delete()
|
||||
|
||||
if data.get("challenges"):
|
||||
Challenges.query.delete()
|
||||
# ChallengeFiles
|
||||
|
||||
if data.get("accounts"):
|
||||
Users.query.delete()
|
||||
Teams.query.delete()
|
||||
require_setup = True
|
||||
logout = True
|
||||
|
||||
if data.get("submissions"):
|
||||
Solves.query.delete()
|
||||
Submissions.query.delete()
|
||||
Awards.query.delete()
|
||||
Unlocks.query.delete()
|
||||
|
||||
if require_setup:
|
||||
set_config("setup", False)
|
||||
cache.clear()
|
||||
logout_user()
|
||||
next_url = url_for("views.setup")
|
||||
|
||||
db.session.commit()
|
||||
cache.clear()
|
||||
logout_user()
|
||||
|
||||
clear_pages()
|
||||
clear_standings()
|
||||
clear_config()
|
||||
|
||||
if logout is True:
|
||||
cache.clear()
|
||||
logout_user()
|
||||
|
||||
db.session.close()
|
||||
return redirect(url_for("views.setup"))
|
||||
return redirect(next_url)
|
||||
|
||||
return render_template("admin/reset.html")
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
or choose to form teams.
|
||||
</small>
|
||||
</label>
|
||||
<div data-toggle="tooltip" data-placement="bottom" title="In order to change User Mode you must reset your CTF">
|
||||
<div data-toggle="tooltip" data-placement="bottom" title="In order to change User Mode you must reset your CTF and delete all accounts">
|
||||
<select class="form-control custom-select" id="user_mode" name="user_mode" disabled="true" style="z-index: -1;">
|
||||
<option value="teams" {% if user_mode == 'teams' %}selected{% endif %}>
|
||||
Teams
|
||||
|
|
|
@ -15,8 +15,11 @@
|
|||
<form method="POST" id="reset-ctf-form">
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<p>
|
||||
Resetting your CTF will delete all user and team data. Think carefully before resetting because
|
||||
no automated backups are made and all non-challenge data is lost.
|
||||
Resetting your CTF will delete the selected data <strong>PERMANENTLY</strong>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Think carefully before resetting because no automated backups are made and all selected data will be lost.
|
||||
</p>
|
||||
|
||||
<span>
|
||||
|
@ -27,6 +30,40 @@
|
|||
</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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<div class="form-check pb-1">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" type="checkbox" name="pages"> Pages (Pages)
|
||||
</label>
|
||||
</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>
|
||||
|
||||
<br>
|
||||
|
||||
<input id="nonce" type="hidden" name="nonce" value="{{ nonce }}">
|
||||
|
||||
<button class="btn btn-warning btn-lg btn-block">
|
||||
|
|
Loading…
Reference in New Issue