Amélioration de l'affichage de la page d'accueil
This commit is contained in:
parent
52d56926d4
commit
801d26cb4a
@ -1,12 +1,13 @@
|
||||
from django.db.models import Q
|
||||
from django.views.generic import ListView
|
||||
from rest_framework import viewsets
|
||||
from .serializers import (
|
||||
GameSerializer,
|
||||
GameTimelineSerializer,
|
||||
PlatformSerializer
|
||||
)
|
||||
from .models import Game, Platform, Timeline
|
||||
|
||||
from .models import Game
|
||||
from .models import Platform
|
||||
from .models import Timeline
|
||||
from .serializers import GameSerializer
|
||||
from .serializers import GameTimelineSerializer
|
||||
from .serializers import PlatformSerializer
|
||||
|
||||
|
||||
class PlatformViewSet(viewsets.ModelViewSet):
|
||||
@ -67,9 +68,8 @@ 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')
|
||||
queryset = Game.objects.filter(~Q(status=Game.EXCLUDED) & Q(
|
||||
wish=False)).order_by('name').prefetch_related('collection')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""
|
||||
@ -78,9 +78,8 @@ class GameList(ListView):
|
||||
"""
|
||||
context = super(GameList, self).get_context_data(**kwargs)
|
||||
context['playing_games'] = Game.objects.filter(
|
||||
playing=True).order_by('name')
|
||||
playing=True).order_by('name').prefetch_related('collection')
|
||||
context['last_timelines'] = Timeline.objects.filter(
|
||||
~Q(item__status=Game.EXCLUDED)
|
||||
).order_by(
|
||||
'-date')[:5]
|
||||
~Q(item__status=Game.EXCLUDED)).order_by(
|
||||
'-date')[:5].prefetch_related('item__collection')
|
||||
return context
|
||||
|
Loading…
Reference in New Issue
Block a user