diff --git a/apps/games/templates/games/game_detail.html b/apps/games/templates/games/game_detail.html index 49728af..0633456 100644 --- a/apps/games/templates/games/game_detail.html +++ b/apps/games/templates/games/game_detail.html @@ -69,28 +69,81 @@
{{ game.description|linebreaks }}
- {% with screenshots=game.screenshots.all %} - {% if screenshots %} -
-

Скриншоты

+ +{% with screenshots=game.screenshots.all %} + {% if screenshots %} +
-
- - {% for screenshot in screenshots %} -
- - Скриншот {{ game.title }} - -
- {% endfor %} +

Скриншоты

+ +
+ + + + + +
+ + + {% endif %} +{% endwith %} +

Файл приложения

diff --git a/apps/games/templates/games/game_list.html b/apps/games/templates/games/game_list.html index 4e31262..5c2b6d4 100644 --- a/apps/games/templates/games/game_list.html +++ b/apps/games/templates/games/game_list.html @@ -18,6 +18,26 @@

+ +
+ + +
diff --git a/apps/games/views.py b/apps/games/views.py index da3a10b..96c30b4 100644 --- a/apps/games/views.py +++ b/apps/games/views.py @@ -1,6 +1,6 @@ from django.views.generic import ListView, DetailView -from django.db.models import F +from django.db.models import F, query from django.http import FileResponse, Http404 from django.shortcuts import get_object_or_404 @@ -18,10 +18,24 @@ class GameListView(ListView): def get_queryset(self): queryset = Game.objects.filter(status=Game.STATUS_PUBLISHED) - query = self.request.GET.get("q") + query = self.request.GET.get("q", "").strip() if query: - queryset = queryset.filter(title__icontains=query) + from django.db.models import Q + queryset = queryset.filter( + Q(title__icontains=query) + | Q(author_name__icontains=query) + ) + + sort = self.request.GET.get("sort", "updated") + + if sort == "title_asc": + queryset = queryset.order_by("title") + elif sort == "title_desc": + queryset = queryset.order_by("-title") + else: + queryset = queryset.order_by("-updated_at") + return queryset