diff_index = -1
for pitch in self.pitches.all():
- for index, diff_choice in enumerate(ROUTE_DIFFICULTY_CHOICES):
- if pitch.difficulty == diff_choice[0]:
- if diff_index < index:
- diff = pitch.difficulty
- diff_index = index
- break
+ p_diff_index = _route_difficulty_index(pitch.difficulty)
+
+ if p_diff_index > diff_index:
+ diff_index = p_diff_index
+ diff = pitch.difficulty
return diff
('5.15d', '5.15d'),
)
+def _route_difficulty_index(difficulty):
+ for i, d in enumerate(ROUTE_DIFFICULTY_CHOICES):
+ if difficulty == d[0]:
+ return i
+ return -1
+
SAFETY_CHOICES = (
('G', 'G'),
('PG', 'PG'),