diff --git a/hackfsu_com/urls.py b/hackfsu_com/urls.py index fece7fa..086e186 100644 --- a/hackfsu_com/urls.py +++ b/hackfsu_com/urls.py @@ -18,8 +18,6 @@ from django.contrib import admin from django.conf import settings from django.conf.urls.static import static -from django.views.generic.base import RedirectView -from django.urls import reverse app_name = 'hackfsu' handler404 = 'webapp.views.handler404' @@ -31,12 +29,5 @@ url('', include('webapp.urls', namespace='webapp')) ] -# Shortcuts -urlpatterns.extend([ - url(r'^register/$', RedirectView.as_view(url=reverse('webapp:registration-user'))), - url(r'^login/$', RedirectView.as_view(url=reverse('webapp:user-login'))), - url(r'^logout/$', RedirectView.as_view(url=reverse('webapp:user-logout'))) -]) - if settings.DEBUG: urlpatterns.extend(static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)) diff --git a/webapp/js/plugins/ajaxForm.js b/webapp/js/plugins/ajaxForm.js index b6b8e54..b2b9b17 100644 --- a/webapp/js/plugins/ajaxForm.js +++ b/webapp/js/plugins/ajaxForm.js @@ -19,6 +19,7 @@ setDisabled: function(value) { return value; }, onAjaxComplete: function(response, data) { console.log(response, data); }, onAjaxError: function(error, data) { console.error(error); }, + afterError: function() {}, parsleyOptions: {} }; @@ -131,6 +132,7 @@ canSubmit = true; o.setDisabled(false); o.onAjaxError(error, jsonData); + o.afterError(); }); }); diff --git a/webapp/urls.py b/webapp/urls.py index e953d86..ffdae9e 100644 --- a/webapp/urls.py +++ b/webapp/urls.py @@ -31,17 +31,27 @@ def static_redirect(path): url(r'^registration/user/$', views.registration.UserRegistrationPage.as_view(), name='registration-user'), url(r'^registration/hacker/$', views.registration.HackerRegistrationPage.as_view(), name='registration-hacker'), - # url(r'^registration/judge/$', views.registration.JudgeRegistrationPage.as_view(), name='registration-judge'), - # url(r'^registration/mentor/$', views.registration.MentorRegistrationPage.as_view(), name='registration-mentor'), - # url(r'^registration/organizer/$', views.registration.OrganizerRegistrationPage.as_view(), - # name='registration-organizer'), + url(r'^registration/judge/$', views.registration.JudgeRegistrationPage.as_view(), name='registration-judge'), + url(r'^registration/mentor/$', views.registration.MentorRegistrationPage.as_view(), name='registration-mentor'), + url(r'^registration/organizer/$', views.registration.OrganizerRegistrationPage.as_view(), + name='registration-organizer'), url(r'^user/login/$', views.user.LoginPage.as_view(), name='user-login'), url(r'^user/logout/$', views.user.logout_view, name='user-logout'), url(r'^user/profile/$', views.user.ProfilePage.as_view(), name='user-profile'), url(r'^hype/$', views.hype.HypeIndex.as_view()), - url(r'^hype/registration$', views.hype.HypeRegistration.as_view()) + url(r'^hype/registration$', views.hype.HypeRegistration.as_view()), + + + # Shortcuts + url(r'^register/$', RedirectView.as_view(url='/registration/user')), + url(r'^register/hacker/$', RedirectView.as_view(url='/registration/user?attendee_type=hacker')), + url(r'^register/organizer/$', RedirectView.as_view(url='/registration/user?attendee_type=organizer')), + url(r'^register/mentor/$', RedirectView.as_view(url='/registration/user?attendee_type=mentor')), + url(r'^register/judge$', RedirectView.as_view(url='/registration/user?attendee_type=judge')), + url(r'^login/$', RedirectView.as_view(url='/user/login')), + url(r'^logout/$', RedirectView.as_view(url='/user/logout')) ] if settings.DEBUG: diff --git a/webapp/views/registration/user/index.pug b/webapp/views/registration/user/index.pug index 04fb59b..8f7dd4b 100644 --- a/webapp/views/registration/user/index.pug +++ b/webapp/views/registration/user/index.pug @@ -13,6 +13,18 @@ block content h1 Registration form#register_user .form-section + fieldset.row + .field-label.col-md-3 I want to... * + .col-md-9: select.responsive(name="attendee_type" required) + option(value="" disabled selected) + option(value="hacker") register as a hacker. + option(value="mentor") register as a mentor. + option(value="judge") register as a judge. + option(value="organizer") register as an organizer. + option(value="other") register as a combination of the above. + option(value="other") figure out want I want to do later. + option(value="other") just make an account. + fieldset.row .field-label.col-md-3 Email * .col-md-9: input.responsive(type="email" name="email" maxlength=100 placeholder="your@school.edu" required) diff --git a/webapp/views/registration/user/script.js b/webapp/views/registration/user/script.js index b1f8bc6..aeec36d 100644 --- a/webapp/views/registration/user/script.js +++ b/webapp/views/registration/user/script.js @@ -6,6 +6,7 @@ 'use strict'; var form = $('form#register_user'); + var attendeeType = form.find('select[name="attendee_type"]'); var firstName = form.find('input[name="first_name"]'); var lastName = form.find('input[name="last_name"]'); var emailInput = form.find('input[name="email"]'); @@ -18,6 +19,8 @@ var mlhCoc = form.find('input[name="mlhcoc"]'); var mlhTac = form.find('input[name="mlhtac"]'); + + $('#diet-detail, #allergy').change(function () { dietInput.toggle($('#diet-other').is(':checked') || $('#allergy').is(':checked')); }); @@ -51,13 +54,17 @@ diet: getDiet() }; }, - onAjaxComplete: function(response) { - console.log('complete', response); - if (response.logged_in) { - window.location.href = '/user/profile'; - } else { - window.location.href = '/user/login'; + onAjaxComplete: function() { + var destination = '/user/profile'; + var type = attendeeType.val(); + if (type !== 'other') { + destination = '/registration/' + type; } + + window.location.href = destination; + }, + afterError: function() { + window.grecaptcha.reset(); } });