From 498b87dba50597c6855da6277b462b819a6b9e65 Mon Sep 17 00:00:00 2001 From: vince0656 Date: Fri, 15 Jun 2018 10:09:15 +0100 Subject: [PATCH] Fixed a validation error where the form wouldn't validate after the deletion of a row within any table --- allauthdemo/polls/views.py | 9 ++++++++- allauthdemo/templates/polls/create_event.html | 14 +++++++------- static/js/create-event-poll.js | 13 +++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/allauthdemo/polls/views.py b/allauthdemo/polls/views.py index 737a6fc..b927e57 100755 --- a/allauthdemo/polls/views.py +++ b/allauthdemo/polls/views.py @@ -304,7 +304,14 @@ def create_event(request): demo_users = DemoUser.objects.all() # Render the template - return render(request, "polls/create_event.html", {"G_R_SITE_KEY": settings.RECAPTCHA_PUBLIC_KEY, "user_email": request.user.email, "events": events, "demo_users": demo_users}) + return render(request, + "polls/create_event.html", + { + "G_R_SITE_KEY": settings.RECAPTCHA_PUBLIC_KEY, + "user_email": request.user.email, + "events": events, + "demo_users": demo_users + }) else: return HttpResponseNotAllowed() diff --git a/allauthdemo/templates/polls/create_event.html b/allauthdemo/templates/polls/create_event.html index 466d438..479d5eb 100755 --- a/allauthdemo/templates/polls/create_event.html +++ b/allauthdemo/templates/polls/create_event.html @@ -133,9 +133,9 @@ Actions - + - + 1 @@ -155,7 +155,7 @@ - + 2 @@ -175,7 +175,7 @@ - + X @@ -197,7 +197,7 @@
- @@ -268,7 +268,7 @@ - + 2 @@ -287,7 +287,7 @@ - + X diff --git a/static/js/create-event-poll.js b/static/js/create-event-poll.js index 28f70ed..142f7de 100755 --- a/static/js/create-event-poll.js +++ b/static/js/create-event-poll.js @@ -832,4 +832,17 @@ $('.formset-form-remove').click(function (e) { // Ported from DEMOS1 } updateFormset(formset); formset.trigger('formsetFormRemoved'); + + // Perform validation now that a row has been removed + switch (formPrefix) { + case 'option': + validateFormField(isPollOptionsValid, "options-input-error-block"); + break; + case 'organiser': + validateFormField(areOrganisersEmailsValid, "organisers-input-error-block"); + break; + case 'trustee': + validateFormField(areTrusteesEmailsValid, "trustees-input-error-block"); + break; + } }); \ No newline at end of file