Skip to content

Commit

Permalink
Fix migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed Dec 5, 2016
1 parent df3364e commit 46c0f86
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import itertools
from django.db import migrations
from pyxform.xls2json import parse_file_to_json
from botocore.exceptions import ClientError


def populate_index_fields(apps, schema_editor):
Expand All @@ -19,7 +20,6 @@ def update_question(idx, **kwargs):
question.save()

def update_group(idx, **kwargs):
print(kwargs)
group = QuestionGroup.objects.get(**kwargs)
group.index = idx
group.save()
Expand Down Expand Up @@ -47,8 +47,13 @@ def update_children(children, questionnaire_id, question_group_id=None):
id=project.current_questionnaire)

if questionnaire.xls_form:
q_json = parse_file_to_json(questionnaire.xls_form.file.name)
update_children(q_json.get('children', []), questionnaire.id)
try:
q_json = parse_file_to_json(
questionnaire.xls_form.file.name)
update_children(
q_json.get('children', []), questionnaire.id)
except ClientError:
pass


class Migration(migrations.Migration):
Expand Down

0 comments on commit 46c0f86

Please sign in to comment.