From bc3dae98b0ef75578630619be0e495fc3062b3cd Mon Sep 17 00:00:00 2001 From: Parbhat Puri <parbhatpuri17@gmail.com> Date: Wed, 20 Mar 2019 10:27:50 +0000 Subject: [PATCH] calculate length once --- opentech/apply/stream_forms/blocks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opentech/apply/stream_forms/blocks.py b/opentech/apply/stream_forms/blocks.py index 18d0502d5..4167e6a0d 100644 --- a/opentech/apply/stream_forms/blocks.py +++ b/opentech/apply/stream_forms/blocks.py @@ -210,10 +210,11 @@ class GroupToggleBlock(FormFieldBlock): (choice, choice) for choice in struct_value['choices'] ] - if len(field_choices) > 2: + total_choices = len(field_choices) + if total_choices > 2: # For toggle we need only two choices field_choices = field_choices[:2] - elif len(field_choices) < 2: + elif total_choices < 2: field_choices = [ ('yes', 'Yes'), ('no', 'No'), -- GitLab