From 7878693537493876b8d999145846f890eba0de2f Mon Sep 17 00:00:00 2001 From: Rohan Moniz <60864468+rm03@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:52:29 -0500 Subject: [PATCH] oops --- backend/clubs/views.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/clubs/views.py b/backend/clubs/views.py index cdb2519f9..db36edd5c 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -4479,7 +4479,7 @@ def question_response(self, *args, **kwargs): submissions page""", } ) - submission, _ = ApplicationSubmission.objects.update_or_create( + submission, _ = ApplicationSubmission.objects.get_or_create( user=self.request.user, application=application, committee=committee, @@ -4507,11 +4507,11 @@ def question_response(self, *args, **kwargs): ): text = question_data.get("text", None) if text is not None and text != "": - obj, _ = ApplicationQuestionResponse.objects.get_or_create( - question=question, submission=submission, + obj, _ = ApplicationQuestionResponse.objects.update_or_create( + question=question, + submission=submission, + defaults={"text": text}, ) - obj.text = text - obj.save() response = Response(ApplicationQuestionResponseSerializer(obj).data) elif question_type == ApplicationQuestion.MULTIPLE_CHOICE: multiple_choice_value = question_data.get("multipleChoice", None) @@ -4519,11 +4519,11 @@ def question_response(self, *args, **kwargs): multiple_choice_obj = ApplicationMultipleChoice.objects.filter( question=question, value=multiple_choice_value ).first() - obj, _ = ApplicationQuestionResponse.objects.get_or_create( - question=question, submission=submission, + obj, _ = ApplicationQuestionResponse.objects.update_or_create( + question=question, + submission=submission, + defaults={"multiple_choice": multiple_choice_obj}, ) - obj.multiple_choice = multiple_choice_obj - obj.save() response = Response(ApplicationQuestionResponseSerializer(obj).data) return response