Skip to content

Commit

Permalink
feat: Add playlist group validation to ToontjeHoger5Tempo rule (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
drikusroor authored Jun 10, 2024
1 parent 2fa7ebd commit b929575
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion backend/experiment/rules/toontjehoger_5_tempo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from experiment.actions.frontend_style import FrontendStyle, EFrontendStyle
from experiment.actions.playback import Multiplayer
from experiment.actions.styles import STYLE_NEUTRAL_INVERTED
from section.models import Playlist
from .base import Base
from experiment.utils import create_player_labels, non_breaking_spaces

Expand Down Expand Up @@ -83,7 +84,7 @@ def get_random_section_pair(self, session, genre):
valid_tag = False
tag_base = ""
tag_original = ""
while(not valid_tag):
while (not valid_tag):
track = random.choice([1, 2, 3, 4, 5])
pair = random.choice([1, 2])
tag_base = "{}{}_P{}_".format(genre.upper(), track, pair, )
Expand Down Expand Up @@ -253,3 +254,16 @@ def get_final_round(self, session):
)

return [*score, final, info]

def validate_playlist(self, playlist: Playlist):

errors = super().validate_playlist(playlist)
sections = playlist.section_set.all()
groups = sorted(list(set([section.group for section in sections])))

if groups != ['ch', 'or']:
errors.append(
"The playlist must contain two groups: 'or' and 'ch'. Found: {}".format(groups)
)

return errors

0 comments on commit b929575

Please sign in to comment.