Skip to content

Fkm/form submission#80

Open
Gabrimari wants to merge 17 commits intofkm/mainfrom
fkm/form-submission
Open

Fkm/form submission#80
Gabrimari wants to merge 17 commits intofkm/mainfrom
fkm/form-submission

Conversation

@Gabrimari
Copy link
Contributor

Add endpoint for form submission to the database.

"QuestionNotFound": status.HTTP_404_NOT_FOUND,
"QuestionOptionNotFound": status.HTTP_404_NOT_FOUND
}
error_helper = lambda msg: Response(msg, CODE_MAPPINGS[msg])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skriv om som funktion?

session_id = serializers.CharField(required=True)
form_data = serializers.ListField(child=QuestionSerializer(), required=True)

def validate_payment(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get payment?


return payment

def validate_event(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kanske tydligare namn?

if not chapter_event.question_set.filter(pk=qs["question_id"]).exists():
return error_helper("QuestionNotFound")

q_db = chapter_event.question_set.get(pk=qs["question_id"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kommer skicka en jäkla massa DB requests men spelar förmodligen ingen roll

if isinstance(payment, Response):
return payment

# Only supports forms if there are one ticket (for now).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kracha om fler än en ticket?

r["question_id"]: r for r in response_data["form_data"]
}

q_errors = validate_questions(form_data_map, chapter_event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fett najs :)

if q_errors:
return q_errors

# Update everhything at once (!?) if the session is valid.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!? hmmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants