From d2029ef49541036fc827070fcf3b7c5245feea0a Mon Sep 17 00:00:00 2001 From: Ruslan Baidan Date: Tue, 14 Dec 2021 18:21:05 +0100 Subject: [PATCH] Reduced the complexity and line length. --- survey/management/commands/import_questions.py | 5 +---- .../1008_surveyquestion_answers_order_and_more.py | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/survey/management/commands/import_questions.py b/survey/management/commands/import_questions.py index 22f8673f..6beccad7 100644 --- a/survey/management/commands/import_questions.py +++ b/survey/management/commands/import_questions.py @@ -128,10 +128,7 @@ def handle(self, *args, **options): @staticmethod def does_question_exists(label: str, questions): - for question in questions: - if question.label == label: - return True - return False + return label in [question.label for question in questions] @staticmethod def process_answers_dependencies(answers_dependencies: Dict): diff --git a/survey/migrations/1008_surveyquestion_answers_order_and_more.py b/survey/migrations/1008_surveyquestion_answers_order_and_more.py index 6f9ac4e7..c36f4082 100644 --- a/survey/migrations/1008_surveyquestion_answers_order_and_more.py +++ b/survey/migrations/1008_surveyquestion_answers_order_and_more.py @@ -18,7 +18,14 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='surveyquestion', name='qtype', - field=models.CharField(choices=[('M', 'Multiple Choice'), ('S', 'Single Choice'), ('SS', 'Single Select Choice'), ('T', 'Free text'), ('MT', 'Multiple Choice + Free Text'), ('ST', 'Single Choice + Free Text')], default='M', max_length=2), + field=models.CharField(choices=[ + ('M', 'Multiple Choice'), + ('S', 'Single Choice'), + ('SS', 'Single Select Choice'), + ('T', 'Free text'), + ('MT', 'Multiple Choice + Free Text'), + ('ST', 'Single Choice + Free Text') + ], default='M', max_length=2), ), migrations.AlterField( model_name='surveyquestionanswer',