Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Add playlist group validation to ToontjeHoger5Tempo rule #1080

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading