From 90883b50b76582d7514defe62bae624c51bb212c Mon Sep 17 00:00:00 2001 From: laurenpudz Date: Sat, 28 Feb 2026 21:34:04 +0800 Subject: [PATCH 1/5] add validation in models.py --- server/game_dev/models.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/game_dev/models.py b/server/game_dev/models.py index 91d7290..521773c 100644 --- a/server/game_dev/models.py +++ b/server/game_dev/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.core.exceptions import ValidationError class Member(models.Model): @@ -66,12 +67,15 @@ class CompletionStatus(models.IntegerChoices): blank=True, help_text="If a game is playable and has a web demo stored on itch.io, please enter the embed developer ID" ) - itchGameWidth = models.PositiveBigIntegerField( - default=0 + default=None, + null=True, + blank=True, ) itchGameHeight = models.PositiveBigIntegerField( - default=0 + default=None, + null=True, + blank=True, ) thumbnail = models.ImageField(upload_to="games/", null=True) @@ -80,6 +84,14 @@ class CompletionStatus(models.IntegerChoices): def __str__(self): return str(self.name) + def clean(self): + super().clean() + if self.itchGamePlayableID: + if not self.itchGameWidth: + raise ValidationError({"itchGameWidth": "Game width is required if itchGamePlayableID is set."}) + if not self.itchGameHeight: + raise ValidationError({"itchGameHeight": "Game height is required if itchGamePlayableID is set."}) + class GameShowcase(models.Model): game = models.OneToOneField('Game', on_delete=models.CASCADE, related_name='game_showcases') From 03b2c15c4d8d3956c0f102bd297f84111162ee86 Mon Sep 17 00:00:00 2001 From: laurenpudz Date: Sat, 28 Feb 2026 21:59:35 +0800 Subject: [PATCH 2/5] refactor gameEmbedID to playableID, add width and height checks --- client/src/hooks/useGames.ts | 2 +- client/src/pages/games/[id].tsx | 6 +++--- client/src/placeholderData.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/src/hooks/useGames.ts b/client/src/hooks/useGames.ts index ddc4d83..758e9c7 100644 --- a/client/src/hooks/useGames.ts +++ b/client/src/hooks/useGames.ts @@ -24,7 +24,7 @@ type ApiGame = { itchEmbedID: string; thumbnail: string | null; event: number | null; - itchGameEmbedID: string; + itchGamePlayableID: string; itchGameWidth: number; itchGameHeight: number; contributors: Contributor[]; diff --git a/client/src/pages/games/[id].tsx b/client/src/pages/games/[id].tsx index 399d4f3..5e6f6eb 100644 --- a/client/src/pages/games/[id].tsx +++ b/client/src/pages/games/[id].tsx @@ -52,7 +52,7 @@ export default function IndividualGamePage() { const gameTitle = game.name; const gameCover = game.gameCover; const gameDescription = game.description.split("\n"); - const gameEmbedID = game.itchGameEmbedID; + const gamePlayableID = game.itchGamePlayableID; const gameWidth = game.itchGameWidth; const gameHeight = game.itchGameHeight; @@ -89,10 +89,10 @@ export default function IndividualGamePage() {
- {gameEmbedID ? ( + {gamePlayableID && gameWidth && gameHeight ? (
Date: Sat, 28 Feb 2026 22:02:23 +0800 Subject: [PATCH 3/5] comment and add migration --- client/src/pages/games/[id].tsx | 1 + ...itchgameheight_alter_game_itchgamewidth.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 server/game_dev/migrations/0028_alter_game_itchgameheight_alter_game_itchgamewidth.py diff --git a/client/src/pages/games/[id].tsx b/client/src/pages/games/[id].tsx index 5e6f6eb..49e8b48 100644 --- a/client/src/pages/games/[id].tsx +++ b/client/src/pages/games/[id].tsx @@ -89,6 +89,7 @@ export default function IndividualGamePage() {
+ {/* only render game embed if ID, width, and height are all provided (...and are non-zero). */} {gamePlayableID && gameWidth && gameHeight ? (
Date: Tue, 3 Mar 2026 17:02:57 +0800 Subject: [PATCH 4/5] delete and redo migrations --- ...030_alter_game_itchgameheight_alter_game_itchgamewidth.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename server/game_dev/migrations/{0028_alter_game_itchgameheight_alter_game_itchgamewidth.py => 0030_alter_game_itchgameheight_alter_game_itchgamewidth.py} (80%) diff --git a/server/game_dev/migrations/0028_alter_game_itchgameheight_alter_game_itchgamewidth.py b/server/game_dev/migrations/0030_alter_game_itchgameheight_alter_game_itchgamewidth.py similarity index 80% rename from server/game_dev/migrations/0028_alter_game_itchgameheight_alter_game_itchgamewidth.py rename to server/game_dev/migrations/0030_alter_game_itchgameheight_alter_game_itchgamewidth.py index 31e8605..33c4b23 100644 --- a/server/game_dev/migrations/0028_alter_game_itchgameheight_alter_game_itchgamewidth.py +++ b/server/game_dev/migrations/0030_alter_game_itchgameheight_alter_game_itchgamewidth.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.15 on 2026-02-28 13:46 +# Generated by Django 5.1.15 on 2026-03-03 08:48 from django.db import migrations, models @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('game_dev', '0027_remove_game_itchgameembedid_game_itchgameplayableid'), + ('game_dev', '0029_rename_cover_image_event_coverimage_and_more'), ] operations = [ From 7c683ed4bd73d9d001a6db2642faed1066e50a19 Mon Sep 17 00:00:00 2001 From: laurenpudz Date: Tue, 3 Mar 2026 17:08:26 +0800 Subject: [PATCH 5/5] update docco --- client/documentation/admin-dashboard/games.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/documentation/admin-dashboard/games.md b/client/documentation/admin-dashboard/games.md index b87783e..73caf79 100644 --- a/client/documentation/admin-dashboard/games.md +++ b/client/documentation/admin-dashboard/games.md @@ -24,8 +24,8 @@ Pages for games can be added and edited at the row 'Game' of the GAME_DEV sectio **Event:** Optional field for the event at which the game was created. Links the game to an event. Foreign key field for an event. -**Itch Game Embed ID:** Optional field for the game's game embed. This ID allows the web version of a game to be played inside the site. This value can be acquired in two ways, either by the developer or through looking in the page source. A developer can get the value by going to the distribution tab of their game and going to the embed game section this will bring up a full embed for the game and the only part needed is the 8 digit number after "https://html-classic.itch.zone/html/". By looking through the page source that link can also be found either in a div or an iframe on the page depending on if the game has been played. **This value is not attainable if there is no web version of the game. hosted on itch.** +**Itch Game Playable ID:** Optional field for the game's game embed. This ID allows the web version of a game to be played inside the site. This value can be acquired in two ways, either by the developer or through looking in the page source. A developer can get the value by going to the distribution tab of their game and going to the embed game section this will bring up a full embed for the game and the only part needed is the 8 digit number after "https://html-classic.itch.zone/html/". By looking through the page source that link can also be found either in a div or an iframe on the page depending on if the game has been played. **This value is not attainable if there is no web version of the game. hosted on itch.** -**Itch Game Width:** Required field for the game's game embed. This value is gotten in a similar way to the Itch Game Embed, however for the developer it's the number after "width=" and in the page source is found after "data-width=". +**Itch Game Width:** This field is required if the playable field ID is non null. This value is gotten in a similar way to the Itch Game Embed, however for the developer it's the number after "width=" and in the page source is found after "data-width=". -**Itch Game Height:** Required field for the game's game embed. This value is gotten in a similar way to the Itch Game Embed, however for the developer it's the number after "height=" and in the page source is found after "data-height=". \ No newline at end of file +**Itch Game Height:** This field is required if the playable field ID is non null. This value is gotten in a similar way to the Itch Game Embed, however for the developer it's the number after "height=" and in the page source is found after "data-height=". \ No newline at end of file