diff --git a/api/survey/enums.py b/api/survey/enums.py index 5adc649733..9c3e58db8f 100644 --- a/api/survey/enums.py +++ b/api/survey/enums.py @@ -1,38 +1,34 @@ -class RecommendationChoiceType: - SATISFIED = "SATISFIED" - - choices = [ - (SATISFIED, "SATISFIED"), - ] - - -class HelpfulGuidanceChoiceType: - STRONGLY_DISAGREE = "STRONGLY DISAGREE" - DISAGREE = "DISAGREE" - NEITHER_AGREE_NOR_DISAGREE = "NEITHER AGREE NOR DISAGREE" - AGREE = "AGREE" - STRONGLY_AGREE = "STRONGLY AGREE" - - choices = [ - (STRONGLY_DISAGREE, "STRONGLY DISAGREE"), - (DISAGREE, "DISAGREE"), - (NEITHER_AGREE_NOR_DISAGREE, "NEITHER AGREE NOR DISAGREE"), - (AGREE, "AGREE"), - (STRONGLY_AGREE, "STRONGLY AGREE"), - ] - - -class UserAccountChoiceType: - VERY_DIFFICULT = "VERY DIFFICULT" - DIFFICULT = "DIFFICULT" - NEITHER_DIFFICULT_NOR_EASY = "NEITHER DIFFICULT NOR EASY" - EASY = "EASY" - VERY_EASY = "VERY EASY" - - choices = [ - (VERY_DIFFICULT, "VERY DIFFICULT"), - (DIFFICULT, "DIFFICULT"), - (NEITHER_DIFFICULT_NOR_EASY, "NEITHER DIFFICULT NOR EASY"), - (EASY, "EASY"), - (VERY_EASY, "VERY EASY"), - ] +from django.db import models + + +class RecommendationChoiceType(models.TextChoices): + VERY_DISSATISFIED = "VERY_DISSATISFIED", "VERY_DISSATISFIED" + DISSATISFIED = "DISSATISFIED", "DISSATISFIED" + NEUTRAL = "NEUTRAL", "NEUTRAL" + SATISFIED = "SATISFIED", "SATISFIED" + VERY_SATISFIED = "VERY_SATISFIED", "VERY_SATISFIED" + + +class SatisfactionRatingEnum(models.TextChoices): + STRONGLY_DISAGREE = "STRONGLY DISAGREE", "STRONGLY DISAGREE" + DISAGREE = "DISAGREE", "DISAGREE" + NEITHER_AGREE_NOR_DISAGREE = "NEITHER AGREE NOR DISAGREE", "NEITHER AGREE NOR DISAGREE" + AGREE = "AGREE", "AGREE" + STRONGLY_AGREE = "STRONGLY AGREE", "STRONGLY AGREE" + + +class UserAccountEnum(models.TextChoices): + VERY_DIFFICULT = "VERY DIFFICULT", "VERY DIFFICULT" + DIFFICULT = "DIFFICULT", "DIFFICULT" + NEITHER_DIFFICULT_NOR_EASY = "NEITHER DIFFICULT NOR EASY", "NEITHER DIFFICULT NOR EASY" + EASY = "EASY", "EASY" + VERY_EASY = "VERY EASY", "VERY EASY" + + +class ExperiencedIssueEnum(models.TextChoices): + NO_ISSUE = "NO_ISSUE", "NO_ISSUE" + UNCLEAR = "UNCLEAR", "UNCLEAR" + NAVIGATION = "NAVIGATION", "NAVIGATION" + FEATURE = "FEATURE", "FEATURE" + SLOW = "SLOW", "SLOW" + OTHER = "OTHER", "OTHER" diff --git a/api/survey/migrations/0001_initial.py b/api/survey/migrations/0001_initial.py index 10aeac7b90..5e58a1758c 100644 --- a/api/survey/migrations/0001_initial.py +++ b/api/survey/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 4.2.10 on 2024-02-12 01:00 +# Generated by Django 4.2.9 on 2024-02-12 11:50 +import django.contrib.postgres.fields from django.db import migrations, models import django.utils.timezone import model_utils.fields @@ -34,9 +35,37 @@ class Migration(migrations.Migration): db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False ), ), - ("recommendation", models.TextField(choices=[("SATISFIED", "SATISFIED")])), + ( + "recommendation", + models.TextField( + choices=[ + ("VERY_DISSATISFIED", "VERY_DISSATISFIED"), + ("DISSATISFIED", "DISSATISFIED"), + ("NEUTRAL", "NEUTRAL"), + ("SATISFIED", "SATISFIED"), + ("VERY_SATISFIED", "VERY_SATISFIED"), + ] + ), + ), ("other_detail", models.TextField(blank=True, null=True)), - ("experienced_issue", models.JSONField(blank=True, null=True)), + ( + "experienced_issue", + django.contrib.postgres.fields.ArrayField( + base_field=models.CharField( + choices=[ + ("NO_ISSUE", "NO_ISSUE"), + ("UNCLEAR", "UNCLEAR"), + ("NAVIGATION", "NAVIGATION"), + ("FEATURE", "FEATURE"), + ("SLOW", "SLOW"), + ("OTHER", "OTHER"), + ] + ), + blank=True, + null=True, + size=None, + ), + ), ( "helpful_guidance", models.TextField( diff --git a/api/survey/models.py b/api/survey/models.py index cee33413a7..462e053055 100644 --- a/api/survey/models.py +++ b/api/survey/models.py @@ -1,20 +1,20 @@ import uuid from django.db import models - +from django.contrib.postgres.fields import ArrayField from api.common.models import TimestampableModel -from api.survey.enums import HelpfulGuidanceChoiceType, RecommendationChoiceType, UserAccountChoiceType +from api.survey.enums import SatisfactionRatingEnum, RecommendationChoiceType, UserAccountEnum, ExperiencedIssueEnum # Create your models here. class SurveyResponse(TimestampableModel): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, db_index=True) - recommendation = models.TextField( + recommendation = models.CharField( choices=RecommendationChoiceType.choices, ) other_detail = models.TextField(blank=True, null=True) - experienced_issue = models.JSONField(blank=True, null=True) - helpful_guidance = models.TextField(choices=HelpfulGuidanceChoiceType.choices, blank=True, default="") - user_account_process = models.TextField(choices=UserAccountChoiceType.choices, blank=True, default="") + experienced_issue = ArrayField(models.CharField(choices=ExperiencedIssueEnum.choices), blank=True, null=True) + helpful_guidance = models.CharField(choices=SatisfactionRatingEnum.choices, blank=True, default="") + user_account_process = models.CharField(choices=UserAccountEnum.choices, blank=True, default="") service_improvements_feedback = models.TextField(blank=True, null=True) def __str__(self): diff --git a/api/survey/views.py b/api/survey/views.py index f894d16f5c..f0fc6a3393 100644 --- a/api/survey/views.py +++ b/api/survey/views.py @@ -3,10 +3,8 @@ from api.core.authentication import ExporterAuthentication from api.survey.models import SurveyResponse from api.survey.serializers import SurveySerializer -from api.conf.pagination import MaxPageNumberPagination -# Create your views here. class SurveyCreateAPIView(CreateAPIView): authentication_classes = (ExporterAuthentication,) queryset = SurveyResponse.objects.all()