Merge pull request #4 from vincentmdealmeida/ValidationV2.1

Fixed a validation error where the form wouldn't validate after the d…
This commit is contained in:
vincentmdealmeida 2018-06-15 10:11:03 +01:00 committed by GitHub
commit 6b70b01e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 8 deletions

View file

@ -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()

View file

@ -133,9 +133,9 @@
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody id="sort" class="formset option-formset" data-formset-prefix="questions" data-formset-type="inline">
<tbody id="sort" class="formset option-formset" data-formset-prefix="options" data-formset-type="inline">
<!-- Option -->
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
<tr class="formset-form sorting-row" data-formset-form-prefix="option">
<!-- # -->
<th class="formset-form-index text-center" scope=row>
1
@ -155,7 +155,7 @@
</td>
</tr>
<!-- Option -->
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
<tr class="formset-form sorting-row" data-formset-form-prefix="option">
<!-- # -->
<th class="formset-form-index text-center" scope=row>
2
@ -175,7 +175,7 @@
</td>
</tr>
<!-- Option -->
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="question">
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="option">
<!-- # -->
<th class="formset-form-index text-center" scope=row>
X
@ -197,7 +197,7 @@
</tbody>
</table>
<div class="clearfix">
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="questions">
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="options">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
Add Question Option
</button>
@ -268,7 +268,7 @@
</td>
</tr>
<!-- Organiser -->
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
<tr class="formset-form sorting-row" data-formset-form-prefix="organiser">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
2
@ -287,7 +287,7 @@
</td>
</tr>
<!-- Organiser -->
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="question">
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="organiser">
<th class="formset-form-index text-center" scope=row>
<!-- # -->
X

View file

@ -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;
}
});