mirror of https://github.com/JohnHammond/CTFd.git
Delete files when resetting pages and challenges
parent
1d33ed4cb2
commit
696872fee5
|
@ -36,6 +36,7 @@ from CTFd.utils.exports import export_ctf as export_ctf_util
|
||||||
from CTFd.utils.exports import import_ctf as import_ctf_util
|
from CTFd.utils.exports import import_ctf as import_ctf_util
|
||||||
from CTFd.utils.helpers import get_errors
|
from CTFd.utils.helpers import get_errors
|
||||||
from CTFd.utils.security.auth import logout_user
|
from CTFd.utils.security.auth import logout_user
|
||||||
|
from CTFd.utils.uploads import delete_file
|
||||||
from CTFd.utils.user import is_admin
|
from CTFd.utils.user import is_admin
|
||||||
|
|
||||||
admin = Blueprint("admin", __name__)
|
admin = Blueprint("admin", __name__)
|
||||||
|
@ -185,15 +186,22 @@ def reset():
|
||||||
data = request.form
|
data = request.form
|
||||||
|
|
||||||
if data.get("pages"):
|
if data.get("pages"):
|
||||||
|
_pages = Pages.query.all()
|
||||||
|
for p in _pages:
|
||||||
|
for f in p.files:
|
||||||
|
delete_file(file_id=f.id)
|
||||||
|
|
||||||
Pages.query.delete()
|
Pages.query.delete()
|
||||||
# PageFiles
|
|
||||||
|
|
||||||
if data.get("notifications"):
|
if data.get("notifications"):
|
||||||
Notifications.query.delete()
|
Notifications.query.delete()
|
||||||
|
|
||||||
if data.get("challenges"):
|
if data.get("challenges"):
|
||||||
|
_challenges = Challenges.query.all()
|
||||||
|
for c in _challenges:
|
||||||
|
for f in c.files:
|
||||||
|
delete_file(file_id=f.id)
|
||||||
Challenges.query.delete()
|
Challenges.query.delete()
|
||||||
# ChallengeFiles
|
|
||||||
|
|
||||||
if data.get("accounts"):
|
if data.get("accounts"):
|
||||||
Users.query.delete()
|
Users.query.delete()
|
||||||
|
|
Loading…
Reference in New Issue