Add token finds list as something the profiles app decides how to show.
This commit is contained in:
parent
b3a7825b56
commit
50d40eb7df
|
@ -69,8 +69,9 @@
|
|||
{% endif %}
|
||||
|
||||
<li><b>Misc.</b></li>
|
||||
<li {% if view.active_menu == "tokens" %}class="active"{% endif %}>
|
||||
<a href="{% url 'tokens:tokenfind_list' %}">
|
||||
{% url 'profiles:tokenfind_list' as tokenfind_list_url %}
|
||||
<li {% if request.path == tokenfind_list_url %}class="active"{% endif %}>
|
||||
<a href="{{ tokenfind_list_url }}">
|
||||
Secret Tokens
|
||||
</a>
|
||||
</li>
|
||||
|
|
55
src/profiles/templates/tokenfind_list.html
Normal file
55
src/profiles/templates/tokenfind_list.html
Normal file
|
@ -0,0 +1,55 @@
|
|||
{% extends 'profile_base.html' %}
|
||||
{% load static from staticfiles %}
|
||||
{% load commonmark %}$
|
||||
|
||||
{% block title %}
|
||||
Your Secret Tokens | {{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block profile_content %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Your Secret Tokens</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p class="lead">You have found the following secret tokens in the BornHack Secret Token Game:</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Camp</th>
|
||||
<th>Category</th>
|
||||
<th>Token</th>
|
||||
<th>Description</th>
|
||||
<th>Found</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for tokenfind in object_list %}
|
||||
<tr>
|
||||
<td>{{ tokenfind.token.camp.title }}</td>
|
||||
<td>{{ tokenfind.token.category }}</td>
|
||||
<td>{{ tokenfind.token.token }}</td>
|
||||
<td>{{ tokenfind.token.description }}</td>
|
||||
<td>{{ tokenfind.created }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for unfound in unfound_list %}
|
||||
<tr>
|
||||
<td>{{ unfound.camp.title }}</td>
|
||||
<td>{{ unfound.category }}</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% if not unfound_list %}
|
||||
<p class="lead">Congratulations! You've found all tokens we have created right now.</p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -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'
|
||||
),
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load static from staticfiles %}
|
||||
{% load commonmark %}$
|
||||
|
||||
{% block title %}
|
||||
Your Secret Tokens | {{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>Your Secret Tokens</h3>
|
||||
<p class="lead">You have found the following secret tokens in the BornHack Secret Token Game:</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Camp</th>
|
||||
<th>Category</th>
|
||||
<th>Token</th>
|
||||
<th>Description</th>
|
||||
<th>Found</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for tokenfind in object_list %}
|
||||
<tr>
|
||||
<td>{{ tokenfind.token.camp.title }}</td>
|
||||
<td>{{ tokenfind.token.category }}</td>
|
||||
<td>{{ tokenfind.token.token }}</td>
|
||||
<td>{{ tokenfind.token.description }}</td>
|
||||
<td>{{ tokenfind.created }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for unfound in unfound_list %}
|
||||
<tr>
|
||||
<td>{{ unfound.camp.title }}</td>
|
||||
<td>{{ unfound.category }}</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if not unfound_list %}
|
||||
<p class="lead">Congratulations! You've found all tokens we have created right now.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
@ -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<token>[0-9a-zA-Z\.@]+)/$',
|
||||
TokenDetailView.as_view(),
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue