from django.shortcuts import render, get_object_or_404
from .models import Game, News

def index(request):
    games = Game.objects.all()[:3]
    news = News.objects.all()[:3]
    return render(request, 'core/index.html', {'games': games, 'news': news})

def games_list(request):
    games = Game.objects.all()
    return render(request, 'core/games_list.html', {'games': games})

def game_detail(request, pk):
    game = get_object_or_404(Game, pk=pk)
    return render(request, 'core/game_detail.html', {'game': game})

def news_list(request):
    news = News.objects.all()
    return render(request, 'core/news_list.html', {'news': news})

def news_detail(request, pk):
    post = get_object_or_404(News, pk=pk)
    return render(request, 'core/news_detail.html', {'post': post})