From 03747d8c2464884279c86cbb0c8ba087e109afb8 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Fri, 1 May 2020 22:36:47 +0900 Subject: [PATCH] disable survey modal if no survey --- .../dashboard/hackathon/onboard.html | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/app/dashboard/templates/dashboard/hackathon/onboard.html b/app/dashboard/templates/dashboard/hackathon/onboard.html index 9c8bb8edeb6..3e6004f081b 100644 --- a/app/dashboard/templates/dashboard/hackathon/onboard.html +++ b/app/dashboard/templates/dashboard/hackathon/onboard.html @@ -326,22 +326,33 @@

{{ question.text }}

if (is_registered) { return; } - $('#questions-form').modal('show'); - $('#send_poll').unbind('click') - $('#send_poll').on('click', function () { + if ($('#questions-form').find('input').length == 0) { + const url = '/register_hackathon/'; + const data = {'name': name, 'referer': referer}; + const sendRegister = fetchData(url, 'POST', data, {'X-CSRFToken': csrftoken}); - const poll = $('#hackathon-poll').serializeArray() - const url = '/register_hackathon/' - const data = { 'name': name, 'referer': referer, 'poll': JSON.stringify(poll)} - const sendRegister = fetchData(url, 'POST', data, {'X-CSRFToken': csrftoken}); + $.when(sendRegister).then((response) => { + _alert('You have now registered for this hackathon.', 'success'); + console.log(response) + document.location.href = response.redirect; + }); + } else { + $('#questions-form').modal('show'); + $('#send_poll').unbind('click') + $('#send_poll').on('click', function () { + const poll = $('#hackathon-poll').serializeArray(); + const url = '/register_hackathon/'; + const data = { 'name': name, 'referer': referer, 'poll': JSON.stringify(poll)}; + const sendRegister = fetchData(url, 'POST', data, {'X-CSRFToken': csrftoken}); - $.when(sendRegister).then((response) => { - _alert('You have now registered for this hackathon.', 'success'); - console.log(response) - document.location.href = response.redirect; + $.when(sendRegister).then((response) => { + _alert('You have now registered for this hackathon.', 'success'); + console.log(response) + document.location.href = response.redirect; + }); }); - }); + } } const params = new URLSearchParams(window.location.search);