Olivier DOSSMANN
c3491b7975
Timelines : * regroupement par date sur la page d'accueil des jeux vidéos * ajout de 4 tests concernant cette page * changement du champ 'date' des Timeline par un 'DateField' (au lieu d'un DateTimeField)
28 lines
840 B
Python
28 lines
840 B
Python
from django.db.models import Q
|
|
from django.views.generic import ListView
|
|
|
|
from .models import Game, Timeline
|
|
|
|
|
|
class GameList(ListView):
|
|
model = Game
|
|
context_object_name = 'non_excluded_games'
|
|
template_name = 'games/index.html'
|
|
queryset = Game.objects.filter(
|
|
~Q(status=Game.EXCLUDED) &
|
|
Q(wish=False)).order_by('name')
|
|
|
|
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')
|
|
context['last_timelines'] = Timeline.objects.filter(
|
|
~Q(item__status=Game.EXCLUDED)
|
|
).order_by(
|
|
'-date')[:5]
|
|
return context
|