Updated the tracker to not crash if the back end isn't running or can't be found.

This commit is contained in:
Ada Werefox 2024-03-03 20:29:51 -06:00
parent 50f5660740
commit dc4bcb19fa
5 changed files with 121 additions and 102 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
**/.venv/** **/.venv/**
**/__pycache__/** **/__pycache__/**
*.pyc *.pyc
TunicTransitionTracker TunicTransitionTracker*
settings.json settings.json
**/db.sqlite3 **/db.sqlite3
**/node_modules/** **/node_modules/**

Binary file not shown.

View File

@ -1,5 +1,3 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -7,12 +5,11 @@
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" /> <meta charset="UTF-8" />
{% comment %} <meta http-equiv="refresh" content="3"> {% endcomment %} {% comment %} <meta http-equiv="refresh" content="3" /> {% endcomment %}
{% load static tailwind_tags %} {% load static tailwind_tags %}
{% tailwind_css %} {% tailwind_css %}
{% load static %} {% load static %}
<script src="{% static 'tracker/assets/test.js' %}"></script> <script src="{% static 'tracker/assets/test.js' %}"></script>
</head> </head>
<body class="bg-[#242424]"> <body class="bg-[#242424]">
{% block content %} {% block content %}

View File

@ -4,6 +4,7 @@
{% block content %} {% block content %}
<div class="container monospace"> <div class="container monospace">
<div class="m-4 ring-4 rounded-md text-[#eee] bg-bluelight-translucent-dark ring-bluelight-dark"> <div class="m-4 ring-4 rounded-md text-[#eee] bg-bluelight-translucent-dark ring-bluelight-dark">
{% if debug != '' %}
<div class="p-4 flex flex-col space-y-4"> <div class="p-4 flex flex-col space-y-4">
<div class="flex pt-4 text-2xl mx-2"> <div class="flex pt-4 text-2xl mx-2">
<span class="relative inline-block align-middle h-8 w-8"><img src="{% static 'tracker/images/neofox_flag_trans_256.png' %}" alt="A trans pride fox emoji." /></span> <span class="relative inline-block align-middle h-8 w-8"><img src="{% static 'tracker/images/neofox_flag_trans_256.png' %}" alt="A trans pride fox emoji." /></span>
@ -22,17 +23,25 @@
<div class="grid gap-4 md:grid-cols-3 grid-flow-row"> <div class="grid gap-4 md:grid-cols-3 grid-flow-row">
{% for scene, scene_totals in totals.items %} {% for scene, scene_totals in totals.items %}
{% if scene != 'Entrances' and scene != 'Checks' %} {% if scene != 'Entrances' and scene != 'Checks' %}
<div class="p-2 flex flex-col rounded-md ring-4 ring-bluelight-dark bg-opacity-50 {% if scene_totals.Checks.Undiscovered > 0 and scene_totals.Entrances.Undiscovered > 0 %} {% if scene_totals.Checks.Undiscovered > 0 and scene_totals.Entrances.Undiscovered > 0 %}
<div class="p-2 flex flex-col rounded-md ring-4 ring-bluelight-dark bg-opacity-50 bg-green-900">
{% elif scene_totals.Checks.Undiscovered > 0 %}
{% elif scene_totals.Entrances.Undiscovered > 0 %}
{% endif %}">
<div>{{ scene }}:</div> <div>{{ scene }}:</div>
<div>Checks: {{ scene_totals.Checks.Undiscovered }}/{{ scene_totals.Checks.Total }}</div> <div>Checks: {{ scene_totals.Checks.Undiscovered }}/{{ scene_totals.Checks.Total }}</div>
<div>Entrances: {{ scene_totals.Entrances.Undiscovered }}/{{ scene_totals.Entrances.Total }}</div> <div>Entrances: {{ scene_totals.Entrances.Undiscovered }}/{{ scene_totals.Entrances.Total }}</div>
</div> </div>
{% elif scene_totals.Checks.Undiscovered > 0 %}
<div class="p-2 flex flex-col rounded-md ring-4 ring-bluelight-dark bg-opacity-50 bg-yellow-900">
<div>{{ scene }}:</div>
<div>Checks: {{ scene_totals.Checks.Undiscovered }}/{{ scene_totals.Checks.Total }}</div>
<div>Entrances: {{ scene_totals.Entrances.Undiscovered }}/{{ scene_totals.Entrances.Total }}</div>
</div>
{% elif scene_totals.Entrances.Undiscovered > 0 %}
<div class="p-2 flex flex-col rounded-md ring-4 ring-bluelight-dark bg-opacity-50 bg-blue-900">
<div>{{ scene }}:</div>
<div>Checks: {{ scene_totals.Checks.Undiscovered }}/{{ scene_totals.Checks.Total }}</div>
<div>Entrances: {{ scene_totals.Entrances.Undiscovered }}/{{ scene_totals.Entrances.Total }}</div>
</div>
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
@ -104,6 +113,7 @@
</div> </div>
</details> </details>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -9,7 +9,19 @@ import requests
def index(request): def index(request):
tracker_output = loads(requests.get('http://localhost:8000/spoiler').text) request_data = None
try:
request_data = requests.get('http://localhost:8000/spoiler').text
except:
context = {
"debug": "",
"totals": "",
"scene": "",
"scene_data": ""
}
template = loader.get_template("tracker/index.html")
return HttpResponse(template.render(context, request))
tracker_output = loads()
# with open('spoiler.json', 'r') as t: # with open('spoiler.json', 'r') as t:
# tracker_output = loads(t.read()) # tracker_output = loads(t.read())
tracker_debug = tracker_output["Debug"] tracker_debug = tracker_output["Debug"]