Browse Source

DIV-1245: Add validation of court file number

pull/172/head
ariannedee 5 years ago
parent
commit
baa633b9f8
11 changed files with 41 additions and 40 deletions
  1. +1
    -1
      edivorce/apps/core/static/css/main.css
  2. +3
    -0
      edivorce/apps/core/static/css/main.scss
  3. +21
    -6
      edivorce/apps/core/static/js/filing.js
  4. +0
    -17
      edivorce/apps/core/static/js/signing-filing.js
  5. +0
    -1
      edivorce/apps/core/templates/base.html
  6. +4
    -1
      edivorce/apps/core/templates/dashboard/final_filing.html
  7. +7
    -1
      edivorce/apps/core/templates/dashboard/sign_file_options.html
  8. +2
    -2
      edivorce/apps/core/templates/partials/filing_location.html
  9. +0
    -1
      edivorce/apps/core/urls.py
  10. +0
    -10
      edivorce/apps/core/views/api.py
  11. +3
    -0
      edivorce/apps/core/views/efiling.py

+ 1
- 1
edivorce/apps/core/static/css/main.css
File diff suppressed because it is too large
View File


+ 3
- 0
edivorce/apps/core/static/css/main.scss View File

@ -812,6 +812,9 @@ i.fa.fa-question-circle {
.error-text { .error-text {
color: $color-red; color: $color-red;
font-weight: bold;
font-size: 14px;
margin-top: 10px;
} }
.table-error { .table-error {


+ 21
- 6
edivorce/apps/core/static/js/filing.js View File

@ -1,18 +1,33 @@
$(window).ready(function () { $(window).ready(function () {
function validateCourtFileNumber(e) {
var fileNumber = $("#court-file-number").val();
const regex = RegExp('^[0-9]{4,10}$');
var valid = !fileNumber || regex.test(fileNumber);
$('#court-file-error').toggle(!valid);
return valid;
}
$("#court-file-number").on('change', validateCourtFileNumber);
validateCourtFileNumber();
$('#submitDocuments').on('click', function (e) { $('#submitDocuments').on('click', function (e) {
var missingForms = []
var errors = []
if (!validateCourtFileNumber()) {
errors.push("A Court File Number contains only digits and must be between 4 and 10 digits in length");
}
$('div#app').children().each(function (i, child) { $('div#app').children().each(function (i, child) {
if ($(child).find("div.placeholder.required").length > 0) { if ($(child).find("div.placeholder.required").length > 0) {
missingForms.push($(child).find("h5 a").text());
var formName = $(child).find("h5 a").text();
errors.push(`Missing documents for ${formName}`);
} }
}) })
var errorBox = $('#error-message-box'); var errorBox = $('#error-message-box');
if (missingForms.length > 0) {
var messageList = $('#error-messages');
if (errors.length > 0) {
e.preventDefault(); e.preventDefault();
var messageList = $('#error-messages');
messageList.empty(); messageList.empty();
missingForms.forEach(function (formName) {
messageList.append(`<li>Missing documents for ${formName}</li>`);
errors.forEach(function (message) {
messageList.append(`<li>${message}</li>`);
}); });
errorBox.show(); errorBox.show();
window.scrollTo(0, 0); window.scrollTo(0, 0);


+ 0
- 17
edivorce/apps/core/static/js/signing-filing.js View File

@ -140,21 +140,4 @@ $(window).load(function () {
$('#unfilled-email-alert').hide(); $('#unfilled-email-alert').hide();
} }
}); });
if ($('#court-registry-location').length > 0) {
var city = $('#court-registry-city').text()
var url = $(location).attr('origin') + window.sm_base_url + 'api/court_location/' + city + '/';
$.ajax(url,
{
type: 'GET',
}).success((response) => {
var data = JSON.parse(response);
$('#court-registry-address').text(data.address);
$('#court-registry-postal-code').text(data.postal_code);
}).error((response) => {
$('#court-registry-address').html('<span class="error-text">No address found</span>');
$('#court-registry-postal-code').html('<a href="https://www.bccourts.ca/supreme_court/court_locations_and_contacts.aspx">Look up address</a>');
});
}
}); });

+ 0
- 1
edivorce/apps/core/templates/base.html View File

@ -219,7 +219,6 @@
<script type="text/javascript" src="{% static 'js/functions.js' %}"></script> <script type="text/javascript" src="{% static 'js/functions.js' %}"></script>
<script type="text/javascript" src="{% static 'js/ajax.js' %}"></script> <script type="text/javascript" src="{% static 'js/ajax.js' %}"></script>
<script type="text/javascript" src="{% static 'js/main.js' %}"></script> <script type="text/javascript" src="{% static 'js/main.js' %}"></script>
<script type="text/javascript" src="{% static 'js/signing-filing.js' %}"></script>
{% endcompress %} {% endcompress %}
{% block extra_js %} {% block extra_js %}
{% endblock %} {% endblock %}


+ 4
- 1
edivorce/apps/core/templates/dashboard/final_filing.html View File

@ -88,7 +88,10 @@
</p> </p>
<div> <div>
<label>{% include "partials/tooltips/court_file_number.html" with text="Court File #" %}</label> <label>{% include "partials/tooltips/court_file_number.html" with text="Court File #" %}</label>
{% input_field type="text" name="court_file_number" class="input-inline" %}
{% input_field type="number" name="court_file_number" id="court-file-number" class="input-inline" %}
<p class="error-text" hidden id="court-file-error">
A Court File Number contains only digits and must be between 4 and 10 digits in length.
</p>
</div> </div>
</div> </div>
<div class="upload-area"> <div class="upload-area">


+ 7
- 1
edivorce/apps/core/templates/dashboard/sign_file_options.html View File

@ -1,5 +1,6 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load input_field %} {% load input_field %}
{% load static %}
{% block title %}{{ block.super }}: Overview{% endblock %} {% block title %}{{ block.super }}: Overview{% endblock %}
@ -172,7 +173,8 @@
</div> </div>
<h3>Select where your spouse would like to {% include "partials/tooltips/swear_affirm.html" %} your affidavit(s):</h3> <h3>Select where your spouse would like to {% include "partials/tooltips/swear_affirm.html" %} your affidavit(s):</h3>
<div class="radio"><label>{% input_field type="radio" name="signing_location_spouse" value="In-person" id="sign-in-person-spouse" %} <div class="radio"><label>{% input_field type="radio" name="signing_location_spouse" value="In-person" id="sign-in-person-spouse" %}
My spouse will sign with a lawyer, notary or other {% include "partials/tooltips/commissioner.html" with hover=True %} for taking affidavits
My spouse will sign with a lawyer, notary or other {% include "partials/tooltips/commissioner.html" with hover=True %} for taking
affidavits
</label></div> </label></div>
<div class="radio"><label>{% input_field type="radio" name="signing_location_spouse" value="Virtual" id="sign-virtual-spouse" %} <div class="radio"><label>{% input_field type="radio" name="signing_location_spouse" value="Virtual" id="sign-virtual-spouse" %}
My spouse will sign in a {% include "partials/tooltips/virtual_session.html" with hover=True %} with the court registry</label> My spouse will sign in a {% include "partials/tooltips/virtual_session.html" with hover=True %} with the court registry</label>
@ -242,4 +244,8 @@
These steps will differ based on how you select to sign and file your documentation on this page.</p> These steps will differ based on how you select to sign and file your documentation on this page.</p>
<p>Once you've got your paperwork together, completed, signed and sworn, you can file it with <p>Once you've got your paperwork together, completed, signed and sworn, you can file it with
the Court Registry.</p> the Court Registry.</p>
{% endblock %}
{% block extra_js %}
<script type="text/javascript" src="{% static 'js/signing-filing.js' %}"></script>
{% endblock %} {% endblock %}

+ 2
- 2
edivorce/apps/core/templates/partials/filing_location.html View File

@ -1,8 +1,8 @@
{% if court_registry_for_filing %} {% if court_registry_for_filing %}
<ul class="no-bullets" id="court-registry-location"> <ul class="no-bullets" id="court-registry-location">
<li id="court-registry-city"><b>{{ court_registry_for_filing }}</b></li> <li id="court-registry-city"><b>{{ court_registry_for_filing }}</b></li>
<li id="court-registry-address"></li>
<li id="court-registry-postal-code"></li>
<li id="court-registry-address">{{ court_registry_for_filing_address }}</li>
<li id="court-registry-postal-code">{{ court_registry_for_filing_postal_code }}</li>
</ul> </ul>
{% else %} {% else %}
<div class="review-warning"> <div class="review-warning">


+ 0
- 1
edivorce/apps/core/urls.py View File

@ -8,7 +8,6 @@ urlpatterns = [
url(r'^api/response$', api.UserResponseHandler.as_view()), url(r'^api/response$', api.UserResponseHandler.as_view()),
path('api/documents/', api.DocumentCreateView.as_view(), name='documents'), path('api/documents/', api.DocumentCreateView.as_view(), name='documents'),
path('api/documents/<file_key>/<int:rotation>/', api.get_document_file_by_key, name='file_by_key'), path('api/documents/<file_key>/<int:rotation>/', api.get_document_file_by_key, name='file_by_key'),
path('api/court_location/<city>/', api.court_location, name='court-location'),
# we add an extra 'x' to the file extension so the siteminder proxy doesn't treat it as an image # we add an extra 'x' to the file extension so the siteminder proxy doesn't treat it as an image
path('api/documents/<doc_type>/<int:party_code>/<filename>x/<int:size>/', api.DocumentView.as_view(), name='document'), path('api/documents/<doc_type>/<int:party_code>/<filename>x/<int:size>/', api.DocumentView.as_view(), name='document'),


+ 0
- 10
edivorce/apps/core/views/api.py View File

@ -1,4 +1,3 @@
import json
import re import re
from django.http import Http404, HttpResponse, HttpResponseGone, HttpResponseNotFound from django.http import Http404, HttpResponse, HttpResponseGone, HttpResponseNotFound
@ -55,15 +54,6 @@ class UserResponseHandler(APIView):
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)
def court_location(request, city):
data = {
'city': city,
'address': f'123 {city} St',
'postal_code': 'V0A 0A0',
}
return HttpResponse(content=json.dumps(data), status=status.HTTP_200_OK)
class DocumentCreateView(CreateAPIView): class DocumentCreateView(CreateAPIView):
serializer_class = CreateDocumentSerializer serializer_class = CreateDocumentSerializer
permission_classes = [permissions.IsAuthenticated] permission_classes = [permissions.IsAuthenticated]


+ 3
- 0
edivorce/apps/core/views/efiling.py View File

@ -1,5 +1,6 @@
import base64 import base64
import random import random
import re
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
@ -70,6 +71,8 @@ def _validate_and_submit_documents(request, responses, initial=False):
court_file_number = responses.get('court_file_number') court_file_number = responses.get('court_file_number')
if not court_file_number: if not court_file_number:
errors.append("You must input your Court File Number") errors.append("You must input your Court File Number")
elif not re.search("^[0-9]{4,10}$", court_file_number):
errors.append("A Court File Number contains only digits and must be between 4 and 10 digits in length")
uploaded, generated = forms_to_file(responses, initial) uploaded, generated = forms_to_file(responses, initial)
for form in uploaded: for form in uploaded:


Loading…
Cancel
Save