From f90403478b5b44cbda98655b82de35f33dc46ca0 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 17 Aug 2021 19:11:09 +0200 Subject: [PATCH] give the token system a once-over --- .../tokens => tokens/templates}/tokenfind_list.html | 6 +++++- src/tokens/urls.py | 6 ++++-- src/tokens/views.py | 8 +++----- 3 files changed, 12 insertions(+), 8 deletions(-) rename src/{profiles/templates/tokens => tokens/templates}/tokenfind_list.html (64%) diff --git a/src/profiles/templates/tokens/tokenfind_list.html b/src/tokens/templates/tokenfind_list.html similarity index 64% rename from src/profiles/templates/tokens/tokenfind_list.html rename to src/tokens/templates/tokenfind_list.html index ecffbb86..cb0d53b1 100644 --- a/src/profiles/templates/tokens/tokenfind_list.html +++ b/src/tokens/templates/tokenfind_list.html @@ -14,7 +14,11 @@ Your Secret Tokens | {{ block.super }}
-

You have found the following secret tokens in the BornHack Secret Token Game:

+

The Secret Token game lasts the whole event and is about finding little text strings matching the regular expression:

+ [0-9a-zA-Z\.@]{31,32}

+ Tokens are hidden or in plain sight physically or virtually on the BornHack venue, online and offline.

+

If you think you found a secret token you can register it by visiting https://bornhack.dk/token/TOKEN/ where TOKEN is replaced by the token you found.

+

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.

diff --git a/src/tokens/urls.py b/src/tokens/urls.py index d12614b0..bbf1d538 100644 --- a/src/tokens/urls.py +++ b/src/tokens/urls.py @@ -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[0-9a-zA-Z\.@]+)/$", TokenDetailView.as_view(), name="details"), + re_path( + r"(?P[0-9a-zA-Z\.@]{31,32})/$", TokenFindView.as_view(), name="details" + ), ] diff --git a/src/tokens/views.py b/src/tokens/views.py index 89833c1e..113f5d21 100644 --- a/src/tokens/views.py +++ b/src/tokens/views.py @@ -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)