38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from webapp.models import Signup, SignupForm
|
|
from django.utils import timezone
|
|
from webapp.utils import month_from_now
|
|
|
|
import json
|
|
|
|
ALL_QUESTION_TYPES = [
|
|
{"id": "j5CeRZDvl", "name": "Asd", "type": "text", "options": []},
|
|
{"id": "RHJhSoaLD", "name": "Asd2", "type": "radiobutton", "options": ["Yes", "no", "maybe"]},
|
|
{"id": "i10d426d5", "name": "Asd3", "type": "checkbox", "options": ["A", "B", "C"]}
|
|
]
|
|
|
|
ALL_QUESTION_TYPES_ANSWER = {"j5CeRZDvl": "Testi", "RHJhSoaLD": "maybe", "i10d426d5": ["B", "C"]}
|
|
|
|
|
|
def createSignupForm(name="Form1", start_time=timezone.now(), end_time=month_from_now(), questions=ALL_QUESTION_TYPES, visible=True):
|
|
return SignupForm.objects.create(
|
|
title=name,
|
|
start_time=start_time,
|
|
end_time=end_time,
|
|
questions=questions,
|
|
visible=visible
|
|
)
|
|
|
|
|
|
def createSignupObject(form, answer):
|
|
return Signup.objects.create(
|
|
signupForm=form,
|
|
answer=answer
|
|
)
|
|
|
|
|
|
def createSignupRequest(form_id, answer):
|
|
return {
|
|
"signupForm_id": form_id,
|
|
"answer": answer
|
|
}
|