Skip to content

Commit

Permalink
Merge pull request #4 from City-of-Turku/bugfix/question-importer-add…
Browse files Browse the repository at this point in the history
…s-subquestionconditions-on-every-import

Fix SubQuestionConditions created on every import
  • Loading branch information
juuso-j authored Feb 8, 2024
2 parents 643c683 + 26a977e commit d5261af
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions profiles/management/commands/import_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def create_sub_question_condition(row_data: str, sub_question: SubQuestion):
question_number, option_order_number = row_data.split(".")
question = Question.objects.get(number=question_number)
option = Option.objects.get(question=question, order_number=option_order_number)
SubQuestionCondition.objects.create(sub_question=sub_question, option=option)
SubQuestionCondition.objects.get_or_create(sub_question=sub_question, option=option)


@db.transaction.atomic
Expand Down Expand Up @@ -266,7 +266,6 @@ def handle(self, *args, **options):
# Question.objects.all().delete()
# QuestionCondition.objects.all().delete()
# Result.objects.all().delete()

file_path = f"{get_root_dir()}/media/{FILENAME}"
excel_data = pd.read_excel(file_path, sheet_name="Yhdistetty")
excel_data = excel_data.fillna("").replace([""], [None])
Expand Down

0 comments on commit d5261af

Please sign in to comment.