From 8d1967d4966124f9d2cb98f868f0cf799d5e97d2 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Fri, 13 Dec 2024 19:44:22 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Pridan=C3=A1=20valid=C3=A1cia,=20pri=20zakl?= =?UTF-8?q?adan=C3=AD=20semestra,=20=C4=8Di=20s=C3=BA=C5=A5a=C5=BE=20je=20?= =?UTF-8?q?naozaj=20semester?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- competition/serializers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/competition/serializers.py b/competition/serializers.py index c90ce14..d0dc76d 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -399,6 +399,8 @@ def validate(self, attrs): if attrs.get('season_code', 0) not in (0, 1): raise ValidationError( 'Seminár musí byť zimný alebo letný(season_code 0 alebo 1)') + if attrs.get('competition').competition_type.name != "Seminár": + raise ValidationError('Súťaž nie je typu seminár') return super().validate(attrs) def get_complete(self, obj: models.Semester): From 20ca8a375deae24967cbe5690d1cd46d173ec7a8 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Fri, 13 Dec 2024 20:06:56 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Kontrola=20spr=C3=A1vnosti=20competition=20?= =?UTF-8?q?iba=20ak=20je=20pr=C3=ADtomn=C3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- competition/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/competition/serializers.py b/competition/serializers.py index d0dc76d..1cf07c3 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -399,7 +399,8 @@ def validate(self, attrs): if attrs.get('season_code', 0) not in (0, 1): raise ValidationError( 'Seminár musí byť zimný alebo letný(season_code 0 alebo 1)') - if attrs.get('competition').competition_type.name != "Seminár": + competition: models.Competition | None = attrs.get('competition') + if competition and competition.competition_type.name != "Seminár": raise ValidationError('Súťaž nie je typu seminár') return super().validate(attrs)