Skip to content

Commit 92dcefd

Browse files
authored
Merge pull request #144 from codersforcauses/issue-143-allow_playable_game_width_and_height_to_be_null
Issue 143 allow playable game width and height to be null
2 parents bb11ebe + 7c683ed commit 92dcefd

6 files changed

Lines changed: 49 additions & 13 deletions

File tree

client/documentation/admin-dashboard/games.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Pages for games can be added and edited at the row 'Game' of the GAME_DEV sectio
2424

2525
**Event:** Optional field for the event at which the game was created. Links the game to an event. Foreign key field for an event.
2626

27-
**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.**
27+
**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.**
2828

29-
**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=".
29+
**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=".
3030

31-
**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=".
31+
**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=".

client/src/hooks/useGames.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type ApiGame = {
2424
itchEmbedID: string;
2525
thumbnail: string | null;
2626
event: number | null;
27-
itchGameEmbedID: string;
27+
itchGamePlayableID: string;
2828
itchGameWidth: number;
2929
itchGameHeight: number;
3030
contributors: Contributor[];

client/src/pages/games/[id].tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function IndividualGamePage() {
5757
const gameTitle = game.name;
5858
const gameCover = game.gameCover;
5959
const gameDescription = game.description.split("\n");
60-
const gameEmbedID = game.itchGameEmbedID;
60+
const gamePlayableID = game.itchGamePlayableID;
6161
const gameWidth = game.itchGameWidth;
6262
const gameHeight = game.itchGameHeight;
6363
const eventID = game.event;
@@ -94,10 +94,11 @@ export default function IndividualGamePage() {
9494
<main>
9595
<section className="w-full items-center justify-center bg-popover">
9696
<div className="mx-auto flex max-w-7xl justify-center p-0 sm:p-8">
97-
{gameEmbedID ? (
97+
{/* only render game embed if ID, width, and height are all provided (...and are non-zero). */}
98+
{gamePlayableID && gameWidth && gameHeight ? (
9899
<div className="m-auto flex overflow-auto">
99100
<GameEmbed
100-
embedID={gameEmbedID}
101+
embedID={gamePlayableID}
101102
gameWidth={gameWidth}
102103
gameHeight={gameHeight}
103104
gameImage={gameCover}

client/src/placeholderData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const placeholderGames = [
5656
hostURL: "/",
5757
itchEmbedID: "1",
5858
thumbnail: "/landing_placeholder.png",
59-
itchGameEmbedID: 0,
59+
itchGamePlayableID: 0,
6060
itchGameWidth: 0,
6161
itchGameHeight: 0,
6262
event: 1,
@@ -70,7 +70,7 @@ export const placeholderGames = [
7070
hostURL: "/",
7171
itchEmbedID: "1",
7272
thumbnail: "/landing_placeholder.png",
73-
itchGameEmbedID: 0,
73+
itchGamePlayableID: 0,
7474
itchGameWidth: 0,
7575
itchGameHeight: 0,
7676
event: 1,
@@ -84,7 +84,7 @@ export const placeholderGames = [
8484
hostURL: "/",
8585
itchEmbedID: "1",
8686
thumbnail: "/landing_placeholder.png",
87-
itchGameEmbedID: 0,
87+
itchGamePlayableID: 0,
8888
itchGameWidth: 0,
8989
itchGameHeight: 0,
9090
event: 1,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.1.15 on 2026-03-03 08:48
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('game_dev', '0029_rename_cover_image_event_coverimage_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='game',
15+
name='itchGameHeight',
16+
field=models.PositiveBigIntegerField(blank=True, default=None, null=True),
17+
),
18+
migrations.AlterField(
19+
model_name='game',
20+
name='itchGameWidth',
21+
field=models.PositiveBigIntegerField(blank=True, default=None, null=True),
22+
),
23+
]

server/game_dev/models.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.db import models
2+
from django.core.exceptions import ValidationError
23

34

45
class Member(models.Model):
@@ -67,12 +68,15 @@ class CompletionStatus(models.IntegerChoices):
6768
blank=True,
6869
help_text="If a game is playable and has a web demo stored on itch.io, please enter the embed developer ID"
6970
)
70-
7171
itchGameWidth = models.PositiveBigIntegerField(
72-
default=0
72+
default=None,
73+
null=True,
74+
blank=True,
7375
)
7476
itchGameHeight = models.PositiveBigIntegerField(
75-
default=0
77+
default=None,
78+
null=True,
79+
blank=True,
7680
)
7781

7882
thumbnail = models.ImageField(upload_to="games/", null=True)
@@ -81,6 +85,14 @@ class CompletionStatus(models.IntegerChoices):
8185
def __str__(self):
8286
return str(self.name)
8387

88+
def clean(self):
89+
super().clean()
90+
if self.itchGamePlayableID:
91+
if not self.itchGameWidth:
92+
raise ValidationError({"itchGameWidth": "Game width is required if itchGamePlayableID is set."})
93+
if not self.itchGameHeight:
94+
raise ValidationError({"itchGameHeight": "Game height is required if itchGamePlayableID is set."})
95+
8496

8597
class GameShowcase(models.Model):
8698
game = models.OneToOneField('Game', on_delete=models.CASCADE, related_name='game_showcases')

0 commit comments

Comments
 (0)