Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/bittan/bittan/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .ticket import Ticket
from .swish_payment_request import SwishPaymentRequestModel
from .question import Question, QuestionType
from .question_option import QuestionOption, FieldOptions
from .question_option import QuestionOption
from .answer import Answer
from .answer_selected_options import AnswerSelectedOptions

2 changes: 1 addition & 1 deletion backend/bittan/bittan/models/answer_selected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class AnswerSelectedOptions(models.Model):
question_option = models.ForeignKey("QuestionOption", on_delete=models.DO_NOTHING)
anwser = models.ForeignKey("Answer", on_delete=models.DO_NOTHING)
answer = models.ForeignKey("Answer", on_delete=models.DO_NOTHING)
text = models.TextField(default="")

8 changes: 2 additions & 6 deletions backend/bittan/bittan/models/question_option.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from django.db import models

class FieldOptions(models.TextChoices):
MANDATORY = "mandatory", "Mandatory"
OPTIONAL = "optional", "Optional"
NO_TEXT = "no_text", "No text"

class QuestionOption(models.Model):
name = models.TextField()
description = models.TextField(default="")
price = models.IntegerField()
text = models.TextField(choices=FieldOptions)
question = models.ForeignKey("Question", on_delete=models.DO_NOTHING)
has_text = models.BooleanField()



31 changes: 15 additions & 16 deletions backend/bittan/scripts/create_mockdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from bittan.models import TicketType, ChapterEvent, Payment, Ticket, Question, QuestionOption, Answer, AnswerSelectedOptions
from bittan.models.payment import PaymentMethod, PaymentStatus
from bittan.models.question import QuestionType
from bittan.models.question_option import FieldOptions
import datetime

User.objects.create_superuser("admin", None, "admin")
Expand Down Expand Up @@ -55,7 +54,7 @@
opt1_1 = QuestionOption.objects.create(
price = 0,
name = "Namn",
text = FieldOptions.MANDATORY,
has_text = True,
question = q1
)

Expand All @@ -68,19 +67,19 @@
opt2_1 = QuestionOption.objects.create(
price = 0,
name = "Gluten",
text = FieldOptions.NO_TEXT,
has_text = False,
question = q2
)
opt2_2 = QuestionOption.objects.create(
price = 0,
name = "Laktos",
text = FieldOptions.NO_TEXT,
has_text = False,
question = q2
)
opt2_3 = QuestionOption.objects.create(
price = 0,
name = "Övrigt",
text = FieldOptions.MANDATORY,
has_text = True,
question = q2
)

Expand All @@ -92,13 +91,13 @@
opt3_1 = QuestionOption.objects.create(
price = 0,
name = "Gött",
text = FieldOptions.NO_TEXT,
has_text = False,
question = q3
)
opt3_2 = QuestionOption.objects.create(
price = 0,
name = "Nött",
text = FieldOptions.NO_TEXT,
has_text = False,
question = q3
)

Expand All @@ -110,13 +109,13 @@
opt4_1 = QuestionOption.objects.create(
name = "Extra punsch",
price = 20,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q4
)
opt4_2 = QuestionOption.objects.create(
name = "Extra nubbe",
price = 20,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q4
)

Expand All @@ -128,7 +127,7 @@
opt5_1 = QuestionOption.objects.create(
name = "Ja",
price = 0,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q5
)

Expand All @@ -140,7 +139,7 @@
opt6_1 = QuestionOption.objects.create(
name = "Ja",
price = 0,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q6
)

Expand All @@ -153,30 +152,30 @@
opt7_1 = QuestionOption.objects.create(
name = "F-24",
price = 0,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q7
)
opt7_2 = QuestionOption.objects.create(
name = "F-23",
price = 0,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q7
)
opt7_3 = QuestionOption.objects.create(
name = "F-22",
price = 0,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q7
)
opt7_4 = QuestionOption.objects.create(
name = "F-21",
price = 0,
text = FieldOptions.NO_TEXT,
has_text = False,
question = q7
)
opt7_5 = QuestionOption.objects.create(
name = "Annan: ",
price = 0,
text = FieldOptions.MANDATORY,
has_text = True,
question = q7
)