diff --git a/CTFd/challenges.py b/CTFd/challenges.py index 911b9f3710cd47c16858d8a73bf52fca2236ffe3..73577e47e06cba8f591dc79c4a0f020c2cb4d89a 100644 --- a/CTFd/challenges.py +++ b/CTFd/challenges.py @@ -20,7 +20,7 @@ challenges = Blueprint("challenges", __name__) @during_ctf_time_only @require_verified_emails @check_challenge_visibility -def listing(): +def listing(page=None): if ( Configs.challenge_visibility == ChallengeVisibilityTypes.PUBLIC and authed() is False @@ -37,12 +37,12 @@ def listing(): infos.append("La visibilité des défis est configuré uniquement pour les administrateurs") if ctf_started() is False: - errors.append(f"{Configs.ctf_name} n'a pas encore commencé") + errors.append(f"{Configs.ctf_name} n'a pas encore commencé, les défis apparaîtrons sur cette page") if ctf_paused() is True: infos.append(f"{Configs.ctf_name} est en pause") if ctf_ended() is True: - infos.append(f"{Configs.ctf_name} a terminé") + infos.append(f"{Configs.ctf_name} est terminé") return render_template("challenges.html", infos=infos, errors=errors) diff --git a/CTFd/themes/core-beta/templates/challenges.html b/CTFd/themes/core-beta/templates/challenges.html index ca423d25343b777c09f5c53c6891255854791276..a586dc257a86d8753eae59224a6397e09e8c363d 100644 --- a/CTFd/themes/core-beta/templates/challenges.html +++ b/CTFd/themes/core-beta/templates/challenges.html @@ -76,7 +76,7 @@ {% else %} <div style="height: 15vw;width: 15vw;display: block;"></div> {% endif %} - <div><h1> + <div><h1 style="color: white"> {% trans %}Défis{% endtrans %} </h1> diff --git a/CTFd/themes/core-beta/templates/page.html b/CTFd/themes/core-beta/templates/page.html index 04ebb0e63b7a89ffa92a76c38ac4f41a64ba3ae4..e40c14af594adbba5eae9d131fa91967194f954a 100644 --- a/CTFd/themes/core-beta/templates/page.html +++ b/CTFd/themes/core-beta/templates/page.html @@ -1,6 +1,38 @@ {% extends "base.html" %} {% block content %} + <div class="col-md-12" style="display: flex; justify-content: space-around;flex-direction: column;"> + {% include "components/errors.html" %} + </div> + <div class="countdown-container" style="width: 100%; display:flex; justify-content: center;"> + <div class="row ctfd-event-countdown"> + <p class="countdown-context" style="position: relative;top: 2vh;text-align:center;font-size: 3vw; max-font-size: 20px;">Chargement en cours...</p> + <div class="col-md-12" style="display: flex; justify-content: space-around; padding-bottom:10px;"> + + <ul id="countdown" style="width: 100%; top: auto;"> + <li class="countdown-days"> + <div class="number">00</div> + <div class="label">Jours</div> + </li> + <li class="countdown-separator">:</li> + <li class="countdown-hours"> + <div class="number">00</div> + <div class="label">Heures</div> + </li> + <li class="countdown-separator">:</li> + <li class="countdown-minutes"> + <div class="number">00</div> + <div class="label">Minutes</div> + </li> + <li class="countdown-separator">:</li> + <li class="countdown-seconds"> + <div class="number">00</div> + <div class="label">Secondes</div> + </li> + </ul> + </div> + </div> + </div> <div class="container"> {{ content | safe }} </div> diff --git a/CTFd/utils/decorators/__init__.py b/CTFd/utils/decorators/__init__.py index f5cf1d1bd7bf8b556df2177c2df2b969ff082a6d..de64a2b2ef078ef3fc2ab2f177fb1ec3df4faaa7 100644 --- a/CTFd/utils/decorators/__init__.py +++ b/CTFd/utils/decorators/__init__.py @@ -1,7 +1,8 @@ import functools -from flask import abort, jsonify, redirect, request, url_for +from flask import abort, jsonify, redirect, request, url_for, render_template +from CTFd.models import Pages from CTFd.cache import cache from CTFd.utils import config, get_config from CTFd.utils import user as current_user @@ -9,7 +10,6 @@ from CTFd.utils.config import is_teams_mode from CTFd.utils.dates import ctf_ended, ctf_started, ctftime, view_after_ctf from CTFd.utils.user import authed, get_current_team, get_current_user, is_admin - def during_ctf_time_only(f): """ Decorator to restrict an endpoint to only be seen during a CTF @@ -19,6 +19,7 @@ def during_ctf_time_only(f): @functools.wraps(f) def during_ctf_time_only_wrapper(*args, **kwargs): + from CTFd.utils.helpers import info_for if ctftime() or current_user.is_admin(): return f(*args, **kwargs) else: @@ -32,6 +33,13 @@ def during_ctf_time_only(f): if is_teams_mode() and get_current_team() is None: return redirect(url_for("teams.private", next=request.full_path)) else: + page = Pages.query.filter(Pages.title.ilike('info')).first() + if page: + info_for( + "views.static_html", + "Veuillez attendre le début de la scav avant d'accéder aux défis", + ) + return redirect(url_for("views.static_html", route=page.route)) error = "{} has not started yet".format(config.ctf_name()) abort(403, description=error) @@ -194,10 +202,10 @@ def ratelimit(method="POST", limit=50, interval=300, key_prefix="rl"): def require_complete_profile(f): - from CTFd.utils.helpers import info_for @functools.wraps(f) def _require_complete_profile(*args, **kwargs): + from CTFd.utils.helpers import info_for if authed(): if is_admin(): return f(*args, **kwargs) diff --git a/CTFd/views.py b/CTFd/views.py index a311c032a2508da568fa5977133bb24be55592fa..43a863c87e182046d09e9ab94b57e1ed9bcce941 100644 --- a/CTFd/views.py +++ b/CTFd/views.py @@ -405,6 +405,7 @@ def settings(): @views.route("/", defaults={"route": "none"}) @views.route("/<path:route>") def static_html(route): + from CTFd.utils.helpers import info_for """ Route in charge of routing users to Pages. :param route: @@ -421,8 +422,8 @@ def static_html(route): splash_visibility = splash_visible() print("splash_visibility: " + str(splash_visibility)) return render_template("scoreboard.html", splash_visibility=splash_visibility) - - return render_template("page.html", content=page.html, title=page.title) + infos = get_infos() + return render_template("page.html", content=page.html, title=page.title, infos=infos)