From 62d9ad196523d9433151632381a911f0ebb119e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=91=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D1=83=D1=81=D0=B5=D0=B2?= <55459712+bratusev07@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:54:47 +0300 Subject: [PATCH] feat: application screenshots added, and file size calculated --- apps/games/admin.py | 3 +- .../games/migrations/0003_game_author_name.py | 18 +++ apps/games/models.py | 12 ++ apps/games/templates/games/game_detail.html | 115 ++++++++++++++++++ apps/games/templates/games/game_list.html | 1 - apps/games/urls.py | 5 + apps/games/views.py | 29 ++++- 7 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 apps/games/migrations/0003_game_author_name.py create mode 100644 apps/games/templates/games/game_detail.html diff --git a/apps/games/admin.py b/apps/games/admin.py index 8f7adac..588f9fd 100644 --- a/apps/games/admin.py +++ b/apps/games/admin.py @@ -8,13 +8,14 @@ from .models import Game, Screenshot class GameAdmin(admin.ModelAdmin): list_display = ( "title", + "author_name", "version", "status", "created_by", "updated_at", ) list_filter = ("status", "unity_version") - search_fields = ("title", "created_by__username") + search_fields = ("title", "author_name", "created_by__username") ordering = ("-updated_at",) diff --git a/apps/games/migrations/0003_game_author_name.py b/apps/games/migrations/0003_game_author_name.py new file mode 100644 index 0000000..4d030a7 --- /dev/null +++ b/apps/games/migrations/0003_game_author_name.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.17 on 2026-10-28 09:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('games', '0002_alter_game_options_alter_screenshot_options_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='game', + name='author_name', + field=models.CharField(blank=True, default='', max_length=200, verbose_name='Автор / команда'), + ), + ] diff --git a/apps/games/models.py b/apps/games/models.py index 21e56b2..6ce7261 100644 --- a/apps/games/models.py +++ b/apps/games/models.py @@ -8,6 +8,12 @@ class Game(models.Model): max_length=200, verbose_name="Название", ) + author_name = models.CharField( + max_length=200, + blank=True, + default="", + verbose_name="Автор / команда", + ) short_description = models.CharField( max_length=300, verbose_name="Краткое описание", @@ -82,6 +88,12 @@ class Game(models.Model): verbose_name="Количество скачиваний", ) + def save(self, *args, **kwargs): + if self.file: + self.file_size = self.file.size + + super().save(*args, **kwargs) + class Meta: verbose_name = "Unity-приложение" verbose_name_plural = "Unity-приложения" diff --git a/apps/games/templates/games/game_detail.html b/apps/games/templates/games/game_detail.html new file mode 100644 index 0000000..49728af --- /dev/null +++ b/apps/games/templates/games/game_detail.html @@ -0,0 +1,115 @@ + +{% extends "games/base.html" %} + +{% block title %}{{ game.title }} — SKB Market{% endblock %} + +{% block content %} +
+ Автор / команда: {{ game.author_name }} +
+ {% endif %} + + {% if game.short_description %} +{{ game.short_description }}
+ {% endif %} + ++ Обновлено: {{ game.updated_at|date:"d.m.Y H:i" }} +
+ ++ Скачиваний: {{ game.download_count }} +
++ Размер: + {% if game.file_size %} + {{ game.file_size|filesizeformat }} + {% else %} + Пока не определён + {% endif %} +
+ + {% if game.file %} + + Скачать приложение + + {% else %} +Файл пока не загружен.
+ {% endif %} +{{ game.short_description }}
diff --git a/apps/games/urls.py b/apps/games/urls.py index 561bfc5..da7e6ab 100644 --- a/apps/games/urls.py +++ b/apps/games/urls.py @@ -10,4 +10,9 @@ urlpatterns = [ views.GameDetailView.as_view(), name="game_detail", ), + path( + "game/