Skip to content

Commit

Permalink
Merge branch 'develop' into feature/1166-monitoring-list-for-manage-d…
Browse files Browse the repository at this point in the history
…ata-api
  • Loading branch information
ifirmawan authored Feb 19, 2024
2 parents c3027e8 + 7a503ff commit ff1d925
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 650 deletions.
6 changes: 6 additions & 0 deletions backend/api/v1/v1_forms/management/commands/form_seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ def handle(self, *args, **options):
self.stdout.write(
f"Form Updated | {form.name} V{form.version}")
# question group loop
list_of_question_ids = []
for qgi, qg in enumerate(json_form["question_groups"]):
question_group = QG.objects.filter(pk=qg["id"]).first()
list_of_question_ids += [q["id"] for q in qg["questions"]]
if not question_group:
question_group = QG.objects.create(
id=qg["id"],
Expand Down Expand Up @@ -162,6 +164,10 @@ def handle(self, *args, **options):
) for a in q.get("attributes")
])

# delete questions that are not in the json
Questions.objects.filter(
form=form).exclude(id__in=list_of_question_ids).delete()

# find JMP criteria config for by form id
jmp_criteria_form = [
cf for cf in jmp_criteria_json
Expand Down
Loading

0 comments on commit ff1d925

Please sign in to comment.