give the token system a once-over

This commit is contained in:
Thomas Steen Rasmussen 2021-08-17 19:11:09 +02:00
parent d3cdd5a838
commit f90403478b
3 changed files with 12 additions and 8 deletions

View File

@ -14,7 +14,11 @@ Your Secret Tokens | {{ block.super }}
</div>
<div class="panel-body">
<p class="lead">You have found the following secret tokens in the BornHack Secret Token Game:</p>
<p class="lead">The Secret Token game lasts the whole event and is about finding little text strings matching the regular expression:<br><br>
<code>[0-9a-zA-Z\.@]{31,32}</code><br><br>
Tokens are hidden or in plain sight physically or virtually on the BornHack venue, online and offline.</p>
<p class="lead">If you think you found a secret token you can register it by visiting <code>https://bornhack.dk/token/TOKEN/</code> where <code>TOKEN</code> is replaced by the token you found.</p>
<p class="lead">This page shows an overview of the tokens in this years game, a hint for each token, and how many of them you have found.</p>
<table class="table">
<tbody>

View File

@ -1,10 +1,12 @@
from django.urls import path, re_path
from .views import TokenDetailView, TokenFindListView
from .views import TokenFindListView, TokenFindView
app_name = "tokens"
urlpatterns = [
path("", TokenFindListView.as_view(), name="tokenfind_list"),
re_path(r"(?P<token>[0-9a-zA-Z\.@]+)/$", TokenDetailView.as_view(), name="details"),
re_path(
r"(?P<token>[0-9a-zA-Z\.@]{31,32})/$", TokenFindView.as_view(), name="details"
),
]

View File

@ -7,12 +7,10 @@ from django.views.generic import DetailView, ListView
from .models import Token, TokenFind
class TokenDetailView(LoginRequiredMixin, DetailView):
template_name = "token_detail.html"
class TokenFindView(LoginRequiredMixin, DetailView):
model = Token
slug_field = "token"
slug_url_kwarg = "token"
older_code = False
def get(self, request, *args, **kwargs):
# register this tokenview if it isn't already
@ -22,14 +20,14 @@ class TokenDetailView(LoginRequiredMixin, DetailView):
if created:
messages.success(
self.request,
f"You found a secret token: {self.get_object().description} - Your visit has been registered! Keep hunting, there might be more tokens out there.",
f"Congratulations! You found a secret token: {self.get_object().description} - Your visit has been registered! Keep hunting, there might be more tokens out there.",
)
return redirect(reverse("tokens:tokenfind_list"))
class TokenFindListView(LoginRequiredMixin, ListView):
model = Token
template_name = "tokens/tokenfind_list.html"
template_name = "tokenfind_list.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)