Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duplicate registration on hackathon onboarding #7290

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/dashboard/templates/dashboard/hackathon/onboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ <h4 class="font-header font-weight-bold pt-0 mb-5">{{ 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)
Expand All @@ -492,6 +493,7 @@ <h4 class="font-header font-weight-bold pt-0 mb-5">{{ 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)
Expand Down
4 changes: 4 additions & 0 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down