| @ -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,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 | from edivorce.apps.core.models import Question | ||||
| def health(request): | |||||
| def health(request): # pylint: disable=unused-argument | |||||
| """ | """ | ||||
| OpenShift health check | OpenShift health check | ||||
| """ | """ | ||||
| return HttpResponse(Question.objects.count()) | return HttpResponse(Question.objects.count()) | ||||
| def headers(request): | 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) | |||||