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.db.models import Q
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from .serializers import (
|
|
||||||
GameSerializer,
|
from .models import Game
|
||||||
GameTimelineSerializer,
|
from .models import Platform
|
||||||
PlatformSerializer
|
from .models import Timeline
|
||||||
)
|
from .serializers import GameSerializer
|
||||||
from .models import Game, Platform, Timeline
|
from .serializers import GameTimelineSerializer
|
||||||
|
from .serializers import PlatformSerializer
|
||||||
|
|
||||||
|
|
||||||
class PlatformViewSet(viewsets.ModelViewSet):
|
class PlatformViewSet(viewsets.ModelViewSet):
|
||||||
@ -67,9 +68,8 @@ class GameList(ListView):
|
|||||||
model = Game
|
model = Game
|
||||||
context_object_name = 'non_excluded_games'
|
context_object_name = 'non_excluded_games'
|
||||||
template_name = 'games/index.html'
|
template_name = 'games/index.html'
|
||||||
queryset = Game.objects.filter(
|
queryset = Game.objects.filter(~Q(status=Game.EXCLUDED) & Q(
|
||||||
~Q(status=Game.EXCLUDED) &
|
wish=False)).order_by('name').prefetch_related('collection')
|
||||||
Q(wish=False)).order_by('name')
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -78,9 +78,8 @@ class GameList(ListView):
|
|||||||
"""
|
"""
|
||||||
context = super(GameList, self).get_context_data(**kwargs)
|
context = super(GameList, self).get_context_data(**kwargs)
|
||||||
context['playing_games'] = Game.objects.filter(
|
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(
|
context['last_timelines'] = Timeline.objects.filter(
|
||||||
~Q(item__status=Game.EXCLUDED)
|
~Q(item__status=Game.EXCLUDED)).order_by(
|
||||||
).order_by(
|
'-date')[:5].prefetch_related('item__collection')
|
||||||
'-date')[:5]
|
|
||||||
return context
|
return context
|
||||||
|
Loading…
Reference in New Issue
Block a user