Séparation de la liste des jeux avec les jeux en cours + Timelines

This commit is contained in:
2018-02-19 22:21:06 +01:00
parent a5bcbf0c7e
commit c9e9ec46fa
5 changed files with 87 additions and 72 deletions

View File

@ -3,18 +3,6 @@
{% block content %}
<h1>{% trans "Games" %}</h1>
<h2>{% trans "Now playing" %}</h2>
{% if playing_games %}
<ul>
{% for playing in playing_games %}
<li><strong>{{ playing.collection.shortname }}</strong> - {{ playing.name }}</li>
{% endfor %}
</ul>
{% else %}
<p>{% trans "No playing game found." %}</p>
{% endif %}
<h2>{% trans "Complete list" %}</h2>
{% if non_excluded_games %}
<ul>
{% for game in non_excluded_games %}
@ -24,22 +12,4 @@
{% else %}
<p>{% trans "No game found." %}</p>
{% endif %}
<h2>{% trans "Memory Card" %}</h2>
{% if last_timelines %}
{% regroup last_timelines by date as dates %}
{% for date in dates %}
<p><u>{{ date.grouper }} : </u>
<ul>
{% for timeline in date.list|dictsortreversed:"id" %}
<li>
<strong>{{ timeline.get_status_display }} :</strong> {{ timeline.item.name }}
(<strong>{{ timeline.item.collection.shortname }}</strong>)
</li>
{% endfor %}
</ul>
{% endfor %}
</p>
{% else %}
<p>{% trans "Empty memory." %}</p>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,35 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<h1>{% trans "My summary" %}</h1>
<h2>{% trans "Now playing" %}</h2>
{% if playing_games %}
<ul>
{% for playing in playing_games %}
<li><strong>{{ playing.collection.shortname }}</strong> - {{ playing.name }}</li>
{% endfor %}
</ul>
{% else %}
<p>{% trans "No playing game found." %}</p>
{% endif %}
<h2>{% trans "Memory Card" %}</h2>
{% if last_timelines %}
{% regroup last_timelines by date as dates %}
{% for date in dates %}
<p><u>{{ date.grouper }} : </u>
<ul>
{% for timeline in date.list|dictsortreversed:"id" %}
<li>
<strong>{{ timeline.get_status_display }} :</strong> {{ timeline.item.name }}
(<strong>{{ timeline.item.collection.shortname }}</strong>)
</li>
{% endfor %}
</ul>
{% endfor %}
</p>
{% else %}
<p>{% trans "Empty memory." %}</p>
{% endif %}
{% endblock %}

View File

@ -1,7 +1,8 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'summary/$', views.SummaryList.as_view()),
url(r'$', views.GameList.as_view()),
]
]

View File

@ -71,14 +71,20 @@ class GameList(ListView):
queryset = Game.objects.filter(~Q(status=Game.EXCLUDED) & Q(
wish=False)).order_by('name').prefetch_related('collection')
class SummaryList(ListView):
model = Game
context_object_name = 'playing_games'
template_name = 'games/summary.html'
queryset = Game.objects.filter(
playing=True).order_by('name').prefetch_related('collection')
def get_context_data(self, **kwargs):
"""
Add playing games list.
Add 5 last current activities from Timeline
"""
context = super(GameList, self).get_context_data(**kwargs)
context['playing_games'] = Game.objects.filter(
playing=True).order_by('name').prefetch_related('collection')
context = super().get_context_data(**kwargs)
context['last_timelines'] = Timeline.objects.filter(
~Q(item__status=Game.EXCLUDED)).order_by(
'-date')[:5].prefetch_related('item__collection')