From 1aeae6fd83a7489c0fe84d21f60fd94b935cb1cb Mon Sep 17 00:00:00 2001 From: walidmujahid Date: Wed, 26 Aug 2020 06:19:58 -0400 Subject: [PATCH] fix: duplicate registration on hackathon onboarding - return error on POST to /register_hackathon/ if user already registerd - if no poll, disable 'Join Now' button on hackathon onboard page on click - if poll, disable poll submit button on click --- app/dashboard/templates/dashboard/hackathon/onboard.html | 2 ++ app/dashboard/views.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/dashboard/templates/dashboard/hackathon/onboard.html b/app/dashboard/templates/dashboard/hackathon/onboard.html index dfa6e232a12..1a2e4c620e8 100644 --- a/app/dashboard/templates/dashboard/hackathon/onboard.html +++ b/app/dashboard/templates/dashboard/hackathon/onboard.html @@ -475,6 +475,7 @@

{{ question.text }}{{ questio const data = {'name': name, 'referer': referer}; const sendRegister = fetchData(url, 'POST', data, {'X-CSRFToken': csrftoken}); + $('[data-registration]').addClass('disabled'); $.when(sendRegister).then((response) => { _alert('You have now registered for this hackathon.', 'success'); console.log(response) @@ -492,6 +493,7 @@

{{ question.text }}{{ questio const data = { 'name': name, 'referer': referer, 'poll': JSON.stringify(poll)}; const sendRegister = fetchData(url, 'POST', data, {'X-CSRFToken': csrftoken}); + $(this).addClass('disabled'); $.when(sendRegister).then((response) => { _alert('You have now registered for this hackathon.', 'success'); console.log(response) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index c017cc083ca..a8dd2a4bbb9 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -4361,6 +4361,10 @@ def hackathon_registration(request): status=401) try: hackathon_event = HackathonEvent.objects.filter(slug__iexact=hackathon).latest('id') + + if HackathonRegistration.objects.filter(hackathon=hackathon_event, registrant=profile).exists(): + return JsonResponse({'error': _('Already registered.')}, status=401) + HackathonRegistration.objects.create( name=hackathon, hackathon=hackathon_event,