give the token system a once-over
This commit is contained in:
parent
d3cdd5a838
commit
f90403478b
|
@ -14,7 +14,11 @@ Your Secret Tokens | {{ block.super }}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<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">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
|
@ -1,10 +1,12 @@
|
||||||
from django.urls import path, re_path
|
from django.urls import path, re_path
|
||||||
|
|
||||||
from .views import TokenDetailView, TokenFindListView
|
from .views import TokenFindListView, TokenFindView
|
||||||
|
|
||||||
app_name = "tokens"
|
app_name = "tokens"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", TokenFindListView.as_view(), name="tokenfind_list"),
|
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"
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,12 +7,10 @@ from django.views.generic import DetailView, ListView
|
||||||
from .models import Token, TokenFind
|
from .models import Token, TokenFind
|
||||||
|
|
||||||
|
|
||||||
class TokenDetailView(LoginRequiredMixin, DetailView):
|
class TokenFindView(LoginRequiredMixin, DetailView):
|
||||||
template_name = "token_detail.html"
|
|
||||||
model = Token
|
model = Token
|
||||||
slug_field = "token"
|
slug_field = "token"
|
||||||
slug_url_kwarg = "token"
|
slug_url_kwarg = "token"
|
||||||
older_code = False
|
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
# register this tokenview if it isn't already
|
# register this tokenview if it isn't already
|
||||||
|
@ -22,14 +20,14 @@ class TokenDetailView(LoginRequiredMixin, DetailView):
|
||||||
if created:
|
if created:
|
||||||
messages.success(
|
messages.success(
|
||||||
self.request,
|
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"))
|
return redirect(reverse("tokens:tokenfind_list"))
|
||||||
|
|
||||||
|
|
||||||
class TokenFindListView(LoginRequiredMixin, ListView):
|
class TokenFindListView(LoginRequiredMixin, ListView):
|
||||||
model = Token
|
model = Token
|
||||||
template_name = "tokens/tokenfind_list.html"
|
template_name = "tokenfind_list.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
Loading…
Reference in a new issue