Skip to content

Commit 9f82369

Browse files
authored
Merge pull request #95 from GeriLife/django-debug-toolbar
Add Django debug toolbar
2 parents 4a0ca84 + cc2bc24 commit 9f82369

File tree

10 files changed

+37
-19
lines changed

10 files changed

+37
-19
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

core/settings.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
default=True,
3636
)
3737

38+
INTERNAL_IPS = [
39+
"127.0.0.1",
40+
]
41+
3842
ALLOWED_HOSTS = env.list(
3943
"DJANGO_ALLOWED_HOSTS",
4044
default=[
@@ -56,6 +60,7 @@
5660
"django.contrib.staticfiles",
5761
"crispy_forms",
5862
"crispy_bootstrap5",
63+
"debug_toolbar",
5964
"accounts",
6065
"activities",
6166
"caregivers",
@@ -71,6 +76,12 @@
7176
CRISPY_TEMPLATE_PACK = "bootstrap5"
7277

7378
MIDDLEWARE = [
79+
# The order of MIDDLEWARE is important.
80+
# Include the Debug Toolbar middleware as early as possible in the list.
81+
# However, it must come after any other middleware that encodes
82+
# the response’s content, such as GZipMiddleware.
83+
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#add-the-middleware
84+
"debug_toolbar.middleware.DebugToolbarMiddleware",
7485
"django.middleware.security.SecurityMiddleware",
7586
"whitenoise.middleware.WhiteNoiseMiddleware",
7687
"django.contrib.sessions.middleware.SessionMiddleware",
@@ -87,9 +98,7 @@
8798
TEMPLATES = [
8899
{
89100
"BACKEND": "django.template.backends.django.DjangoTemplates",
90-
"DIRS": [
91-
str(BASE_DIR.joinpath("templates")),
92-
],
101+
"DIRS": [],
93102
"APP_DIRS": True,
94103
"OPTIONS": {
95104
"context_processors": [

core/urls.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
from django.views.generic.base import TemplateView
1919

2020
urlpatterns = [
21+
path(
22+
"__debug__/",
23+
include("debug_toolbar.urls"),
24+
),
2125
path("admin/", admin.site.urls),
2226
path(
2327
"i18n/",
@@ -47,5 +51,11 @@
4751
"work/",
4852
include("work.urls"),
4953
),
50-
path("", TemplateView.as_view(template_name="home.html"), name="home"),
54+
path(
55+
"",
56+
TemplateView.as_view(
57+
template_name="home.html",
58+
),
59+
name="home",
60+
),
5161
]

dev.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,6 @@ def uninstall_all_packages() -> None:
6969
"pip list --outdated",
7070
],
7171
),
72-
Command(
73-
alias="start-db",
74-
help_text="Start the database",
75-
commands_list=[
76-
"docker compose up -d wf_postgres_service",
77-
],
78-
),
79-
Command(
80-
alias="stop-db",
81-
help_text="Stop the database",
82-
commands_list=[
83-
"docker compose stop wf_postgres_service",
84-
],
85-
),
8672
Command(
8773
alias="install",
8874
help_text="Install project dependencies",

homes/templates/homes/home_detail.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ <h2 class="mt-3">{% translate "Current Residents" %}</h2>
2626
<table class="table">
2727
<caption>{% translate "Table of residents showing current activity status, total activity count, and daily activity indicators for past seven days." %}</caption>
2828
<tr>
29+
<th class="col">
30+
{% translate "View" %}
31+
</th>
2932
<th class="col-lg-1 col-2">{% translate "Name" %}</th>
3033
<th class="col-md-1">{% translate "Activity Level" %}</th>
3134
<th class="col-md-1 text-center">{% translate "Total Activities" %}</th>
@@ -36,7 +39,15 @@ <h2 class="mt-3">{% translate "Current Residents" %}</h2>
3639
</tr>
3740
{% for resident in home.current_residents_with_recent_activity_metadata.residents %}
3841
<tr>
39-
<td>{{ resident.resident.full_name }}</td>
42+
<td>
43+
<a class="btn btn-outline-primary btn-sm"
44+
href="{% url 'resident-detail-view' resident.resident.url_uuid %}">
45+
<i class="bi bi-eye"></i>
46+
</a>
47+
</td>
48+
<td>
49+
{{ resident.resident.first_name }}&nbsp;{{ resident.resident.last_initial }}
50+
</td>
4051
<td>
4152
<span class="badge text-bg-{{ resident.resident.activity_level.color_class }}">
4253
{{ resident.resident.activity_level.text }}

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
asgiref==3.7.2
2+
coverage==7.3.3
23
crispy-bootstrap5==2023.10
34
Django==5.0
45
django-crispy-forms==2.1
6+
django-debug-toolbar==4.2.0
57
django-environ==0.11.2
68
factory-boy==3.3.0
79
Faker==21.0.0

0 commit comments

Comments
 (0)