Skip to content

Commit

Permalink
Add fields to models to order question parts and add chosen options f…
Browse files Browse the repository at this point in the history
…or the answers
  • Loading branch information
nmenezes0 committed Jan 2, 2025
1 parent 2269ed5 commit bf11d0e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 5.1.4 on 2025-01-02 09:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("consultations", "0028_alter_consultation2_slug_alter_question2_slug"),
]

operations = [
migrations.AddField(
model_name="answer2",
name="chosen_options",
field=models.JSONField(default=list),
),
migrations.AddField(
model_name="questionpart",
name="order",
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name="question2",
name="order",
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name="questionpart",
name="options",
field=models.JSONField(default=list),
),
]
8 changes: 4 additions & 4 deletions consultation_analyser/consultations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,8 @@ class Meta(UUIDPrimaryKeyModel.Meta, TimeStampedModel.Meta):
class Question2(UUIDPrimaryKeyModel, TimeStampedModel, SlugFromTextModel):
text = models.TextField()
consultation = models.ForeignKey(Consultation2, on_delete=models.CASCADE)
order = models.IntegerField()
order = models.IntegerField(null=True)
question_group = models.ForeignKey(QuestionGroup, on_delete=models.CASCADE, null=True)
# TODO - add slug

class Meta(UUIDPrimaryKeyModel.Meta, TimeStampedModel.Meta, SlugFromTextModel.Meta):
constraints = [
Expand All @@ -411,13 +410,13 @@ class QuestionType(models.TextChoices):
question = models.ForeignKey(Question2, on_delete=models.CASCADE)
text = models.TextField()
type = models.CharField(max_length=16, choices=QuestionType.choices)
options = models.JSONField(default=list, blank=True)
options = models.JSONField(default=list)
order = models.IntegerField(null=True)

class Meta(UUIDPrimaryKeyModel.Meta, TimeStampedModel.Meta):
pass


# TODO - add expanded question
class ExpandedQuestion(UUIDPrimaryKeyModel, TimeStampedModel):
question_part = models.ForeignKey(QuestionPart, on_delete=models.CASCADE)
text = models.TextField()
Expand All @@ -441,6 +440,7 @@ class Answer2(UUIDPrimaryKeyModel, TimeStampedModel):
question_part = models.ForeignKey(QuestionPart, on_delete=models.CASCADE)
respondent = models.ForeignKey(Respondent, on_delete=models.CASCADE)
text = models.TextField()
chosen_options = models.JSONField(default=list)
# TODO - add favourite

class Meta(UUIDPrimaryKeyModel.Meta, TimeStampedModel.Meta):
Expand Down
Binary file modified docs/erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bf11d0e

Please sign in to comment.