Skip to content

Commit 339955c

Browse files
authored
Merge pull request #14 from noamkush/ddt3_fixes
Support Django debug toolbar 3.0
2 parents 0ea63ed + e39cbbb commit 339955c

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

elastic_panel/panel.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from django.conf import settings
2-
from django.template.loader import render_to_string
1+
from django.templatetags.static import static
32
from django.utils.translation import ugettext_lazy as _
43
from debug_toolbar.panels import Panel
54
from debug_toolbar.utils import ThreadCollector
@@ -61,20 +60,26 @@ class ElasticDebugPanel(Panel):
6160
nb_duplicates = 0
6261
nb_queries = 0
6362

63+
@property
6464
def nav_title(self):
6565
return _("Elastic Queries")
6666

67+
@property
6768
def nav_subtitle(self):
6869
default_str = "{} queries {:.2f}ms".format(self.nb_queries, self.total_time)
6970
if self.nb_duplicates > 0:
7071
default_str += " {} DUPE".format(self.nb_duplicates)
7172
return default_str
7273

73-
def url(self):
74-
return ""
75-
74+
@property
7675
def title(self):
77-
return self.nav_title()
76+
return self.nav_title
77+
78+
@property
79+
def scripts(self):
80+
scripts = super().scripts
81+
scripts.append(static("elastic_panel/js/elastic_panel.js"))
82+
return scripts
7883

7984
def process_request(self, request):
8085
collector.clear_collection()

elastic_panel/static/elastic_panel/js/elastic_panel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var showHandler = function(e) {
1414

1515
toggle(this.nextElementSibling)
1616

17-
arrow = document.querySelector('a.elasticShowTemplate .toggleArrow')
17+
var arrow = document.querySelector('a.elasticShowTemplate .toggleArrow')
1818
arrow.textContent = arrow.textContent == uarr ? darr : uarr
1919

2020
toggle(this.parentNode.nextElementSibling)
@@ -27,8 +27,8 @@ for (var e of document.querySelectorAll('a.elasticShowTemplate')) {
2727
}
2828

2929
var textHandler = function(e) {
30-
selection = window.getSelection();
31-
range = document.createRange();
30+
var selection = window.getSelection();
31+
var range = document.createRange();
3232
range.selectNodeContents(this.parentNode.nextElementSibling.querySelector('code'));
3333
selection.removeAllRanges();
3434
selection.addRange(range);

elastic_panel/templates/elastic_panel/elastic_panel.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,3 @@
4545
</p>
4646
{% endif %}
4747
{% endif %}
48-
49-
<script src="{% static 'elastic_panel/js/elastic_panel.js' %}"></script>

0 commit comments

Comments
 (0)