+
+
Your Secret Tokens
+
+
+
You have found the following secret tokens in the BornHack Secret Token Game:
+
+
+
+
+ Camp |
+ Category |
+ Token |
+ Description |
+ Found |
+
+
+
+ {% for tokenfind in object_list %}
+
+ {{ tokenfind.token.camp.title }} |
+ {{ tokenfind.token.category }} |
+ {{ tokenfind.token.token }} |
+ {{ tokenfind.token.description }} |
+ {{ tokenfind.created }} |
+
+ {% endfor %}
+ {% for unfound in unfound_list %}
+
+ {{ unfound.camp.title }} |
+ {{ unfound.category }} |
+ - |
+ - |
+ - |
+
+ {% endfor %}
+
+
+
+ {% if not unfound_list %}
+
Congratulations! You've found all tokens we have created right now.
+ {% endif %}
+
+
+{% endblock %}
+
diff --git a/src/profiles/urls.py b/src/profiles/urls.py
index 96af5551..6f61a482 100644
--- a/src/profiles/urls.py
+++ b/src/profiles/urls.py
@@ -1,10 +1,14 @@
from django.urls import path
-from .views import ProfileDetail, ProfileUpdate
-
+from .views import ProfileDetail, ProfileUpdate, ProfileTokenFindsView
app_name = 'profiles'
urlpatterns = [
path('', ProfileDetail.as_view(), name='detail'),
path('edit', ProfileUpdate.as_view(), name='update'),
+ path(
+ 'tokens',
+ ProfileTokenFindsView.as_view(),
+ name='tokenfind_list'
+ ),
]
diff --git a/src/profiles/views.py b/src/profiles/views.py
index a535145d..aa88f239 100644
--- a/src/profiles/views.py
+++ b/src/profiles/views.py
@@ -3,6 +3,7 @@ from django.views.generic import DetailView, UpdateView
from django.urls import reverse_lazy
from django.contrib import messages
+from tokens.views import TokenFindListBaseView
from . import models
@@ -32,3 +33,6 @@ class ProfileUpdate(LoginRequiredMixin, UpdateView):
messages.success(self.request, 'Your profile has been updated.')
return super().form_valid(form, **kwargs)
+
+class ProfileTokenFindsView(TokenFindListBaseView):
+ template_name = "tokenfind_list.html"
diff --git a/src/tokens/templates/tokenfind_list.html b/src/tokens/templates/tokenfind_list.html
deleted file mode 100644
index 0a4edafe..00000000
--- a/src/tokens/templates/tokenfind_list.html
+++ /dev/null
@@ -1,47 +0,0 @@
-{% extends 'base.html' %}
-{% load static from staticfiles %}
-{% load commonmark %}$
-
-{% block title %}
-Your Secret Tokens | {{ block.super }}
-{% endblock %}
-
-{% block content %}
-
Your Secret Tokens
-
You have found the following secret tokens in the BornHack Secret Token Game:
-
-
-
- Camp |
- Category |
- Token |
- Description |
- Found |
-
-
-
- {% for tokenfind in object_list %}
-
- {{ tokenfind.token.camp.title }} |
- {{ tokenfind.token.category }} |
- {{ tokenfind.token.token }} |
- {{ tokenfind.token.description }} |
- {{ tokenfind.created }} |
-
- {% endfor %}
- {% for unfound in unfound_list %}
-
- {{ unfound.camp.title }} |
- {{ unfound.category }} |
- - |
- - |
- - |
-
- {% endfor %}
-
-
-{% if not unfound_list %}
-
Congratulations! You've found all tokens we have created right now.
-{% endif %}
-{% endblock %}
-
diff --git a/src/tokens/urls.py b/src/tokens/urls.py
index 1f06ff6d..5ee67ff3 100644
--- a/src/tokens/urls.py
+++ b/src/tokens/urls.py
@@ -1,14 +1,9 @@
-from django.urls import path, re_path, include
-from .views import TokenDetailView, TokenFindListView
+from django.urls import re_path
+from .views import TokenDetailView
app_name = 'tokens'
urlpatterns = [
- path(
- '',
- TokenFindListView.as_view(),
- name='tokenfind_list'
- ),
re_path(
'(?P
[0-9a-zA-Z\.@]+)/$',
TokenDetailView.as_view(),
diff --git a/src/tokens/views.py b/src/tokens/views.py
index 06f4ac2e..9346f5ec 100644
--- a/src/tokens/views.py
+++ b/src/tokens/views.py
@@ -3,6 +3,7 @@ from django.views.generic import ListView, DetailView
from .models import Token, TokenFind
+
class TokenDetailView(LoginRequiredMixin, DetailView):
template_name = "token_detail.html"
model = Token
@@ -18,8 +19,10 @@ class TokenDetailView(LoginRequiredMixin, DetailView):
return super().get(request, *args, **kwargs)
-class TokenFindListView(LoginRequiredMixin, ListView):
- template_name = "tokenfind_list.html"
+class TokenFindListBaseView(LoginRequiredMixin, ListView):
+ """
+ This class is meant to be extended in other apps like `profiles`.
+ """
model = TokenFind
def get_queryset(self):