show missing tokens, and show category/hint

This commit is contained in:
Thomas Steen Rasmussen 2018-08-19 18:30:25 +02:00
parent df34d3edf3
commit fe4fdd06b0
2 changed files with 16 additions and 0 deletions

View file

@ -15,6 +15,7 @@ Your Secret Tokens | {{ block.super }}
<tr> <tr>
<th>Camp</th> <th>Camp</th>
<th>Token</th> <th>Token</th>
<th>Category</th>
<th>Description</th> <th>Description</th>
<th>Found</th> <th>Found</th>
</tr> </tr>
@ -23,15 +24,24 @@ Your Secret Tokens | {{ block.super }}
{% for tokenfind in object_list %} {% for tokenfind in object_list %}
<tr> <tr>
<td>{{ tokenfind.token.camp.title }}</td> <td>{{ tokenfind.token.camp.title }}</td>
<td>{{ tokenfind.token.category }}</td>
<td>{{ tokenfind.token.token }}</td> <td>{{ tokenfind.token.token }}</td>
<td>{{ tokenfind.token.description }}</td> <td>{{ tokenfind.token.description }}</td>
<td>{{ tokenfind.created }}</td> <td>{{ tokenfind.created }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% for unfound in unfound_list %}
<td>{{ unfound.camp.title }}</td>
<td>-</td>
<td>{{ unfound.category }}</td>
<td>-</td>
<td>-</td>
{% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p class="lead">You haven't found any secret tokens yet. Happy hunting!</p> <p class="lead">You haven't found any secret tokens yet. Happy hunting!</p>
{% endif %} {% endif %}
<hr>
{% endblock %} {% endblock %}

View file

@ -25,3 +25,9 @@ class TokenFindListView(LoginRequiredMixin, ListView):
def get_queryset(self): def get_queryset(self):
return TokenFind.objects.filter(user=self.request.user) return TokenFind.objects.filter(user=self.request.user)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# find the tokens the user still needs to find
context['unfound_list'] = Token.objects.all().exclude(id__in=TokenFind.objects.filter(user=self.request.user).values_list('id', flat=True))
return context