mirror of
https://github.com/bratusev07/skb-market.git
synced 2026-12-05 05:09:44 +00:00
feat: application screenshots added, and file size calculated
This commit is contained in:
1 parent
196d1e2ed7
commit
62d9ad1965
7 files changed
+180
-3
No files matched your search
+28
-1
@@ -1,5 +1,9 @@
|
||||
from django.views.generic import ListView, DetailView
|
||||
|
||||
from django.db.models import F
|
||||
from django.http import FileResponse, Http404
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from .models import Game
|
||||
|
||||
|
||||
@@ -29,4 +33,27 @@ class GameDetailView(DetailView):
|
||||
context_object_name = "game"
|
||||
|
||||
def get_queryset(self):
|
||||
return Game.objects.filter(status=Game.STATUS_PUBLISHED)
|
||||
return Game.objects.filter(status=Game.STATUS_PUBLISHED)
|
||||
|
||||
|
||||
def download_game(request, pk):
|
||||
game = get_object_or_404(
|
||||
Game,
|
||||
pk=pk,
|
||||
status=Game.STATUS_PUBLISHED,
|
||||
)
|
||||
|
||||
if not game.file:
|
||||
raise Http404("Файл приложения не найден")
|
||||
|
||||
response = FileResponse(
|
||||
game.file.open("rb"),
|
||||
as_attachment=True,
|
||||
filename=game.file.name.split("/")[-1],
|
||||
)
|
||||
|
||||
Game.objects.filter(pk=game.pk).update(
|
||||
download_count=F("download_count") + 1
|
||||
)
|
||||
|
||||
return response
|
||||
Reference in new issue
Block a user