Skip to content

Commit

Permalink
inform users about start time if start time is in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunsi committed Dec 23, 2024
1 parent 6865d52 commit 9acbba2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
import socket
from collections import defaultdict
from datetime import datetime
from datetime import datetime, timezone
from secrets import token_hex
from typing import Iterable

Expand Down Expand Up @@ -132,6 +132,20 @@ def before_request():
g.avatar = session.get("gh_avatar")


@app.context_processor
def start_time_alert():
# if g.user is set, the user was successfully logged in (see above)
if g.user:
return {"start_time": None}

start_time = datetime.fromtimestamp(CONFIG["TIME_MIN"], timezone.utc)

if start_time < datetime.now(timezone.utc):
return {"start_time": None}

return {"start_time": start_time.strftime("%F %T")}


@app.route("/github-callback")
@github.authorized_handler
def authorized(access_token):
Expand Down
6 changes: 6 additions & 0 deletions templates/layout.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
</nav>
<div class="container" id='main'>
<busy-indicator></busy-indicator>
{% if start_time %}
<div class="alert alert-info" role="alert">
<h2>Submissions are not yet open</h2>
<p>You will be able to submit content starting <span style="font-weight: bolder;">{{ start_time }} UTC</span></p>
</div>
{% endif %}
{% block body %}
{% endblock %}
<hr/>
Expand Down

0 comments on commit 9acbba2

Please sign in to comment.