Skip to content

Commit

Permalink
updated enums and model
Browse files Browse the repository at this point in the history
  • Loading branch information
Tllew committed Feb 12, 2024
1 parent e4b610a commit fa66deb
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 49 deletions.
72 changes: 34 additions & 38 deletions api/survey/enums.py
Original file line number Diff line number Diff line change
@@ -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"
35 changes: 32 additions & 3 deletions api/survey/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions api/survey/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 0 additions & 2 deletions api/survey/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fa66deb

Please sign in to comment.