Skip to content

Commit 64d928f

Browse files
authored
Merge branch 'main' into javascript-load-panel-event
2 parents e766af7 + 5a3ccd9 commit 64d928f

File tree

26 files changed

+183
-76
lines changed

26 files changed

+183
-76
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ jobs:
1515
mariadb:
1616
image: mariadb:10.3
1717
env:
18-
MYSQL_ROOT_PASSWORD: mysql
19-
MYSQL_DATABASE: mysql
18+
MYSQL_ROOT_PASSWORD: debug_toolbar
2019
options: >-
2120
--health-cmd "mysqladmin ping"
2221
--health-interval 10s
@@ -61,11 +60,10 @@ jobs:
6160
run: tox
6261
env:
6362
DB_BACKEND: mysql
64-
DB_NAME: mysql
6563
DB_USER: root
66-
DB_PASSWORD: mysql
67-
DB_HOST: "127.0.0.1"
68-
DB_PORT: "3306"
64+
DB_PASSWORD: debug_toolbar
65+
DB_HOST: 127.0.0.1
66+
DB_PORT: 3306
6967

7068
- name: Upload coverage
7169
uses: codecov/codecov-action@v1
@@ -84,7 +82,9 @@ jobs:
8482
postgres:
8583
image: 'postgres:9.5'
8684
env:
87-
POSTGRES_PASSWORD: postgres
85+
POSTGRES_DB: debug_toolbar
86+
POSTGRES_USER: debug_toolbar
87+
POSTGRES_PASSWORD: debug_toolbar
8888
ports:
8989
- 5432:5432
9090
options: >-
@@ -129,9 +129,6 @@ jobs:
129129
run: tox
130130
env:
131131
DB_BACKEND: postgresql
132-
DB_NAME: postgres
133-
DB_USER: postgres
134-
DB_PASSWORD: postgres
135132
DB_HOST: localhost
136133
DB_PORT: 5432
137134

.tx/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
host = https://www.transifex.com
33
lang_map = sr@latin:sr_Latn
44

5-
[django-debug-toolbar.master]
5+
[django-debug-toolbar.main]
66
file_filter = debug_toolbar/locale/<lang>/LC_MESSAGES/django.po
77
source_file = debug_toolbar/locale/en/LC_MESSAGES/django.po
88
source_lang = en

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ style: package-lock.json
88
flake8
99
npx eslint --ignore-path .gitignore --fix .
1010
npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS)
11+
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1112

1213
style_check: package-lock.json
1314
isort -c .
1415
black --target-version=py36 --check .
1516
flake8
1617
npx eslint --ignore-path .gitignore .
1718
npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS)
19+
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1820

1921
example:
2022
python example/manage.py migrate --noinput

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Django Debug Toolbar
1010
:target: https://github.com/jazzband/django-debug-toolbar/actions
1111
:alt: Build Status
1212

13-
.. image:: https://codecov.io/gh/jazzband/django-debug-toolbar/branch/master/graph/badge.svg
13+
.. image:: https://codecov.io/gh/jazzband/django-debug-toolbar/branch/main/graph/badge.svg
1414
:target: https://codecov.io/gh/jazzband/django-debug-toolbar
1515
:alt: Test coverage status
1616

@@ -28,7 +28,7 @@ more details about the panel's content.
2828

2929
Here's a screenshot of the toolbar in action:
3030

31-
.. image:: https://raw.github.com/jazzband/django-debug-toolbar/master/example/django-debug-toolbar.png
31+
.. image:: https://raw.github.com/jazzband/django-debug-toolbar/main/example/django-debug-toolbar.png
3232
:alt: Django Debug Toolbar screenshot
3333

3434
In addition to the built-in panels, a number of third-party panels are

debug_toolbar/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
__all__ = ["VERSION"]
22

33

4-
try:
5-
import pkg_resources
6-
7-
VERSION = pkg_resources.get_distribution("django-debug-toolbar").version
8-
except Exception:
9-
VERSION = "unknown"
10-
4+
# Do not use pkg_resources to find the version but set it here directly!
5+
# see issue #1446
6+
VERSION = "3.2"
117

128
# Code that discovers files or modules in INSTALLED_APPS imports this module.
139

debug_toolbar/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, get_response):
4444
def __call__(self, request):
4545
# Decide whether the toolbar is active for this request.
4646
show_toolbar = get_show_toolbar()
47-
if not show_toolbar(request) or request.path.startswith("/__debug__/"):
47+
if not show_toolbar(request) or DebugToolbar.is_toolbar_request(request):
4848
return self.get_response(request)
4949

5050
toolbar = DebugToolbar(request, self.get_response)

debug_toolbar/panels/cache.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
import time
44
from collections import OrderedDict
55

6+
try:
7+
from django.utils.connection import ConnectionProxy
8+
except ImportError:
9+
ConnectionProxy = None
10+
611
from django.conf import settings
712
from django.core import cache
8-
from django.core.cache import CacheHandler, caches as original_caches
13+
from django.core.cache import (
14+
DEFAULT_CACHE_ALIAS,
15+
CacheHandler,
16+
cache as original_cache,
17+
caches as original_caches,
18+
)
919
from django.core.cache.backends.base import BaseCache
1020
from django.dispatch import Signal
1121
from django.middleware import cache as middleware_cache
@@ -246,8 +256,13 @@ def enable_instrumentation(self):
246256
else:
247257
cache.caches = CacheHandlerPatch()
248258

259+
# Wrap the patched cache inside Django's ConnectionProxy
260+
if ConnectionProxy:
261+
cache.cache = ConnectionProxy(cache.caches, DEFAULT_CACHE_ALIAS)
262+
249263
def disable_instrumentation(self):
250264
cache.caches = original_caches
265+
cache.cache = original_cache
251266
# While it can be restored to the original, any views that were
252267
# wrapped with the cache_page decorator will continue to use a
253268
# monkey patched cache.

debug_toolbar/panels/request.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@ def generate_stats(self, request, response):
4444
view_info["view_func"] = get_name_from_obj(func)
4545
view_info["view_args"] = args
4646
view_info["view_kwargs"] = kwargs
47-
view_info["view_urlname"] = getattr(match, "url_name", _("<unavailable>"))
47+
48+
if getattr(match, "url_name", False):
49+
url_name = match.url_name
50+
if match.namespaces:
51+
url_name = ":".join([*match.namespaces, url_name])
52+
else:
53+
url_name = _("<unavailable>")
54+
55+
view_info["view_urlname"] = url_name
56+
4857
except Http404:
4958
pass
5059
self.record_stats(view_info)

debug_toolbar/static/debug_toolbar/css/toolbar.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
#djDebug .djdt-width-60 {
602602
width: 60%;
603603
}
604+
#djDebug .djdt-max-height-100 {
605+
max-height: 100%;
606+
}
604607
#djDebug .djdt-highlighted {
605608
background-color: lightgrey;
606609
}

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const djdt = {
4545
inner.previousElementSibling.remove(); // Remove AJAX loader
4646
inner.innerHTML = data.content;
4747
$$.executeScripts(data.scripts);
48+
$$.applyStyles(inner);
4849
djDebug.dispatchEvent(
4950
new CustomEvent("djdt.panel.render", {
5051
detail: { panelId: panelId },

0 commit comments

Comments
 (0)