diff --git a/edivorce/apps/core/context_processors.py b/edivorce/apps/core/context_processors.py
index ddfb2a37..a4c3fc38 100644
--- a/edivorce/apps/core/context_processors.py
+++ b/edivorce/apps/core/context_processors.py
@@ -4,5 +4,6 @@ from django.conf import settings
def settings_processor(request):
return {
'gtm_id': settings.GTM_ID,
- 'proxy_root_path': settings.FORCE_SCRIPT_NAME
+ 'proxy_root_path': settings.FORCE_SCRIPT_NAME,
+ 'show_debug': settings.ENVIRONMENT in ['localdev', 'dev', 'test']
}
diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js
index 35e068a6..82802d76 100755
--- a/edivorce/apps/core/static/js/main.js
+++ b/edivorce/apps/core/static/js/main.js
@@ -132,7 +132,7 @@ $(function () {
var under19 = $('#unselected_child_support_alert').data('children-number-under-19');
var over19 = $('#unselected_child_support_alert').data('children-number-over-19');
var reasons = $('#unselected_child_support_alert').data('children-financial-support')
- reasons = reasons.filter((el) => { return el !== 'NO'; }).length > 0;
+ reasons = (reasons || []).filter((el) => { return el !== 'NO'; }).length > 0;
eligible = children === 'YES' && (under19 > 0 || (over19 > 0 && reasons));
}
var proceedNext = $(this).data('proceed');
@@ -194,8 +194,18 @@ $(function () {
$('.info-modal').on('click', function (e) {
e.preventDefault();
$('#info_modal').modal('show');
- })
+ });
+ $('.confirm-link').on('click', function (e) {
+ if (!confirm($(e.target).data('message'))) {
+ e.preventDefault();
+ }
+ });
+
+ $('.previous-page').on('click', function(e) {
+ e.preventDefault();
+ window.history.back();
+ });
});
// delete and added field and save the change
diff --git a/edivorce/apps/core/templates/base.html b/edivorce/apps/core/templates/base.html
index 52f60e37..49fa7721 100644
--- a/edivorce/apps/core/templates/base.html
+++ b/edivorce/apps/core/templates/base.html
@@ -149,6 +149,11 @@
Contact Us
+ {% if show_debug %}
+
+ Debug Current User
+
+ {% endif %}
diff --git a/edivorce/apps/core/templates/dashboard/current.html b/edivorce/apps/core/templates/dashboard/current.html
new file mode 100644
index 00000000..8b982276
--- /dev/null
+++ b/edivorce/apps/core/templates/dashboard/current.html
@@ -0,0 +1,100 @@
+{% extends 'base.html' %}
+
+{% block formbuttons %}{% endblock %}
+{% block sidebar %}{% endblock %}
+
+{% block content %}
+
+
+
+
+{% if request.user.is_anonymous %}
+The current user is not logged in.
+{% endif %}
+
+
+
+
+
+ {% if not request.user.is_anonymous %}
+ Responses
+
+ {% endif %}
+
+ Session Data
+
+ {% for key, value in request.session.items %}
+ {% if value != None %}
+
+ | {{ key }} |
+ {{ value }} |
+
+ {% endif %}
+ {% empty %}
+
+ | No session data |
+
+ {% endfor %}
+
+
+
+ |
+
+
+ {% if not request.user.is_anonymous %}
+ User Fields
+
+ {% endif %}
+
+ |
+
+
+
+{% endblock %}
+
+
diff --git a/edivorce/apps/core/urls.py b/edivorce/apps/core/urls.py
index 31209ddf..708dcc66 100644
--- a/edivorce/apps/core/urls.py
+++ b/edivorce/apps/core/urls.py
@@ -28,5 +28,6 @@ urlpatterns = [
url(r'^pdf-form(?P[0-9]{1,3}(_we|_claimant1|_claimant2)?)$', pdf.form, name="pdf_form"),
url(r'^prequalification/step_(?P[0-9]{2})$', main.prequalification, name="prequalification"),
url(r'^question/(?P.*)$', main.question, name="question_steps"),
+ url(r'^current', system.current, name="current"),
url(r'^$', main.home, name="home"),
]
diff --git a/edivorce/apps/core/views/system.py b/edivorce/apps/core/views/system.py
index 4cf1138c..e45fbe4a 100644
--- a/edivorce/apps/core/views/system.py
+++ b/edivorce/apps/core/views/system.py
@@ -1,14 +1,44 @@
-from django.http import HttpResponse
-from django.shortcuts import render
+from django.conf import settings
+from django.http import HttpResponse, Http404
+from django.shortcuts import render, redirect
from edivorce.apps.core.models import Question
-def health(request):
+def health(request): # pylint: disable=unused-argument
"""
OpenShift health check
"""
return HttpResponse(Question.objects.count())
+
def headers(request):
- return render(request, 'localdev/debug.html')
\ No newline at end of file
+ return render(request, 'localdev/debug.html')
+
+
+def current(request):
+ """
+ Debug tool usable in dev and test environments, available at /current
+ """
+ if settings.ENVIRONMENT not in ['localdev', 'dev', 'test']:
+ raise Http404()
+
+ if request.GET.get('reset', False):
+ if not request.user.is_anonymous():
+ request.user.responses.all().delete()
+ request.user.delete()
+ request.session.flush()
+ return redirect('/current')
+
+ if request.GET.get('intercept', False) and request.user.is_authenticated():
+ request.user.has_seen_orders_page = False
+ request.user.save()
+ request.user.responses.filter(question__key='want_which_orders').delete()
+ return redirect('/current')
+
+ context = {
+ 'hide_nav': True,
+ 'is_anonymous': request.user.is_anonymous(),
+ }
+
+ return render(request, 'dashboard/current.html', context=context)
diff --git a/edivorce/settings/base.py b/edivorce/settings/base.py
index 99339676..764f1df6 100644
--- a/edivorce/settings/base.py
+++ b/edivorce/settings/base.py
@@ -16,6 +16,7 @@ from unipath import Path
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
PROJECT_ROOT = Path(__file__).parent.parent.parent
BASE_DIR = Path(__file__).parent.parent
+ENVIRONMENT = os.environ.get('ENVIRONMENT_TYPE', 'localdev')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
@@ -49,6 +50,7 @@ INSTALLED_APPS = (
MIDDLEWARE_CLASSES = (
'edivorce.apps.core.middleware.basicauth_middleware.BasicAuthMiddleware',
+ 'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@@ -132,3 +134,10 @@ BASICAUTH_ENABLED = False
# Google Tag Manager (dev/test instance)
GTM_ID = 'GTM-NJLR7LT'
+
+def show_toolbar(request):
+ return ENVIRONMENT in ['localdev', 'dev', 'test']
+
+DEBUG_TOOLBAR_CONFIG = {
+ 'SHOW_TOOLBAR_CALLBACK': show_toolbar,
+}
diff --git a/edivorce/urls.py b/edivorce/urls.py
index c805c78c..6f56d95c 100644
--- a/edivorce/urls.py
+++ b/edivorce/urls.py
@@ -4,7 +4,11 @@ from django.contrib import admin
urlpatterns = []
-if settings.DEPLOYMENT_TYPE == 'localdev':
+if settings.ENVIRONMENT in ['localdev', 'dev']:
+ import debug_toolbar
+ urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)),)
+
+if settings.ENVIRONMENT == 'localdev':
urlpatterns.append(url(r'^admin/', admin.site.urls))
urlpatterns.append(url(r'^', include('edivorce.apps.core.urls')))