Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add footer and an example js #49

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion comptest/comptest/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"web.context_processors.navbar_pages",
"web.context_processors.footer_content",
],
},
},
Expand Down Expand Up @@ -191,7 +192,20 @@
# - NOT_STARTED: The challenge has not started yet
# - RUNNING: The challenge is currently running
# Based on this, different views are shown to the user
CHALLENGE_STATE = "NOT_STARTED"
CHALLENGE_STATE = "RUNNING"

FOOTER = """
<div class="footer">
<p id="footer-text">&copy; HELLO!</p>
<script>
document.addEventListener('DOMContentLoaded', function() {
var footerText = document.getElementById('footer-text');
var timeOfDay = new Date().toString();
footerText.innerHTML = timeOfDay;
});
</script>
</div>
"""

import os

Expand Down
6 changes: 6 additions & 0 deletions comptest/web/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from django.conf import settings

from .models import Page


def navbar_pages(request):
pages = Page.objects.all().order_by("order").exclude(is_home=True)
return {"pages": pages}


def footer_content(request):
return {"footer": settings.FOOTER}
10 changes: 10 additions & 0 deletions comptest/web/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,14 @@
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script>
</body>
<footer>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container">
<!-- <a class="navbar-brand" href="/"></a> -->
<div class="collapse navbar-collapse">
<div class="navbar-nav">{{ footer|safe }}</div>
</div>
</div>
</nav>
</footer>
</html>