Browse Source

DIV-513

pull/160/head
Justin Johnson 8 years ago
parent
commit
7df4e6c26b
8 changed files with 168 additions and 8 deletions
  1. +2
    -1
      edivorce/apps/core/context_processors.py
  2. +12
    -2
      edivorce/apps/core/static/js/main.js
  3. +5
    -0
      edivorce/apps/core/templates/base.html
  4. +100
    -0
      edivorce/apps/core/templates/dashboard/current.html
  5. +1
    -0
      edivorce/apps/core/urls.py
  6. +34
    -4
      edivorce/apps/core/views/system.py
  7. +9
    -0
      edivorce/settings/base.py
  8. +5
    -1
      edivorce/urls.py

+ 2
- 1
edivorce/apps/core/context_processors.py View File

@ -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']
}

+ 12
- 2
edivorce/apps/core/static/js/main.js View File

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


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

@ -149,6 +149,11 @@
<li>
<a href="http://www2.gov.bc.ca/gov/content/home/contact-us" target="_blank">Contact Us</a>
</li>
{% if show_debug %}
<li>
<em><a href="/current">Debug Current User</a></em>
</li>
{% endif %}
</ul>
</div>
</footer>


+ 100
- 0
edivorce/apps/core/templates/dashboard/current.html View File

@ -0,0 +1,100 @@
{% extends 'base.html' %}
{% block formbuttons %}{% endblock %}
{% block sidebar %}{% endblock %}
{% block content %}
<style>
table.outer { width: 100%; }
table.outer td { width: 50%; vertical-align: top; }
td input { padding: 7px 10px; margin-bottom: 2px; }
table.inner { width: 90%; }
table.inner td { vertical-align: top; }
</style>
<h2>
Current User Controls
<small>
[ <a href="?reset=true" class="confirm-link"
data-message="This will delete the user and all responses.
Are you sure you want to continue?"
>Reset User</a> ]
[ <a href="#" class="previous-page">Previous Page</a> ]
</small>
</h2>
{% if request.user.is_anonymous %}
<p>The current user is not logged in.</p>
{% endif %}
<table class='outer'>
<tr>
<td>
{% if not request.user.is_anonymous %}
<h3>Responses</h3>
<table class='inner'>
{% for response in request.user.responses.all %}
<tr>
<td>{{ response.question.key }}</td>
<td>
<input
type='text'
name='{{ response.question.key }}'
value='{{ response.value }}'
/>
</td>
</tr>
{% empty %}
<tr>
<td colspan="2">No responses yet</td>
</tr>
{% endfor %}
</table>
{% endif %}
<h3>Session Data</h3>
<table class='inner'>
{% for key, value in request.session.items %}
{% if value != None %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<td colspan="2">No session data</td>
</tr>
{% endfor %}
</table>
</td>
<td>
{% if not request.user.is_anonymous %}
<h3>User Fields</h3>
<table class='inner'>
<tr>
<td>Has seen orders page</td>
<td>
{{ request.user.has_seen_orders_page }}<br>
[ <a href="?intercept=reset" class="confirm-link"
data-message="This will reset the flag triggering the Orders intercept screen preceding the overview. It also deletes any orders selections you may have made (but it doesn't delete responses on specific orders pages.
Are you sure you want to continue?"
>Reset intercept flag</a> ]<br>
[ <a href="{% url 'overview' %}">Overview Page</a> ]
</td>
</tr>
</table>
{% endif %}
</td>
</tr>
</table>
{% endblock %}

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

@ -28,5 +28,6 @@ urlpatterns = [
url(r'^pdf-form(?P<form_number>[0-9]{1,3}(_we|_claimant1|_claimant2)?)$', pdf.form, name="pdf_form"),
url(r'^prequalification/step_(?P<step>[0-9]{2})$', main.prequalification, name="prequalification"),
url(r'^question/(?P<step>.*)$', main.question, name="question_steps"),
url(r'^current', system.current, name="current"),
url(r'^$', main.home, name="home"),
]

+ 34
- 4
edivorce/apps/core/views/system.py View File

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

+ 9
- 0
edivorce/settings/base.py View File

@ -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,
}

+ 5
- 1
edivorce/urls.py View File

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

Loading…
Cancel
Save