File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from django .db import models
2+ from django .core .exceptions import ValidationError
23
34
45class Member (models .Model ):
@@ -66,12 +67,15 @@ class CompletionStatus(models.IntegerChoices):
6667 blank = True ,
6768 help_text = "If a game is playable and has a web demo stored on itch.io, please enter the embed developer ID"
6869 )
69-
7070 itchGameWidth = models .PositiveBigIntegerField (
71- default = 0
71+ default = None ,
72+ null = True ,
73+ blank = True ,
7274 )
7375 itchGameHeight = models .PositiveBigIntegerField (
74- default = 0
76+ default = None ,
77+ null = True ,
78+ blank = True ,
7579 )
7680
7781 thumbnail = models .ImageField (upload_to = "games/" , null = True )
@@ -80,6 +84,14 @@ class CompletionStatus(models.IntegerChoices):
8084 def __str__ (self ):
8185 return str (self .name )
8286
87+ def clean (self ):
88+ super ().clean ()
89+ if self .itchGamePlayableID :
90+ if not self .itchGameWidth :
91+ raise ValidationError ({"itchGameWidth" : "Game width is required if itchGamePlayableID is set." })
92+ if not self .itchGameHeight :
93+ raise ValidationError ({"itchGameHeight" : "Game height is required if itchGamePlayableID is set." })
94+
8395
8496class GameShowcase (models .Model ):
8597 game = models .OneToOneField ('Game' , on_delete = models .CASCADE , related_name = 'game_showcases' )
You can’t perform that action at this time.
0 commit comments